
我在使用kolla部署openstack的时候,会出现同一网段的网卡名称不一样的情况
1.查看IP地址和网卡信息
此时我们可以看到我的两块物理网卡的名字分别为ens32和ens33

2.假如我想修改名称为ens33为eth0,ens32e为eth1
[root@controller ~]# vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
这一行添加上net.ifnames=0 biosdevname=0参数
[root@controller ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 biosdevname=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
3.加载配置文件
- 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-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-8c75cb6e910544c8a8dabe6bae037f3b
Found initrd image: /boot/initramfs-0-rescue-8c75cb6e910544c8a8dabe6bae037f3b.img
done
4.修改网卡名称
- 这里值得一提的事当我们把默认的第一块网卡改名字后,其他剩余的网卡也会自动的更改名字
[root@controller ~]# cd /etc/sysconfig/network-scripts/
[root@controller network-scripts]# vim ifcfg-ens32
NAME=eth0
DEVICE=eth0
[root@controller network-scripts]# mv ifcfg-ens32 ifcfg-eth0
5.重启虚拟机
- 查看网络服务运行状态
[root@controller ~]# systemctl restart network
[root@controller ~]# systemctl status network
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: active (exited) since 一 2020-05-25 09:48:55 CST; 6s ago
Docs: man:systemd-sysv-generator(8)
Process: 9235 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
Process: 9341 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller network[9341]: RTNETLINK answers: File exists
5月 25 09:48:55 controller systemd[1]: Started LSB: Bring up/down networking.
[root@controller ~]# nmcli connection show
NAME UUID TYPE DEVICE
eth0 5e39b3b6-6e23-3d57-a5c1-cb7ffcf7f0f5 ethernet eth0
eth1 c8ae01dc-f2ba-3e08-ace6-0303a14fb016 ethernet eth1

[root@controller ~]# ping -c 5 www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=128 time=16.7 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=128 time=20.7 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=3 ttl=128 time=17.0 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=4 ttl=128 time=16.8 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=5 ttl=128 time=16.5 ms
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4008ms
rtt min/avg/max/mdev = 16.544/17.582/20.743/1.592 ms