linux怎样修改网卡的名字为eth0

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux怎样修改网卡的名字为eth0相关的知识,希望对你有一定的参考价值。

linux可通过以下步骤修改网卡名称:
1、修改/etc/udev/rules.d/70-persistent-net.rules,将eth0 改为em1,将eth1 改为em2,注意:只需要修改name即可,不需要修改kernel;
2、重命名网卡配置文件,需要ifcfg-eth0文件重命名为ifcfg-em1,需要ifcfg-eth1文件重命名为ifcfg-em2,
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-em1
mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-em2
3、编辑网卡配置文件,将名称修改过来,并把uuid删除(如没有就不用),重启服务器,重启之后网卡名称已经修改过来,网络正常。
参考技术A linux可通过以下步骤修改网卡名称:1、修改/etc/udev/rules.d/70-persistent-net.rules,将eth0 改为em1,将eth1 改为em2,注意:只需要修改name即可,不需要修改kernel;2、重命名网卡配置文件,需要ifcfg-eth0文件重命名为ifcfg-em1,需要ifcfg-eth1文件重命名为ifcfg-em2,mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-em1mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-em23、编辑网卡配置文件,将名称修改过来,并把uuid删除(如没有就不用),重启服务器,重启之后网卡名称已经修改过来,网络正常。 参考技术B 1.shutdown 相应接口,将 /etc/sysconfig/network-scripts/ifcfg-eth0中的 DEVICE=eth0 HWADDR=00:1e:ec:0f:79:f6 修改或添加 并将下面文件中修改成和上述一致 /etc/udev/rules.d/70-persistent-net.rules # PCI device 0x14e4:0x1713 (tg3) SUB...本回答被提问者采纳

centos7修改网卡名字为传统名字

前言:在centos6及其之前的系统中,我们已经习惯了网卡为eth0,eht1这种网卡命名方式,在centos7上网卡名字为ens33,ens37,ens38等名字,很别扭,想统一下网卡的命名。

1 修改内核配置文件

[[email protected] ~]$ sed -r -i.bak /^GRUB_CMDLINE_LINUX/[email protected](.*)"@\1 net.ifnames=0 biosdevname=0"@ /etc/default/grub               # 修改下grub的配置文件   -i.bak保留原始文件的备份为.bak文件
[[email protected] ~]$ cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak                                                              # 备份配置文件
[[email protected] ~]$ grub2-mkconfig -o /boot/grub2/grub.cfg                                                                         # grub2-mkconfig 生成配置文件
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-063d6d8599b74e68adab2b5e6cc3add8
Found initrd image: /boot/initramfs-0-rescue-063d6d8599b74e68adab2b5e6cc3add8.img
done

2 修改已有的网卡信息

[[email protected] network-scripts]$ mv ifcfg-ens33 ifcfg-eth0                                                             # 已有网卡的重命名,我这里只有ens33有配置,只做这个网卡的处理
[[email protected] network-scripts]$ sed -ir [email protected]@[email protected] ifcfg-eth0                                                    # 替换ens33为eth0
[[email protected] network-scripts]$ cat ifcfg-eth0                                                                        # 检查下
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=f20778dd-bdaa-4e5c-8e2a-8fef4ec151a0
DEVICE=eth0
ONBOOT=yes

3 重启检查

重启

[[email protected] ~]$ reboot                                                                                    # 重启系统

 检查下

[[email protected] ~]$ ip a                                                                                       # 检查
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:ad:b0:f2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.105/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 172502sec preferred_lft 172502sec
    inet6 fe80::424f:3b52:2ac8:2535/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:ad:b0:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.27.141/24 brd 192.168.27.255 scope global dynamic eth1
       valid_lft 1503sec preferred_lft 1503sec
    inet6 fe80::25f5:cc0c:6e2a:d1b2/64 scope link 
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:ad:b0:06 brd ff:ff:ff:ff:ff:ff
    inet 192.168.27.142/24 brd 192.168.27.255 scope global dynamic eth2
       valid_lft 1503sec preferred_lft 1503sec
    inet6 fe80::7046:9827:fa73:db4c/64 scope link 
       valid_lft forever preferred_lft forever
5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:3f:39:3a brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:3f:39:3a brd ff:ff:ff:ff:ff:ff
7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 02:42:ba:6e:03:4f brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever

 

以上是关于linux怎样修改网卡的名字为eth0的主要内容,如果未能解决你的问题,请参考以下文章

RHEL7/centos7修改网卡名称为eth0

centos7修改网卡名字为传统名字

Linux操作-修改克隆虚拟机的网卡名

Linux下网卡eth1如何修改为eth0

centos7修改网卡名字

RHEL7/centos7修改网卡名称为eth0