ubuntu 网卡名称重命名

ubuntu 网卡名称重命名

 

参考:https://blog.csdn.net/hzj_001/article/details/81587824

biosdevname 和 net.ifnames 两种命名规范
---------------------------------------
net.ifnames 的命名规范为:   设备类型+设备位置+数字

设备类型:
en 表示Ethernet
wl 表示WLAN
ww 表示无线广域网WWAN

实际的例子:
eno1 板载网卡
enp0s2  pci网卡
ens33   pci网卡
wlp3s0  PCI无线网卡
wwp0s29f7u2i2   4G modem
wlp0s2f1u4u1   连接在USB Hub上的无线网卡
enx78e7d1ea46da pci网卡

---------------------------------------

biosdevname 的命名规范为:

实际的例子:
em1 板载网卡
p3p4 pci网卡
p3p4_1 虚拟网卡

---------------------------------------

 

修改 grub 引导参数

# 查看 GRUB_CMDLINE_LINUX 变量
$ cat /etc/default/grub | grep GRUB_CMDLINE_LINUX

# 修改 GRUB_CMDLINE_LINUX 变量
$ sudo sed -i 's/^.*GRUB_CMDLINE_LINUX="".*$/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"/g' /etc/default/grub

# 更新grub引导
$ sudo update-grub

# 重启系统
$ sudo reboot

 

参考:https://kb.vmware.com/s/article/1032790

 

# 查看所有网卡列表
$ ifconfig -s
$ ifconfig -a # 查看网络设备类型的设备配置规则 $ cat /etc/udev/rules.d/70-persistent-net.rules | grep net # 执行 write_net_rules 脚本,此脚本会更新 /etc/udev/rules.d/70-persistent-net.rules 文件 # "ethN" 指网卡设备名称,例如:"eth0" # "xx:xx:xx:xx:xx:xx" 指网卡设备的MAC地址,例如:"00:10:f3:5a:96:36" $ sudo rm /etc/udev/rules.d/70-persistent-net.rules $ sudo env INTERFACE="ethN" MATCHADDR="xx:xx:xx:xx:xx:xx" /lib/udev/write_net_rules # 查看网卡名称设备对应的MAC地址 $ ifconfig -a eth0 | grep HWaddr # 查看网卡名称设备的带宽速率 $ ethtool eth0 | grep "link mode" # 查看网卡名称设备对应的PCIID $ ethtool -i eth0 | grep bus # 查看网卡名称设备对应的驱动 $ ethtool -i eth0 | grep driver # 查看网卡设备的PCIID $ lspci | grep -i eth # 查看PCIID的设备信息 $ lspci -D -n -vvv -s 01:00.0 # 查看指定设备ID的设备信息 $ lspci -D -n -vvv -d 8086:10fb # 查看系统指定设备信息 $ udevadm info -a -p /sys/class/net/eth0
# 重新加载设备规则配置文件
$ sudo chmod a+x /etc/udev/rules.d/70-persistent-net.rules
$ sudo udevadm control --reload-rules 或 sudo service udev restart

# 重启网络管理服务
# sudo service networking restart
# 编辑网卡配置文件 $ sudo vi /etc/network/interfaces

# 查看系统路由项
$ sudo netstat -nr

 

$ sudo vi /etc/network/interfaces
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface # auto setting #auto eth0 #iface eth0 inet dhcp #auto eth1 #iface eth1 inet dhcp # manual setting auto eth0 iface eth0 inet static address 172.16.204.31 netmask 255.255.255.0 broadcast 172.16.204.255 network 172.16.204.0 #auto eth1 #iface eth1 inet static #address 192.168.1.31 #netmask 255.255.255.0 #broadcast 192.168.1.255 #network 192.168.1.0 up route add default gw 172.16.204.1 dev eth0
#up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth1 # This is an autoconfigured IPv6 interface # auto setting iface eth0 inet6 auto #iface eth1 inet6 auto # manual setting

 

$ sudo vi /etc/resolvconf/resolv.conf.d/base 
nameserver 114.114.114.114
nameserver 8.8.8.8
#nameserver 4.2.2.1
#nameserver 4.2.2.2
search localdomain

 

$ sudo cat /etc/hostname
localhost.localdomain

 

$ sudo vi /etc/hosts
127.0.0.1	localhost localhost.localdomain

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

# 网络设备信息

-------------------------------------------------------------------------------------- name type MATCHADDR Bandwidth PCIID driver device -------------------------------------------------------------------------------------- eth0 Ethernet 00:13:32:0e:2a:60 1000baseT/Full 0000:05:00.0 e1000e 8086:10d3 eth1 Ethernet 00:13:32:0e:2a:61 1000baseT/Full 0000:06:00.0 e1000e 8086:10d3 eth2 Ethernet 00:13:32:0e:2a:62 1000baseT/Full 0000:07:00.0 e1000e 8086:10d3 eth3 Ethernet 00:13:32:0e:2a:63 1000baseT/Full 0000:08:00.0 e1000e 8086:10d3 -------------------------------------------------------------------------------------- eth4 Ethernet 00:10:f3:5a:96:36 10000baseT/Full 0000:01:00.0 ixgbe 8086:10fb eth5 Ethernet 00:10:f3:5a:96:37 10000baseT/Full 0000:01:00.1 ixgbe 8086:10fb -------------------------------------------------------------------------------------- # 将设备MAC地址与ethN接口名称相关联 $ sudo vi cat 70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x8086:10d3 (e1000e) --- 05:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:60", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x8086:10d3 (e1000e) --- 06:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:61", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" # PCI device 0x8086:10d3 (e1000e) --- 07:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:62", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" # PCI device 0x8086:10d3 (e1000e) --- 08:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:32:0e:2a:63", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:f3:5a:96:36", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.1 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:f3:5a:96:37", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5" # 将设备PCI总线地址与ethN接口名称相关联 $ sudo vi cat 70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x8086:10d3 (e1000e) --- 05:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:05:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x8086:10d3 (e1000e) --- 06:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:06:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" # PCI device 0x8086:10d3 (e1000e) --- 07:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:07:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" # PCI device 0x8086:10d3 (e1000e) --- 08:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:08:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.0 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:01:00.0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4" # PCI device 0x8086:0x10fb (ixgbe) --- 01:00.1 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", %B=="0000:01:00.1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5" # 重新加载设备规则配置文件 $ sudo chmod a+x /etc/udev/rules.d/70-persistent-net.rules $ sudo udevadm control --reload-rules 或 sudo service udev restart


 

# 查看网桥连接
$ sudo modprobe br_netfilter
$ show brctl show

# 开启 IP 转发: $ sudo vi /etc/sysctl.conf --> net.ipv4.ip_forward=1 (永久开启) # 禁用网络过滤器 # 向文件/etc/sysctl.conf添加以下代码: net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 # 重新加载kernel参数 $ sudo sysctl -p


 

================ End

 

转载于:https://www.cnblogs.com/lsgxeva/p/10944806.html

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值