修改Ubuntu网卡名称

[email protected]:/sys/class/net$ ifconfig
enp0s25   Link encap:Ethernet  HWaddr f0:de:f1:16:a4:98  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:20 Memory:f2500000-f2520000

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:5843 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5843 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:502791 (502.7 KB)  TX bytes:502791 (502.7 KB)

wlp2s0    Link encap:Ethernet  HWaddr 00:26:c7:69:c2:ca  
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1002067 errors:0 dropped:0 overruns:0 frame:0
          TX packets:243468 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1485557749 (1.4 GB)  TX bytes:25632722 (25.6 MB)

xenbr0    Link encap:Ethernet  HWaddr 5a:af:ce:b3:98:ef  
          inet6 addr: fe80::58af:ceff:feb3:98ef/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:260 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:77345 (77.3 KB)

xenbr0:avahi Link encap:Ethernet  HWaddr 5a:af:ce:b3:98:ef  
          inet addr:169.254.12.112  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

查看网卡信息
[email protected]:/sys/class/net$ udevadm info -a -p /sys/class/net/wlp2s0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device ‘/devices/pci0000:00/0000:00:1c.4/0000:02:00.0/net/wlp2s0‘:
    KERNEL=="wlp2s0"
    SUBSYSTEM=="net"
    DRIVER==""
    ATTR{addr_assign_type}=="0"
    ATTR{addr_len}=="6"
    ATTR{address}=="00:26:c7:69:c2:ca"
    ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
    ATTR{carrier}=="1"
    ATTR{carrier_changes}=="2"
    ATTR{dev_id}=="0x0"
    ATTR{dev_port}=="0"
    ATTR{dormant}=="0"
    ATTR{flags}=="0x1003"
    ATTR{gro_flush_timeout}=="0"
    ATTR{ifalias}==""
    ATTR{ifindex}=="3"
    ATTR{iflink}=="3"
    ATTR{link_mode}=="1"
    ATTR{mtu}=="1500"
    ATTR{name_assign_type}=="4"
    ATTR{netdev_group}=="0"
    ATTR{operstate}=="up"
    ATTR{tx_queue_len}=="1000"
    ATTR{type}=="1"

looking at parent device ‘/devices/pci0000:00/0000:00:1c.4/0000:02:00.0‘:
    KERNELS=="0000:02:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="iwlwifi"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x028000"
    ATTRS{consistent_dma_mask_bits}=="36"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x0084"
    ATTRS{dma_mask_bits}=="36"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="61"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="f"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x1315"
    ATTRS{subsystem_vendor}=="0x8086"
    ATTRS{vendor}=="0x8086"

looking at parent device ‘/devices/pci0000:00/0000:00:1c.4‘:
    KERNELS=="0000:00:1c.4"
    SUBSYSTEMS=="pci"
    DRIVERS=="pcieport"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{d3cold_allowed}=="0"
    ATTRS{device}=="0x3b4a"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"[email protected]:/sys/class/net$ udevadm info -a -p /sys/class/net/wlp2s0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device ‘/devices/pci0000:00/0000:00:1c.4/0000:02:00.0/net/wlp2s0‘:
    KERNEL=="wlp2s0"
    SUBSYSTEM=="net"
    DRIVER==""
    ATTR{addr_assign_type}=="0"
    ATTR{addr_len}=="6"
    ATTR{address}=="00:26:c7:69:c2:ca"
    ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
    ATTR{carrier}=="1"
    ATTR{carrier_changes}=="2"
    ATTR{dev_id}=="0x0"
    ATTR{dev_port}=="0"
    ATTR{dormant}=="0"
    ATTR{flags}=="0x1003"
    ATTR{gro_flush_timeout}=="0"
    ATTR{ifalias}==""
    ATTR{ifindex}=="3"
    ATTR{iflink}=="3"
    ATTR{link_mode}=="1"
    ATTR{mtu}=="1500"
    ATTR{name_assign_type}=="4"
    ATTR{netdev_group}=="0"
    ATTR{operstate}=="up"
    ATTR{tx_queue_len}=="1000"
    ATTR{type}=="1"

looking at parent device ‘/devices/pci0000:00/0000:00:1c.4/0000:02:00.0‘:
    KERNELS=="0000:02:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="iwlwifi"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x028000"
    ATTRS{consistent_dma_mask_bits}=="36"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x0084"
    ATTRS{dma_mask_bits}=="36"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="61"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="f"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x1315"
    ATTRS{subsystem_vendor}=="0x8086"
    ATTRS{vendor}=="0x8086"

looking at parent device ‘/devices/pci0000:00/0000:00:1c.4‘:
    KERNELS=="0000:00:1c.4"
    SUBSYSTEMS=="pci"
    DRIVERS=="pcieport"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{d3cold_allowed}=="0"
    ATTRS{device}=="0x3b4a"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="20"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="f"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x2164"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{vendor}=="0x8086"

looking at parent device ‘/devices/pci0000:00‘:
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

ATTRS{enable}=="1"
    ATTRS{irq}=="20"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="f"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x2164"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{vendor}=="0x8086"

looking at parent device ‘/devices/pci0000:00‘:
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

[email protected]:/etc/udev/rules.d$ touch 70-persistent-net.rules
touch: cannot touch ‘70-persistent-net.rules’: Permission denied
[email protected]:/etc/udev/rules.d$ sudo touch 70-persistent-net.rules
[sudo] password for robin:
[email protected]:/etc/udev/rules.d$ ls
70-persistent-net.rules

[email protected]:/etc/udev/rules.d$ cat 70-persistent-net.rules
# PCI device wifi
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:26:c7:69:c2:ca", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="wlan"
[email protected]:/etc/udev/rules.d$

