本文共 1783 字,大约阅读时间需要 5 分钟。
方法一:禁用该可预测命名规则
1、对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现的。
cat /etc/sysconfig/grub GRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=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 # This is a sample udev rules file that demonstrates how to get udev to# set the name of IPoIB interfaces to whatever you wish. There is a# 16 character limit on network device names though, so don't go too nuts## Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the# ATTR{address} match must start with ?* and only reference the last 8# bytes of the address or else the address might not match on any given# start of the IPoIB stack## Note: as of rhel7, udev is case sensitive on the address field match# and all addresses need to be in lower case.## ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3"ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", 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=EthernetBOOTPROTO=staticDEFROUTE=yesNAME=eth0#UUID=408326bb-7565-4aa5-b156-c89a0ba839d2HWADDR=00:0c:29:7a:1e:16DEVICE=eth0ONBOOT=yesIPADDR=172.16.18.188NETMASK=255.255.255.0GATEWAY=172.16.18.1DNS=219.141.136.10
3、reboot
转载地址:http://yzasa.baihongyu.com/