CentOS多网卡重命名配置
时间:2015-04-28 16:26 来源:blog.51cto.com 作者:Isuncle的技术博客
在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 image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-9bede79b46bd4e9696b92a4ec68a97b1
Found initrd image: /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
(责任编辑:IT)
在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 image: /boot/vmlinuz-3.10.0-229.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-9bede79b46bd4e9696b92a4ec68a97b1 Found initrd image: /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 (责任编辑:IT) |