合 CentOS7修改网卡名称并配置静态IP地址
需求:原来的网卡名为eno16666628,需要修改为eth0。需要完整执行如下几个步骤,否则可能导致重启连接不上服务器:
1、修改/etc/default/grub文件
编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0”到GRUB_CMDLINE_LINUX变量:
1 | sed -i 's/rhgb/net.ifnames=0 biosdevname=0 rhgb/' /etc/default/grub |
再执行如下命令,使系统重新加载grub文件:
1 | grub2-mkconfig -o /boot/grub2/grub.cfg |
2、修改/etc/udev/rules.d/70-persistent-net.rules文件
查看接口的MAC地址:
1 2 3 4 5 | [root@docker35 ~]# ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eno16666628: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0c:29:30:be:cd brd ff:ff:ff:ff:ff:ff |
不错哟