CentOS多网卡重命名配置
CentOS多網卡重命名配置
在CentOS7中我安裝了3塊網卡,但是名字是enoxxxxx的格式,讓我這個有強迫癥的***座很是不爽,以下是我配置網卡并且重命名為ethx的詳細步驟
前提工作要做好:
1.查看網卡UUID
# nmcli con show
名稱 ?UUID ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?類型 ? ? ? ? ? ?設備?
eth1 ?dfc9199c-7b47-4209-a396-109bf44e683a ?802-3-ethernet ?eth1?
eth2 ?020d86aa-548f-49c2-9cb0-f6cfffdb8219 ?802-3-ethernet ?eth2?
eth0 ?a5e6ae5c-dd71-48be-b374-ad64121bd785 ?802-3-ethernet ?eth0
2.查看網卡信息
# nmcli device show [設備名] ?例:
# nmcli device show eth0
GENERAL.設備: ? ? ? ? ? ? ? ? ? ? ? ? ? eth0
GENERAL.類型: ? ? ? ? ? ? ? ? ? ? ? ? ? ethernet
GENERAL.硬盤: ? ? ? ? ? ? ? ? ? ? ? ? ? 00:0C:29:94:C8:08
GENERAL.MTU: ? ? ? ? ? ? ? ? ? ? ? ? ? ?1500
GENERAL.狀態: ? ? ? ? ? ? ? ? ? ? ? ? ? 100 (連接的)
GENERAL.CONNECTION: ? ? ? ? ? ? ? ? ? ? eth0
GENERAL.CON-PATH: ? ? ? ? ? ? ? ? ? ? ? /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.容器: ? ? ? ? ? ? ? ? ?開
IP4.地址[1]: ? ? ? ? ? ? ? ? ? ? ? ? ? ?192.168.66.4/24
IP4.網關: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 192.168.66.1
IP4.DNS[1]: ? ? ? ? ? ? ? ? ? ? ? ? ? ? 202.106.46.151
IP6.地址[1]: ? ? ? ? ? ? ? ? ? ? ? ? ? ?fe80::20c:29ff:fe94:c808/64
IP6.網關: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
??
步入正題
進入到網卡配置文件目錄
# cd /etc/sysconfig/network-scripts
將網卡重新命名
# mv ifcfg-eno16777736 ifcfg-eth0
修改網卡信息,不是很懂的小伙伴請參考我的另一篇詳細解說http://baoer7758.blog.51cto.com/8187563/1638229
# vim ifcfg-eth0?
HWADDR=00:0c:29:94:c8:08
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
NAME=eth0
UUID=a5e6ae5c-dd71-48be-b374-ad64121bd785
# DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.66.4
NETMASK=255.255.255.0
GATEWAY=192.168.66.1
DNS1=202.106.46.151
# DEVICE=eth0
將配置文件拷貝出來兩份作為另外兩個網卡的配置文件
# cp ifcfg-eth0 ifcfg-eth1
# cp ifcfg-eth0 ifcfg-eth2
編輯修改:
# vim ifcfg-eth1
HWADDR=00:0c:29:94:c8:12
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
NAME=eth1
UUID=dfc9199c-7b47-4209-a396-109bf44e683a
ONBOOT=yes
IPADDR=192.168.67.4
NETMASK=255.255.255.0
# DEVICE=eth0
編輯修改
# vim ifcfg-eth2
HWADDR=00:0c:29:94:c8:1c
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
NAME=eth2
UUID=020d86aa-548f-49c2-9cb0-f6cfffdb8219
# DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.68.4
NETMASK=255.255.255.0
# DEVICE=eth0
開始為重命名做配置, 不是很懂的小伙伴請參考我的另一篇詳細解說http://baoer7758.blog.51cto.com/8187563/1638229? ? ? ? ? ? ? ? ?
# vi /etc/sysconfig/grub?
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto net.ifnames=0 biosdevname=0 net.ifnames=1 biosdevname=1 net.ifnames=2 biosdevname=2 rhgb quiet" ? ? ? ? ? //加粗為添加內容
GRUB_DISABLE_RECOVERY="true"
重新加載到啟動中
# grub2-mkconfig -o /boot/grub2/grub.cfg?
Generating grub configuration file ...
Found linux p_w_picpath: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd p_w_picpath: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux p_w_picpath: /boot/vmlinuz-0-rescue-9bede79b46bd4e9696b92a4ec68a97b1
Found initrd p_w_picpath: /boot/initramfs-0-rescue-9bede79b46bd4e9696b92a4ec68a97b1.img
done
重新啟動系統reboot
查看網卡信息
# ifconfig?
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> ?mtu 1500
? ? ? ? inet 192.168.66.4 ?netmask 255.255.255.0 ?broadcast 192.168.66.255
? ? ? ? inet6 fe80::20c:29ff:fe94:c808 ?prefixlen 64 ?scopeid 0x20<link>
? ? ? ? ether 00:0c:29:94:c8:08 ?txqueuelen 1000 ?(Ethernet)
? ? ? ? RX packets 690 ?bytes 69262 (67.6 KiB)
? ? ? ? RX errors 0 ?dropped 0 ?overruns 0 ?frame 0
? ? ? ? TX packets 488 ?bytes 65725 (64.1 KiB)
? ? ? ? TX errors 0 ?dropped 0 overruns 0 ?carrier 0 ?collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> ?mtu 1500
? ? ? ? inet 192.168.67.4 ?netmask 255.255.255.0 ?broadcast 192.168.67.255
? ? ? ? inet6 fe80::20c:29ff:fe94:c812 ?prefixlen 64 ?scopeid 0x20<link>
? ? ? ? ether 00:0c:29:94:c8:12 ?txqueuelen 1000 ?(Ethernet)
? ? ? ? RX packets 129 ?bytes 15944 (15.5 KiB)
? ? ? ? RX errors 0 ?dropped 0 ?overruns 0 ?frame 0
? ? ? ? TX packets 26 ?bytes 3927 (3.8 KiB)
? ? ? ? TX errors 0 ?dropped 0 overruns 0 ?carrier 0 ?collisions 0
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> ?mtu 1500
? ? ? ? inet 192.168.68.4 ?netmask 255.255.255.0 ?broadcast 192.168.68.255
? ? ? ? inet6 fe80::20c:29ff:fe94:c81c ?prefixlen 64 ?scopeid 0x20<link>
? ? ? ? ether 00:0c:29:94:c8:1c ?txqueuelen 1000 ?(Ethernet)
? ? ? ? RX packets 127 ?bytes 15613 (15.2 KiB)
? ? ? ? RX errors 0 ?dropped 0 ?overruns 0 ?frame 0
? ? ? ? TX packets 25 ?bytes 3609 (3.5 KiB)
? ? ? ? TX errors 0 ?dropped 0 overruns 0 ?carrier 0 ?collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> ?mtu 65536
? ? ? ? inet 127.0.0.1 ?netmask 255.0.0.0
? ? ? ? inet6 ::1 ?prefixlen 128 ?scopeid 0x10<host>
? ? ? ? loop ?txqueuelen 0 ?(Local Loopback)
? ? ? ? RX packets 4 ?bytes 420 (420.0 B)
? ? ? ? RX errors 0 ?dropped 0 ?overruns 0 ?frame 0
? ? ? ? TX packets 4 ?bytes 420 (420.0 B)
? ? ? ? TX errors 0 ?dropped 0 overruns 0 ?carrier 0 ?collisions 0
發現哦了
轉載于:https://blog.51cto.com/baoer7758/1638277
總結
以上是生活随笔為你收集整理的CentOS多网卡重命名配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到一只大老鼠跑来跑去是什么意思
- 下一篇: 梦到谈恋爱很甜蜜预示了什么