robin@robin-ThinkPad-X201:/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
查看网卡信息
robin@robin-ThinkPad-X201:/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)"robin@robin-ThinkPad-X201:/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==""
robin@robin-ThinkPad-X201:/etc/udev/rules.d$ touch 70-persistent-net.rules
touch: cannot touch ‘70-persistent-net.rules’: Permission denied
robin@robin-ThinkPad-X201:/etc/udev/rules.d$ sudo touch 70-persistent-net.rules
[sudo] password for robin:
robin@robin-ThinkPad-X201:/etc/udev/rules.d$ ls
70-persistent-net.rules
robin@robin-ThinkPad-X201:/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"
robin@robin-ThinkPad-X201:/etc/udev/rules.d$
robin@robin-ThinkPad-X201:~$ 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)