CentOS 7 修改网卡名称

简介:

方法一:禁用该可预测命名规则

1、对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现的。

1
2
3
4
5
6
7
8
cat  /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= "ipv6.disable=1 crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY= "true"

2、运行命令grub2-mkconfig -o /boot/grub2/grub.cfg 来重新生成GRUB配置并更新内核参数。

3、reboot


方法二:修改rules文件

1、文件没有的话可以手动创建,后缀是.rules,按照顺序将MAC地址与网卡名称绑定

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat  /etc/udev/rules .d /70-persistent-ipoib .rules 
# This is a sample udev rules file that demonstrates how to get udev to
# set the name of IPoIB interfaces to whatever you wish.  There is a
# 16 character limit on network device names though, so don't go too nuts
#
# Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the
# ATTR{address} match must start with ?* and only reference the last 8
# bytes of the address or else the address might not match on any given
# start of the IPoIB stack
#
# Note: as of rhel7, udev is case sensitive on the address field match
# and all addresses need to be in lower case.
#
# ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3"
ACTION== "add" , SUBSYSTEM== "net" , DRIVERS== "?*" , ATTR{ type }== "32" , ATTR{address}== "?*00:0c:29:7a:1e:16" , NAME= "eth0"

2、修改网卡配置文件,配置DEVICE和NAME,并加入HWADDR

注:DEVICE、NAME和HWADDR 要和.rules 里面相对应

1
2
3
4
5
6
7
8
9
10
11
12
13
cat  /etc/sysconfig/network-scripts/ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE= yes
NAME=eth0
#UUID=408326bb-7565-4aa5-b156-c89a0ba839d2
HWADDR=00:0c:29:7a:1e:16
DEVICE=eth0
ONBOOT= yes
IPADDR=172.16.18.188
NETMASK=255.255.255.0
GATEWAY=172.16.18.1
DNS=219.141.136.10

3、reboot



本文转自 baby神 51CTO博客,原文链接:http://blog.51cto.com/babyshen/2044094,如需转载请自行联系原作者

相关文章
|
6月前
|
数据可视化 Linux
Linux centos7.x系统 下没有ens33 网卡的解决方案
此时还没有enp0s31f6网卡相关的配置信息 , 所以我们需要配置enp0s31f6网卡相关的信息
369 0
|
负载均衡 Linux
配置Centos7网卡聚合链路
配置Centos7网卡聚合链路
556 0
配置Centos7网卡聚合链路
|
17天前
|
Linux 虚拟化
VMware workstation 中centos7虚拟机在nat模式下怎么配置网卡,指定我想要的IP并且可以联网
https://blog.csdn.net/2302_78534730/article/details/132825156?spm=1001.2014.3001.5502
131 0
|
16天前
|
网络协议
centos8 网卡 Nmcli(是network的简写 Nmcli)配置网络
centos8 网卡 Nmcli(是network的简写 Nmcli)配置网络
15 0
|
8月前
|
存储 Linux Shell
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)(下)
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)
370 0
|
8月前
|
分布式计算 Hadoop Linux
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)(上)
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)
279 0
|
Linux
Centos删除virbr0网卡
Centos删除virbr0网卡
128 0
centos 配置静态地址并修改网卡名
centos 配置静态地址并修改网卡名
|
关系型数据库 MySQL Linux
Centos 8系统Mysql 8修改root密码
Centos 8系统Mysql 8修改root密码
|
Linux 开发工具
如何在 centos 7 中修改内核启动顺序
CentOS 7是CentOS项目发布的开源类服务器操作系统,于2014年7月7日正式发布。对于Centos 7 grub 配置有改变,如何修改?
如何在 centos 7 中修改内核启动顺序

热门文章

最新文章