centos6中修改網卡名稱方法
歸納步驟:vim
1.修改 /etc/udev/rules.d/70-persistent-net.rules 文件中網卡名
2.ethtool -i eth2 查看網卡驅動模塊名
3.modprobe -r e1000 卸載網卡模塊
4.modprobe e1000 從新加載網卡模塊
5.修改/etc/sysconfig/network-scripts中網卡的配置文件(使其格式爲ifcfg-網卡名)
6.重啓網卡服務/etc/inint.d/network restartcentos
具體步驟以下:
一、編輯 /etc/udev/rules.d/70-persistent-net.rules 將其中網卡mask地址對應的網卡名稱更改成所需的名稱,(我用的是vi你能夠使用vim)
[root@centos6 ~]#vi /etc/udev/rules.d/70-persistent-net.rules ide
2.ethtool -i eth2 || dmesg | grep –i eth0 查看驅動模塊信息(兩個命令均可以使用)
# dmesg //顯示開機加載的網卡信息 grep –i eth0 過濾信息 (沒有太大用)
# #ethtool eth2 //這個命令是查看網卡更詳細的信息的好比工做模式是否爲雙工模式 oop
3.modprobe -r e1000 || rmmod e1000 卸載模塊(兩個命令均可以使用 )
4.modprobe e1000 從新加載模塊rest
5.在/etc/sysconfig/network-scripts/中將原網卡的配置文件改文件名,使其格式爲ifcfg-網卡名
(新加的網卡可能會出現沒有配置文件,複製一份其餘網卡配置文件進行修改)code
修改網卡的配置文件(網卡的IP地址等信息是讀取這個配置文件的)
7.ifdown 網卡名 //關閉網卡blog
[root@centos6 ~]#ifup eth1
8.ifup 網卡名 //啓動網卡ip
[root@centos6 ~]#ifdown eth1
也能夠將兩步驟合併成:it
service network restart //啓動網卡服務 [root@centos6mini ~]# /etc/init.d/network restart //重啓網卡服務 [root@centos6 ~]#service network restart //重啓網卡服務 Shutting down interface eth0: Device state: 3 (disconnect Shutting down interface eth1: Device state: 3 (disconnected) [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Active connection state: activating Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/17 state: activated Connection activated [ OK ] Bringing up interface eth1: Active connection state: activating Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/18 state: activated Connection activated [ OK ]
還有能夠使用新服務(NetworkManager),來實現更改網卡配置文件的方式:
[root@centos6 ~]#vi /etc/sysconfig/network-scripts/ifcfg-eth1io
從新加載網卡模塊
重啓網卡服務
[root@centos6 ~]# service NetworkManager restart
[root@centos6 ~]# /etc/init.d/NetworkManager restart