Linux基操—8.改网卡名

 
Centos7修改了网卡的命名方式,想要保持原有的命名方式有两种办法:
 

装系统时修改

- 1.启动后,在选择安装方式界面按下 tab 键

- 2.结尾处加入 net.ifnames=0 biosdevname=0 直接回车

 

装完系统修改

1、修改网卡文件

[root@wg ~]# cd /etc/sysconfig/network-scripts/
[root@wg network-scripts]# mv ifcfg-en33  ifcfg-eth0 
[root@wg network-scripts]# vi ifcfg-eth0 
| NAME=eth0                   // name修改为eth0
| DEVICE=eth0

2、编辑grub信息

[root@wg ~]# vi /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=256M biosdevname=0 net.ifnames=0 rhgb quiet"  // 修改项
| GRUB_DISABLE_RECOVERY="true"

# 我也奇怪自己注释为什么不用 # 而是用 // ,跟前端有仇!

3、生成启动菜单

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

4、验证环节

[root@wg ~]# reboot
[root@wg ~]# ifconfig eth0   // 为什么要用ifconfig?ss或者lsof命令怎么用,aaaaaa,想不起来鸟
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.121  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::20c:29ff:fef2:b5e8  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f2:b5:e8  txqueuelen 1000  (Ethernet)
        RX packets 74  bytes 7774 (7.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 93  bytes 12017 (11.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
posted @ 2022-01-12 20:30  梵高de画笔  阅读(108)  评论(0编辑  收藏  举报