首页 > 网络 > 其他 >

如何修改CentOS 7.6的网卡名称-fdffsddd的博客-51CTO博客

2019-11-22

我们习惯了eth0这样的网络设备命名,在centos6发现网络设备变成了em1这样的命名,到了CentOS 7版本对网卡的命名规则又进行了重新定义,因此,对于这个命名规则的修改,还是让很多人比较头疼,无法适应这种随机生

我们习惯了eth0这样的网络设备命名,在centos6发现网络设备变成了em1这样的命名,到了CentOS 7版本对网卡的命名规则又进行了重新定义,因此,对于这个命名规则的修改,还是让很多人比较头疼,无法适应这种随机生成的网卡名称,下面就教大家如何将网卡固定修改为eth0,操作步骤也很简单;

    修改方法进入到/etc/sysconfig/network-scripts/目录下,备份网卡文件[root@192168088102-NFS-Server ~]# cd /etc/sysconfig/network-scripts/[root@192168088102-NFS-Server network-scripts]# lsifcfg-ens33 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functionsifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global[root@192168088102-NFS-Server network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak[root@192168088102-NFS-Server network-scripts]# ll ifcfg-ens33-rw-r--r--. 1 root root 347 Jul 27 11:41 ifcfg-ens33-rw-r--r--. 1 root root 347 Jul 27 12:48 ifcfg-ens33.bak将网卡文件名称改为ifcfg-eth0,并修改网卡配置文件[root@192168088102-NFS-Server network-scripts]# mv ifcfg-ens33 ifcfg-eth0[root@192168088102-NFS-Server network-scripts]# ll ifcfg-eth0-rw-r--r--. 1 root root 347 Jul 27 11:41 ifcfg-eth0[root@192168088102-NFS-Server network-scripts]# cat ifcfg-eth0TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=staticDEFROUTE=yesIPV4_FAILURE_FATAL=no#将ens33改为eth0NAME=eth0UUID=7615d0b6-d6c2-46bf-9140-45083e4aed4b#将ens33改为eth0DEVICE=eth0ONBOOT=yesIPADDR=192.168.88.102NETMASK=255.255.255.0GATEWAY=192.168.88.2修改grub文件,添加内核参数net.ifnames=0 biosdevname=0信息,使网卡名称修改为eth0[root@192168088102-NFS-Server network-scripts]# cat /etc/sysconfig/grubGRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet"GRUB_DISABLE_RECOVERY="true"生成启动菜单,重新加载到启动中,并重启系统[root@192168088102-NFS-Server network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfgGenerating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-dc723d2d2d444cf0ae3794ab211366b8Found initrd image: /boot/initramfs-0-rescue-dc723d2d2d444cf0ae3794ab211366b8.imgdone[root@192168088102-NFS-Server network-scripts]# reboot验证网卡是否成功修改为eth0[root@192168088102-NFS-Server ~]# ip addr1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:b6:52:ed brd ff:ff:ff:ff:ff:ffinet 192.168.88.102/24 brd 192.168.88.255 scope global noprefixroute eth0valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:feb6:52ed/64 scope linkvalid_lft forever preferred_lft forever
相关文章
最新文章
热点推荐