我在vmware workstation裡面安裝的centos7虛擬機器設定了2張網絡卡,網絡卡名稱預設為eno16777736、eno33554984:
[root@controller ~]# ip a
1: lo: mtu 65536 qdisc noqueue state unknown qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:50:56:3a:78:ee brd ff:ff:ff:ff:ff:ff
inet 192.168.128.85/24 brd 192.168.128.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe3a:78ee/64 scope link
valid_lft forever preferred_lft forever
3: eno33554984:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:0c:29:72:41:10 brd ff:ff:ff:ff:ff:ff
inet 10.10.10.10/24 brd 10.10.10.255 scope global eno33554984
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe72:4110/64 scope link
valid_lft forever preferred_lft forever
如果改為eth0、eth1,該如何操作呢?
1.修改配置
[root@controller ~]# vi /etc/default/grub
grub_cmdline_linux
加上net.ifnames=0 biosdevname=0
grub_cmdline_linux="net.ifnames=0 biosdevname=0 crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
grub2-mkconfig -o /boot/grub2/grub.cfg
[root@controller ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
generating grub configuration file ...
found linux image: /boot/vmlinuz-3.10
.0-693.5
.2.el7.x86_64
found initrd image: /boot/initramfs-3.10
.0-693.5
.2.el7.x86_64.img
found linux image: /boot/vmlinuz-3.10
.0-327.28
.3.el7.x86_64
found initrd image: /boot/initramfs-3.10
.0-327.28
.3.el7.x86_64.img
found linux image: /boot/vmlinuz-3.10
.0-327.el7.x86_64
found initrd image: /boot/initramfs-3.10
.0-327.el7.x86_64.img
found linux image: /boot/vmlinuz-0-rescue-0ff0e879cd2f443cb90ec9afa4d66dfb
found initrd image: /boot/initramfs-0-rescue-0ff0e879cd2f443cb90ec9afa4d66dfb.img
done
3.修改網絡卡名稱
[root@controller ~]# cd /etc/sysconfig/network-scripts/
[root@controller network-scripts]# vi ifcfg-eno16777736
修改為
name=eth0
device=eth0
[root@controller network-scripts]# mv ifcfg-eno16777736 ifcfg-eth0
同樣另外一張網絡卡改為eth1
4.重啟機器
發現通過ssh連線不到 192.168.128.85
進入vmware控制台檢視,還是顯示原網絡卡名稱,再檢視網路服務狀態,顯示failed
如何解決?
進入目錄/etc/udev/rules.d/
[root@controller ~]# cd /etc/udev/rules.d/
檢視 90-eno-pix.rules
# this file was automatically generated on systemd update
subsystem=="net", action=="add", drivers=="?*", attr=="00:50:56:3a:78:ee", name="eno16777736"
subsystem=="net", action=="add", drivers=="?*", attr=="00:0c:29:72:41:10", name="eno33554984"
看到還是之前的網絡卡名稱
刪掉此檔案,或者改為正確的網絡卡名稱,注意和mac對應,然後重啟機器
這次成功了
[root@controller ~]# ip a
1: lo: mtu 65536 qdisc noqueue state unknown qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:50:56:3a:78:ee brd ff:ff:ff:ff:ff:ff
inet 192.168.128.85/24 brd 192.168.128.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe3a:78ee/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:0c:29:72:41:10 brd ff:ff:ff:ff:ff:ff
inet 10.10.10.10/24 brd 10.10.10.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe72:4110/64 scope link
valid_lft forever preferred_lft forever
CentOS7修改網絡卡名稱
在centos7上,使用ifconfig檢視預設的網絡卡名稱是enp3s0,如果想修改網絡卡名稱,比如把網絡卡名改為eth0,需要通過下面步驟來實現。cd etc sysconfig network scripts sudo mv ifcfg enp3s0 ifcfg eth0device eth0...
Centos7修改網絡卡裝置名稱
從centos rhel7起,可預見的命名規則變成了預設。這一規則,介面名稱被自動基於韌體,拓撲結構和位置資訊來確定。現在,即使新增或移除網路裝置,介面名稱仍然保持固定,而無需重新列舉,和壞掉的硬體可以無縫替換。但是這樣一來,雖然有好處,但也影響了不少使用者的操作,因為新的命名方案介面名稱比傳統的e...
centos7系統修改網絡卡名稱
1.vim etc default grub,在 grub cmdline linux crashkernel auto rd.lvm.lv centos root rd.lvm.lv centos swap rhgb quiet 配置項中增加 net.ifnames 0 biosdevname 0...