centos7修改网卡名的操作过程

 

 

问题:搭建服务集群需要统一网卡名字
机器的enp2s0网卡修改为eth0

1,修改网卡配置文件

vim /etc/sysconfig/network-scripts/ifcfg-enp2s0
HWADDR=00:e0:67:1c:d1:10 #修改为网卡的mac地址,通过ifconfig查看
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
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" #修改需要的网卡名字
DEVICE="eth0" #修改需要的网卡名字
ONBOOT="yes"
IPADDR=10.144.100.90
NETMASK=255.255.255.0
GATEWAY=10.144.100.1
ZONE=public

2,重命名网卡配置文件

mv /etc/sysconfig/network-scripts/ifcfg-enp2s0 /etc/sysconfig/network-scripts/ifcfg-eth0

3,使用内核udev功能添加网卡,没有相应文件就新建
ATTER{address}填入网卡mac地址

vim /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:e0:67:1c:d1:10",ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"

4,重新生成GRUB配置并更新内核参数

grub2-mkconfig -o /boot/grub2/grub.cfg

5,重启查看网卡,修改成功

[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.144.100.90 netmask 255.255.255.0 broadcast 10.144.100.255
inet6 fe80::ef9e:a90:b800:3cd4 prefixlen 64 scopeid 0x20<link>
ether 00:e0:67:1c:d1:10 txqueuelen 1000 (Ethernet)
RX packets 14013 bytes 9910596 (9.4 MiB)
RX errors 0 dropped 364 overruns 0 frame 0
TX packets 5848 bytes 1148491 (1.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

posted @ 2022-08-27 16:32  纯捡垃圾吃的  阅读(726)  评论(0编辑  收藏  举报
返回顶部