1. 程式人生 > >常用網路定位命令

常用網路定位命令

 

檢視所有IP地址

ip a/addr/address

ip a/addr/address sh/show

檢視指定IP地址

ip a/addr/address sh/show dev eth1

ip a/addr/address sh/show eth1

[[email protected] ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    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 fa:16:3e:df:dd:cb brd ff:ff:ff:ff:ff:ff
    inet 10.62.38.149/24 brd 10.62.38.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fedf:ddcb/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether fa:16:3e:b9:8e:fe brd ff:ff:ff:ff:ff:ff
    inet 100.79.0.112/24 brd 100.79.0.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:feb9:8efe/64 scope link
       valid_lft forever preferred_lft forever

檢視指定IP的路由

[[email protected]~]# ip route get 100.66.18.253
100.66.18.253 via 100.79.0.1 dev eth1  src 100.79.0.112
    cache

檢視路由

[[email protected]~]# ip route
default via 10.62.38.1 dev eth0
10.62.38.0/24 dev eth0  proto kernel  scope link  src 10.62.38.149
100.66.0.0/16 via 100.79.0.1 dev eth1
100.79.0.0/24 dev eth1  proto kernel  scope link  src 100.79.0.112
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003