Table of Contents

Linux Commands#network

ip - How to use ip command in Linux with examples



ip - show / manipulate routing, devices, policy routing and tunnels

Help/Manual

# ip help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |
                   tunnel | maddr | mroute | mrule | monitor | xfrm | token }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -f[amily] { inet | inet6 | ipx | dnet | link } |
                    -o[neline] | -t[imestamp] | -b[atch] [filename] |
                    -rc[vbuf] [size]}


Example

ip a = ip addr (Print Interface's Infomation)

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 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
    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 08:00:27:8a:a9:64 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.14/24 brd 192.168.0.255 scope global eth0
    inet6 2408:12:760:2800:a00:27ff:fe8a:a964/64 scope global dynamic
       valid_lft 2591921sec preferred_lft 604721sec
    inet6 fe80::a00:27ff:fe8a:a964/64 scope link
       valid_lft forever preferred_lft forever


# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:8a:a9:64 brd ff:ff:ff:ff:ff:ff


ip r = ip route (Show IP Routing)

# ip route
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.14
169.254.0.0/16 dev eth0  scope link  metric 1002
default via 192.168.0.1 dev eth0
#ip route show

# ip route add default via 192.168.10.1
# ip route add 192.168.100.10/32 via 192.168.10.1 dev eth0  <- host
# ip route add 192.168.100.0/24 via 192.168.10.1 dev eth0   <- network

# ip route del default
# ip route add default via 192.168.10.1
# ip route del 10.0.3.0/24


ip n = ip neigh (Show Arp Table)

# ip neigh
fe80::212:e2ff:fe70:d100 dev eth0 lladdr 00:12:e2:70:d1:00 router STALE
192.168.0.1 dev eth0 lladdr 10:6f:3f:63:c5:d1 STALE
192.168.0.150 dev eth0 lladdr 14:fe:b5:9c:77:f9 DELAY


# ip -f inet addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.0.14/24 brd 192.168.0.255 scope global eth0