您的位置:首页 > 其它

RHEL7修改网卡名称

2017-09-22 16:47 453 查看

RHEL7修改网卡名称

注:我的是四块网卡。

1. 安装好系统后的网卡名称

[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
inet6 fe80::a00:27ff:fe67:bf01  prefixlen 64  scopeid 0x20<link>
ether 08:00:27:67:bf:01  txqueuelen 1000  (Ethernet)
RX packets 909  bytes 62348 (60.8 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 62  bytes 9696 (9.4 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
ether 08:00:27:12:6f:d1  txqueuelen 1000  (Ethernet)
RX packets 842  bytes 52028 (50.8 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 0  bytes 0 (0.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
ether 08:00:27:6c:54:e2  txqueuelen 1000  (Ethernet)
RX packets 842  bytes 52028 (50.8 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 0  bytes 0 (0.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
ether 08:00:27:00:27:31  txqueuelen 1000  (Ethernet)
RX packets 841  bytes 51968 (50.7 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 0  bytes 0 (0.0 B)
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 8  bytes 676 (676.0 B)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 8  bytes 676 (676.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


2. 修改网卡配置文件中的内容

修改配置文件中的NAME和DEVICE

原配置:

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls | grep "ifcfg*"
ifcfg-enp0s10
ifcfg-enp0s3
ifcfg-enp0s8
ifcfg-enp0s9
ifcfg-lo
[root@localhost network-scripts]# cat ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1


修改后:

[root@localhost network-scripts]# cat ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1


3. 修给网卡配置文件的名称

将ifcfg-enp0s3修改为ifcfg-eth0

[root@localhost network-scripts]# ls | grep "ifcfg*"
ifcfg-eth0
ifcfg-eth1
ifcfg-eth2
ifcfg-eth3
ifcfg-lo


4. 修改grub配置文件

原配置:

[root@localhost network-scripts]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"


修改后:

[root@localhost network-scripts]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"


5. 重新生成grub配置文件

[root@localhost network-scripts]# 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-9e413466ccc049119140331b9927a8fb
Found initrd image: /boot/initramfs-0-rescue-9e413466ccc049119140331b9927a8fb.img
done


6. 添加udev规则

在/etc/udev/rules.d/70-persistent-ipoib.rules文件最后添加

SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="MAC地址",ATTR{type}=="1",KERNEL=="eth*",NAME="eth0"


7. 重启系统

[root@localhost ~]# reboot


8. 修改完成

[root@localhost ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
inet6 fe80::a00:27ff:fe67:bf01  prefixlen 64  scopeid 0x20<link>
ether 08:00:27:67:bf:01  txqueuelen 1000  (Ethernet)
RX packets 1979  bytes 127754 (124.7 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 48  bytes 6045 (5.9 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet6 fe80::a00:27ff:fe12:6fd1  prefixlen 64  scopeid 0x20<link>
ether 08:00:27:12:6f:d1  txqueuelen 1000  (Ethernet)
RX packets 1910  bytes 119785 (116.9 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 18  bytes 1416 (1.3 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet6 fe80::a00:27ff:fe6c:54e2  prefixlen 64  scopeid 0x20<link>
ether 08:00:27:6c:54:e2  txqueuelen 1000  (Ethernet)
RX packets 1925  bytes 120653 (117.8 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 18  bytes 1416 (1.3 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet6 fe80::a00:27ff:fe00:2731  prefixlen 64  scopeid 0x20<link>
ether 08:00:27:00:27:31  txqueuelen 1000  (Ethernet)
RX packets 2016  bytes 126113 (123.1 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 18  bytes 1416 (1.3 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 48  bytes 4076 (3.9 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 48  bytes 4076 (3.9 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: