$ ifconfig -a
展示全部網卡
$ ifconfig enp2s0 up
啓用網卡enp2s0
$ sudo vi /etc/network/interfaces
auto enp2s0
iface enp2s0 inet static
address 192.168.2.10
network 255.255.255.0
gateway 192.168.2.1
Ubuntu14.04重啓網卡的三種方法:
一、network
利用root帳戶
service networking restart
或者/etc/init.d/networking restart
二、ifdown/ifup
ifdown enp2s0
ifup enp2s0
三、ifconfig
ifconfig enp2s0 down
ifconfig enp2s0 up
Ubuntu14.04修改配置,重啓網卡沒有生效,出現如下問題:
service networking restart //重啓網絡服務
stop: Job failed while stopping
start: Job is already running: networking
tail -f /var/log/upstart/networking.log //查看錯誤日誌
Stopping or restarting the networking job is notsupported.
Use ifdown & ifup to reconfigure desired interface.
從以上日誌內容可以看出,傳統的service重啓和停止網絡已經不再支持了,需要通過使用ifdown &ifup來實現相應的操作。tail -f /var/log/upstart/networking.log
重啓指定網卡
ifdown enp2s0 && ifup enp2s0