ip

ip 用来显示/管理路由、设备、地址、等。

Table of Contents

ip addr

显示所有设备和地址信息
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:e0:d0:06 brd ff:ff:ff:ff:ff:ff
    inet 10.66.193.160/23 brd 10.66.193.255 scope global dynamic eth0
       valid_lft 2972sec preferred_lft 2972sec
    inet6 2620:52:0:42c0:5054:ff:fee0:d006/64 scope global noprefixroute dynamic
       valid_lft 2591956sec preferred_lft 604756sec
    inet6 fe80::5054:ff:fee0:d006/64 scope link
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:31:cf:eb brd ff:ff:ff:ff:ff:ff
    inet 192.168.124.1/24 brd 192.168.124.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:31:cf:eb brd ff:ff:ff:ff:ff:ff
显示一个设备和地址信息
# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:e0:d0:06 brd ff:ff:ff:ff:ff:ff
    inet 10.66.193.160/23 brd 10.66.193.255 scope global dynamic eth0
       valid_lft 2669sec preferred_lft 2669sec
    inet6 2620:52:0:42c0:5054:ff:fee0:d006/64 scope global noprefixroute dynamic
       valid_lft 2591985sec preferred_lft 604785sec
    inet6 fe80::5054:ff:fee0:d006/64 scope link
       valid_lft forever preferred_lft forever
显示所有设备网络接收和统计数据
# ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    10780      120      0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    10780      120      0       0       0       0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:e0:d0:06 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    2024607    16218    0       5       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    294805     857      0       0       0       0
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT qlen 1000
    link/ether 52:54:00:31:cf:eb brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    0          0        0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT qlen 1000
    link/ether 52:54:00:31:cf:eb brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    0          0        0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0
显示一个设备统计数据
# ip -s link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:e0:d0:06 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    2083377    16735    0       5       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    297915     870      0       0       0       0

ip route

显示路由信息
# ip route
default via 10.66.193.254 dev eth0  proto static  metric 100
10.66.192.0/23 dev eth0  proto kernel  scope link  src 10.66.193.160  metric 100
10.72.17.5 via 10.66.193.254 dev eth0  proto dhcp  metric 100
192.168.124.0/24 dev virbr0  proto kernel  scope link  src 192.168.124.1
ping 用来检测网络的连通性
# ping -c2 10.66.193.254
PING 10.66.193.254 (10.66.193.254) 56(84) bytes of data.
64 bytes from 10.66.193.254: icmp_seq=1 ttl=255 time=2.05 ms
64 bytes from 10.66.193.254: icmp_seq=2 ttl=255 time=6.90 ms

--- 10.66.193.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.059/4.482/6.906/2.424 ms
tracepath 用来跟踪远程地址
# tracepath 10.66.193.254
 1?: [LOCALHOST]                                         pmtu 1500
 1:  10.66.193.253                                         2.605ms reached
 1:  10.66.193.253                                         2.263ms reached
     Resume: pmtu 1500 hops 1 back 1
traceroute 用来跟踪远程地址
# traceroute -T 10.66.193.254
traceroute to 10.66.193.254 (10.66.193.254), 30 hops max, 60 byte packets
 1  gateway (10.66.193.254)  3.080 ms  3.925 ms  5.163 ms
Note
tracepath/traceroute 默认发送 UDP 包给远程地址。traceroute 可以指定发送包的类型,ICMP (-I),TCP(-T)。

results matching ""

    No results matching ""