1. 程式人生 > >Ubuntu14.04重啟網絡卡的三種方法:

Ubuntu14.04重啟網絡卡的三種方法:

$ 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