anaconda如何修改虚拟环境的名称_CentOS7如何修改网卡名称

a6efe6c31bc86a06d974a79f4066cbf7.png

我在使用kolla部署openstack的时候,会出现同一网段的网卡名称不一样的情况

1.查看IP地址和网卡信息

此时我们可以看到我的两块物理网卡的名字分别为ens32和ens33

b4104ecdc8ebb0cf57dd96ad0ed6ffdd.png

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 

8ed1f65001ced3fa7c54bbbc017f56ea.png
[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值