天天看點

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=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"      
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      

繼續閱讀