[root@master network-scripts]# ifconfig
ens33: flags=4163
inet 192.168.64.128 netmask 255.255.255.0 broadcast 192.168.64.255
inet6 fe80::6420:ed94:b17d:424f prefixlen 64 scopeid 0x20
ether 00:0c:29:d3:a7:23 txqueuelen 1000 (Ethernet)
RX packets 620 bytes 59676 (58.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 443 bytes 60929 (59.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 68 bytes 5780 (5.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5780 (5.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:4e:45:22 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
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
[root@master network-scripts]# mv ifcfg-ens33 ifcfg-eno (重命名你想改的网卡名称)
[root@master network-scripts]#ip addr (查看MAC地址)
[root@master network-scripts]# vi ifcfg-eno (修改配置文件里面name和device)
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno
UUID=9356eadc-9efe-423d-967e-ff01f5971571
HWADDR=00:0c:29:d3:a7:23 ####注意加上HWADDR,指定对应地址
DEVICE=eno
ONBOOT=yes
redhat7开始就得用使用下面命令,redhat 6可以忽略
[root@master network-scripts]# vi /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=rootvg/root rd.lvm.lv=rootvg/swap rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
如果你想要控制其设备名,而不是让内核以它自己的方式命名,创建,/etc/udev/rules.d/XXX-net.rules规则是必要的!
[root@master network-scripts]# vi /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d3:a7:23", ATTR{type}=="1", KERNEL=="eno*", NAME="eno"
[root@master network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg (重新生成GRUB配置并更新内核参数)
重启系统验证
[root@master ~]# ifconfig