[root@pdshow ~]# ping www.baidu.com
connect: 網絡不可達
[root@pdshow ~]# ifconfig eth0 192.168.121.51 netmask 255.255.255.0 \
broadcast 192.168.121.255
[root@pdshow ~]# route add default gw 192.168.120.1
SIOCADDRT: 沒有那個進程
手動設定的 IP 完全沒生效,等於白做。
正在關閉接口 eth0: 錯誤:斷開設備 'eth0' (/org/freedesktop/NetworkManager/Devices/0) 失敗: This device is not active;
網上有說法是 NetworkManager 會干擾 /etc/init.d/network,於是:
service NetworkManager stop # 停止 NetworkManager 守護進程:[確定]
結果一樣無效,service network restart 仍然失敗。
vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet UUID=fd7935ed-d944-4a1a-81eb-bf72b1e368c0 ONBOOT=no NM_CONTROLLED=yes BOOTPROTO=none HWADDR=00:0c:29:cd:1f:68 IPADDR=192.168.121.52 PREFIX=23 GATEWAY=192.168.120.1 DNS1=192.168.121.212 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0"
關鍵就是 ONBOOT=no——這個值代表開機時不啟用網卡,設定自然不會生效。改成 yes 才是對的。
/etc/init.d/network restart
這次設定正常載入,網路問題解決。