歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

Centos7更改默認網卡為eth

Centos7更改默認網卡為eth


Centos7更改默認網卡為eth


1.更改默認網卡為eth0

vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

#首先,先編輯網卡的配置文件, 將裡面的NAME項修改為eth0

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

#然後,重命名該文件

2.編輯Grub配置

vim/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=autord.lvm.lv=centos/rootrd.lvm.lv=centos/swapnet.ifnames=0biosdevname=0rhgbquiet"

GRUB_DISABLE_RECOVERY="true"

#禁用該可預測命名規則。在啟動時傳遞“net.ifnames=0 biosdevname=0 ”的內核參數。通過編輯/etc/default/grub並加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX變量來實現的。

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

#重新生成GRUB配置並更新內核參數

3.設置設備名規則

vim/etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:0c:29:84:3a:14",ATTR{type}=="1",KERNEL=="eth*",NAME="eth0"

#根據Centos 官方WIKI的FAQ中得知,如果你有多個接口,並且想要控制其設備名,而不是讓內核以它自己的方式命名,創建,/etc/udev/rules.d/XXX-net.rules規則是必要的

#重啟後,O了

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:5b:71:b3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.205/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe5b:71b3/64 scope link

http://xxxxxx/Linuxjc/1144501.html TechArticle

Copyright © Linux教程網 All Rights Reserved