CentOS 7 修改网卡名称

前端之家收集整理的这篇文章主要介绍了CentOS 7 修改网卡名称前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

方法一:禁用该可预测命名规则

1、对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现的。

cat/etc/sysconfig/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="ipv6.disable=1crashkernel=autorhgbquietnet.ifnames=0biosdevname=0"
GRUB_DISABLE_RECOVERY="true"

2、运行命令grub2-mkconfig -o /boot/grub2/grub.cfg来重新生成GRUB配置并更新内核参数。

3、reboot


方法二:修改rules文件

1、文件没有的话可以手动创建,后缀是.rules,按照顺序将MAC地址与网卡名称绑定

cat/etc/udev/rules.d/70-persistent-ipoib.rules
#Thisisasampleudevrulesfilethatdemonstrateshowtogetudevto
#setthenameofIPoIBinterfacestowhateveryouwish.Thereisa
#16characterlimitonnetworkdevicenamesthough,sodon'tgotoonuts
#
#Importantitemstonote:ATTR{type}=="32"isIPoIBinterfaces,andthe
#ATTR{address}matchmuststartwith?*andonlyreferencethelast8
#bytesoftheaddressorelsetheaddressmightnotmatchonanygiven
#startoftheIPoIBstack
#
#Note:asofrhel7,udeviscasesensitiveontheaddressfieldmatch
#andalladdressesneedtobeinlowercase.
#
#ACTION=="add",SUBSYSTEM=="net",DRIVERS=="?*",ATTR{type}=="32",ATTR{address}=="?*00:02:c9:03:00:31:78:f2",NAME="mlx4_ib3"
ACTION=="add",ATTR{address}=="?*00:0c:29:7a:1e:16",NAME="eth0"

2、修改网卡配置文件,配置DEVICE和NAME,并加入HWADDR

注:DEVICE、NAME和HWADDR 要和.rules 里面相对应

cat/etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
NAME=eth0
#UUID=408326bb-7565-4aa5-b156-c89a0ba839d2
HWADDR=00:0c:29:7a:1e:16
DEVICE=eth0
ONBOOT=yes
IPADDR=172.16.18.188
NETMASK=255.255.255.0
GATEWAY=172.16.18.1
DNS=219.141.136.10

3、reboot

原文链接:https://www.f2er.com/centos/375198.html

猜你在找的CentOS相关文章