[email protected]:~$ ifconfig
enp0s25   Link encap:Ethernet  HWaddr f0:de:f1:16:a4:98  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:20 Memory:f2500000-f2520000

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1210 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1210 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:107082 (107.0 KB)  TX bytes:107082 (107.0 KB)

wlan      Link encap:Ethernet  HWaddr 00:26:c7:69:c2:ca  
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::226:c7ff:fe69:c2ca/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6057 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4383 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5887721 (5.8 MB)  TX bytes:803304 (803.3 KB)

时间: 2024-10-01 04:37:43

修改Ubuntu网卡名称的相关文章

centos7.2 下修改默认网卡名称

Centos7下修改了默认的网卡名称,有点不习惯.所以想把那个名称改回 eth0 要修改grub和bios的 命名规则 编辑进入 :  vi   /etc/sysconfig/grub     在倒数第二行  添加  net.ifnames=0 biosdevname=0 # grub2-mkconfig -o /boot/grub2/grub.cfg 用mv  修改网卡名称.需要注意的 是:修改后的eth0  的配置文件里面DEVICE=eth0. 重启服务器.生效.

修改CentOS7网卡名称为传统名称eth0格式

为什么要修改网卡名称?很多使用CentOS7以前系统的小伙伴装完CentOS7以后发现了一个问题,那就是网卡名改变为了“en016777736”,而不是以前的eth0的简易模式了,如图: 这是为什么呢?开发者吃饱撑的么?当然不是.   以往的CentOS7以前的系统网卡命名虽然简单方便,但也会带来一些问题,例如,当eth0接口对应的网卡出问题以后,更换掉新网卡后新网卡的名字就可能不是eth0了.而CentOS7使用了新的网卡命名模式接口名称被自动基于固件,拓扑结构和位置信息来确定.即使添加或移除

ubuntu网卡名称变化的解决方法

在chinacache工作时,遇到了东方网力的客户,需要安装使用ubuntu系统,每个服务器有4个网口,在做bond时,发现部分网卡漂移,为了解决这个,搜索了大量的文档,汇总一下. 1 编辑grub文件如下: #cat /etc/default/grub GRUB_CMDLINE_LINUX="biosdevname=0" 或者 GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0" 2 从新生成grub文件

Linux 7修改网卡名称后配置文件中的默认网关不生效

背景 ? 为了系统统一管理在创建了系统后统一将网卡名称修改为eth0,eth1等格式,并在修改完网卡名称重新编译grub配置文件重启后,添加了静态路由,使用route -n查看系统发现路由可以生效,但是配置的默认网关不生效,记录下排查过程. 检查网卡配置文件并手动配置默认网关 ? 在检查了网卡配置文件确认无误后,使用route add default gw 192.168.1.1命令发现可以成功配置,经过此操作确认了此问题应该和修改网卡名称的操作有关 检查network配置文件 ? /etc/s

shell脚本:不登陆KVM虚拟机,修改虚拟机网卡IP地址

# Author:丁丁历险(Jacob) # 该脚本使用 guestmount 工具,Centos7.2 中安装 libguestfs-tools-c 可以获得 guestmount 工具 # 脚本在不登陆虚拟机的情况下,修改虚拟机的 IP 地址信息 # 在某些环境下,虚拟机没有 IP 或 IP 地址与真实主机不在一个网段 # 真实主机在没有 virt-mange 图形的情况下,远程连接虚拟机很麻烦 # 该脚本可以解决类似的问题 #!/bin/bash #Author:丁丁历险(Jacob) #

RedHat7/Centos7修改默认网卡名为eth0

可能因为个人习惯问题,我还是比较喜欢linux 6.x版本中的网卡名的显示格式(eth0),不是很喜欢linux 7.x版本中的显示格式(eno16777736),下面就教大家怎么修改默认网卡名称. 方法一: 可在装系统时就修改,在选择菜单界面,按下tab键,输入"net.ifnames=0  biosdevname=0  ",回车即可! 方法二: 可以通过修改配置文件来修改默认网卡名称 一.修改配置文件 [[email protected] ~]# vim /etc/sysconfi

ubuntu修改网卡名称,找不到eth0,无法ssh链接问题记录

一.修改网卡名称: 如出现网卡名称不是eth0,可以将/etc/default/grub文件编辑,然后添加一下内容: vi /etc/default/grub 然后通过update-grub命令使之生效 update-grub 还要编辑 /etc/network/interfaces 添加图示中的两行 然后重启ubuntu系统,ip a 命令查看网卡名称. 二.ip a 查看网卡名称变成了eth1.   转载别人的------(用此方法问题解决了) 很多Linux distribution使用u

Linux 中修改网卡名称【ubuntu + Centos7】

有时候安装好Linux系统之后,网卡的名称不是ethX, 这时候可以通过以下方式修改网卡的名称为ethX(以eth0为例). ubuntu 14.04 1. 查看是否存在/etc/udev/rules.d/70-persistent-net.rules 文件,如不存在,可以通过以下方式生成(或者从其它机器上拷贝一个) # ifconfig em1 Link encap:以太网 硬件地址 18:66:da:7e:64:10 inet 地址:192.168.2.38 广播:192.168.2.255

Linux修改网卡名称enss33到eth0--Ubuntu16和centos7

新装的Ubuntu16.04和centos7的默认网卡名称都是ens33.想要修改为eth0. 一.centos: 修改/etc/sysconfig/grub文件(修改前先备份) 为GRUB_CMDLINE_LINUX变量增加2个参数(net.ifnames=0 biosdevname=0),修改完成如下:GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 b