1.进入配置文件
vi /etc/network/interfaces
root@cubietruck-plus:~# vi /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo eth0
#allow-hotplug eth0
iface lo inet loopback #将lo接口设置为一个本地回环(loopback)地址
#iface eth0 inet dhcp #指出eth0接口自动获取IP
iface eth0 inet static #指出eth0接口具有一个静态的(static)IP配置
address 192.168.0.231
mask 255.255.255.0
gateway 192.168.0.1
#"your-ssid-here" and "your-passwd-here" should been replase with yours and remove the annotation
#auto wlan0
#iface wlan0 inet dhcp
#pre-up ip link set wlan0 up
#pre-up iwconfig wlan0 essid your-ssid-here
#wpa-ssid your-ssid-here
#wpa-psk your-passwd-here
2. auto 和auto-hotplug
auto
语法:
auto <interface_name>
含义:
在系统启动的时候启动网络接口,无论网络接口有无连接(插入网线),如果该接口配置了DHCP,则无论有无网线,系统都会去执行DHCP,如果没有插入网线,则等该接口超时后才会继续。
allow-hotplug
语法:
allow-hotplug <interface_name>
含义:
只有当内核从该接口检测到热插拔事件后才启动该接口。如果系统开机时该接口没有插入网线,则系统不会启动该接口,系统启动后,如果插入网线,系统会自动启动该接口。也就是将网络接口设置为热插拔模式。
3. 手动重新启动网络
一般修改了网络配置文件后,会用以下命令重新启动网络
/etc/init.d/networking restart
4.其他
`ifconfig eth0 down
#将网卡禁用命令
ifconfig eth0 up
#将网卡启用命令`
链接
链接:https://blog.csdn.net/mountzf/article/details/52035499