在 Linux 中,ifconfig 本身是一个查看和配置网络接口的工具(来自 net-tools 包),可以用它来启用(up)网卡。
基本命令格式:
sudo ifconfig <网卡名> up
例如,开启 eth0:
sudo ifconfig eth0 up
如果是无线网卡,比如 wlan0:
sudo ifconfig wlan0 up
开启后通常不会自动获取 IP,需要手动配置或运行 DHCP。
sudo ifconfig eth0 up
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
或使用 DHCP 获取 IP(需 dhclient):
sudo ifconfig eth0 up
sudo dhclient eth0
ifconfig
或仅查看某个网卡:
ifconfig eth0
如果看到 UP 和 RUNNING,说明网卡已开启。
sudo ifconfig eth0 down
ifconfig 已逐渐被 ip 命令 取代:
sudo ip link set eth0 up
查看:
ip addr
如果你告诉我:
ip a 查看)我可以给你更精确的开启方式(包括开机自动启用)。