linux网络命令

查看所有网卡总线号

root@tidb3:~# ll /sys/class/net/
total 0
drwxr-xr-x  2 root root 0 May 27 11:38 ./
drwxr-xr-x 73 root root 0 May 27 11:38 ../
lrwxrwxrwx  1 root root 0 May 27 11:38 enp10s0f0 -> ../../devices/pci0000:00/0000:00:04.1/0000:0a:00.0/net/enp10s0f0/
lrwxrwxrwx  1 root root 0 May 27 11:38 enp10s0f1 -> ../../devices/pci0000:00/0000:00:04.1/0000:0a:00.1/net/enp10s0f1/
lrwxrwxrwx  1 root root 0 May 27 11:38 enp193s0f0 -> ../../devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/net/enp193s0f0/
lrwxrwxrwx  1 root root 0 May 27 11:38 enp193s0f1 -> ../../devices/pci0000:c0/0000:c0:01.1/0000:c1:00.1/net/enp193s0f1/
lrwxrwxrwx  1 root root 0 May 27 11:38 lo -> ../../devices/virtual/net/lo/

如何查看网口类型

// 使用ethtool enp14s0f0,通过下面输出可以看到speed那一行,表示万兆网还是千兆网
root@ceph2:~# ifconfig 
enp14s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.3.7.35  netmask 255.255.0.0  broadcast 10.3.255.255
        ether b8:ce:f6:0b:fe:d0  txqueuelen 1000  (Ethernet)
        RX packets 77323525  bytes 108203715386 (108.2 GB)
        RX errors 0  dropped 6499  overruns 0  frame 0
        TX packets 75530400  bytes 100311118002 (100.3 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp14s0f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:ce:f6:0b:fe:d1  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp15s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.3.6.35  netmask 255.255.0.0  broadcast 10.3.255.255
        ether 00:e0:4a:68:1c:1f  txqueuelen 1000  (Ethernet)
        RX packets 5772357  bytes 8245209397 (8.2 GB)
        RX errors 0  dropped 1190  overruns 0  frame 0
        TX packets 3017758  bytes 3723847625 (3.7 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfaf00000-faffffff  

enp16s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:e0:4a:68:1c:20  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfac00000-facfffff  

enp17s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:e0:4a:68:1c:21  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfa900000-fa9fffff  

enp18s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:e0:4a:68:1c:22  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfa600000-fa6fffff  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 157730  bytes 69140496 (69.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 157730  bytes 69140496 (69.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@ceph2:~# ethtool enp14s0f0
Settings for enp14s0f0:
    Supported ports: [ FIBRE ]
    Supported link modes:   1000baseKX/Full 
                            10000baseKR/Full 
    Supported pause frame use: Symmetric
    Supports auto-negotiation: Yes
    Supported FEC modes: None BaseR
    Advertised link modes:  1000baseKX/Full 
                            10000baseKR/Full 
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Advertised FEC modes: None
    Speed: 10000Mb/s
    Duplex: Full
    Port: FIBRE
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    Supports Wake-on: d
    Wake-on: d
    Current message level: 0x00000004 (4)
                   link
    Link detected: yes
root@ceph2:~# ethtool enp15s0
Settings for enp15s0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: Symmetric
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: off (auto)
    Supports Wake-on: pumbg
    Wake-on: g
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: yes
root@ceph2:~# 

如何查看哪些网口插了网线

// 网口中UP代表插了网线
root@tidb3:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp10s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether a0:42:3f:47:d9:39 brd ff:ff:ff:ff:ff:ff
3: enp10s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether a0:42:3f:47:d9:3a brd ff:ff:ff:ff:ff:ff
4: enp193s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether a0:42:3f:48:f0:96 brd ff:ff:ff:ff:ff:ff
    inet 10.3.64.3/16 brd 10.3.255.255 scope global enp193s0f0
       valid_lft forever preferred_lft forever
    inet6 fe80::a242:3fff:fe48:f096/64 scope link 
       valid_lft forever preferred_lft forever
5: enp193s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether a0:42:3f:48:f0:97 brd ff:ff:ff:ff:ff:ff
    inet 10.4.64.3/16 brd 10.4.255.255 scope global enp193s0f1
       valid_lft forever preferred_lft forever
    inet6 fe80::a242:3fff:fe48:f097/64 scope link 
       valid_lft forever preferred_lft forever

   转载规则


《linux网络命令》 bill 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
gomod使用 gomod使用
在go mod 的require里面引入项目的last commit id由于不知道哪个版本号,那么在require里面使用最近一次提交的commit id: 510aa62 go 1.3.3 require ( git.xx.cn
2020-03-11
下一篇 
ubuntu18.04磁盘格式化被占用 ubuntu18.04磁盘格式化被占用
问题说明新装的Linux系统,两块硬盘,一块作为系统磁盘,另一块作为数据磁盘,安装完系统后,由于该数据磁盘中包含之前残余的LVM信息,无法对数据磁盘无法进行操作。 新系统启动后,通过fdisk -l查看磁盘信息如下 Disk /dev/sd
2020-03-11
  目录