centos7 更改成自己想要的網卡名稱

    當我們使用centos7時網卡名子過長,我們需要更改成自己想要的名字,過程如下:

1、備份並修改/etc/default/grub

[root@controller03 ~]# cp /etc/default/grub /etc/default/grub.bk

2、 let's disable the predictable naming rule. For that, you can pass "net.ifnames=0" kernel parameter during boot. This is achieved by editing /etc/default/grub and adding "net.ifnames=0" to GRUB_CMDLINE_LINUX variable

[root@controller03 ~]# cat  /etc/default/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="crashkernel=auto rd.lvm.lv=root_vg01/lv_01 net.ifnames=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

3、run this command to regenerate GRUB configuration with updated kernel parameters

[root@controller03 ~]# cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bk
[root@controller03 ~]# sudo grub2-mkconfig -o /boot/grub2/grub.cfg

4、修改 vim  /etc/udev/rules.d/70-persistent-net.rules 根據MAC對應 自己想要定義的網卡的名字

[root@controller03 ~]# cat  /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",ATTR{address}=="52:54:00:57:1a:ef", ATTR{type}=="1", KERNEL=="eth*",NAME="ens4"

#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",ATTR{address}=="52:54:00:37:dc:e0", ATTR{type}=="1", KERNEL=="eth*",NAME="eth1"

5、最後重啓系統即可!


參考鏈接

http://ask.xmodulo.com/change-network-interface-name-centos7.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章