接口细节

IFCONFIG

列出机器上可用的所有接口

$ ifconfig -a

列出特定接口的详细信息

语法:$ ifconfig <interface>

例:

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:x.x.x.x  Bcast:x.x.x.x  Mask:x.x.x.x
          inet6 addr: xxxx::xxx:xxxx:xxxx:xxxx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4426618 errors:0 dropped:1124 overruns:0 frame:0
          TX packets:189171 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:382611580 (382.6 MB)  TX bytes:36923665 (36.9 MB)
          Interrupt:16 Memory:fb5e0000-fb600000 

Ethtool - 查询网络驱动程序和硬件设置

语法:$ ethtool <interface>

例:

$ ethtool eth0
Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: on (auto)
    Supports Wake-on: pumbg
    Wake-on: g
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: yes

ip - 显示/操作路由,设备,策略路由和隧道

语法:$ ip { link | ... | route | macsec }(请参阅 man ip 获取完整的对象列表)

例子

列出网络接口

$ ip link show    

将接口 eth0 重命名为 wan

$ ip link set dev eth0 name wan    

接口 eth0 向上(或向下)

$ ip link set dev eth0 up    

列出接口的地址

$ ip addr show    

添加(或 del)ip 和掩码(255.255.255.0)

$ ip addr add 1.2.3.4/24 brd + dev eth0