centos7修改网卡名称为eth0-技术流ken

 

前言

在配置集群的时候,需要保持网卡名称一致,所以我们需要修改centos7中的网卡名称为eth0.

 

检查网卡

检查网卡,现在网卡名称是ens33

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:e9:0d:a7 brd ff:ff:ff:ff:ff:ff
    inet 10.220.5.9/24 brd 10.220.5.255 scope global noprefixroute dynamic ens33
       valid_lft 518249sec preferred_lft 518249sec
    inet6 fe80::20c:29ff:fee9:da7/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

 

修改网卡名称

修改启动过程中加载的内核参数

添加 net.ifnames=0 biosdevname=0

[root@localhost ~]# vim /etc/sysconfig/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 rhgb net.ifnames=0 biosdevname=0 quiet"
GRUB_DISABLE_RECOVERY="true"

重新生成grub

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-862.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-04a5422144ea49f38d885773499b59b9
Found initrd image: /boot/initramfs-0-rescue-04a5422144ea49f38d885773499b59b9.img
done

   

创建网卡配置文件

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-ens33 ifcfg-eth0
[root@localhost network-scripts]# vim ifcfg-eth0 
DEVICE="eth0"
ONBOOT=yes
NETBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet

   

重启

[root@localhost network-scripts]# reboot

 

检查网卡名称

检查发现网卡名称已经变成了eth0

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:e9:0d:a7 brd ff:ff:ff:ff:ff:ff
    inet 10.220.5.9/24 brd 10.220.5.255 scope global noprefixroute dynamic eth0
       valid_lft 518376sec preferred_lft 518376sec
    inet6 fe80::20c:29ff:fee9:da7/64 scope link 
       valid_lft forever preferred_lft forever

 

转载于:https://www.cnblogs.com/kenken2018/p/9715690.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值