Easy Tutorial
❮ Linux Comm Uudecode Linux Comm Minfo ❯

Linux ip Command

Linux Command Manual

The Linux ip command is similar to the ifconfig command but is more powerful, primarily used for displaying or configuring network devices.

The ip command is an enhanced network configuration tool in Linux, replacing the ifconfig command.

Syntax

ip [ OPTIONS ] OBJECT { COMMAND | help }

OBJECT is a common object, which can be one of the following:

OBJECT={ link | addr | addrlabel | route | rule | neigh | ntable | tunnel | maddr | mroute | mrule | monitor | xfrm | token }

The meanings of common object values are as follows:

OPTIONS are common options, which can be one of the following:

OPTIONS={ -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] | -h[uman-readable] | -iec | -f[amily] { inet | inet6 | ipx | dnet | link } | -o[neline] | -t[imestamp] | -b[atch] [filename] | -rc[vbuf] [size] }

The meanings of common option values are as follows:

help provides help information for the command.

Examples

ip link show                     # Display network interface information
ip link set eth0 up             # Enable network card
ip link set eth0 down            # Disable network card
ip link set eth0 promisc on      # Enable promiscuous mode for the network card
ip link set eth0 promisc offi    # Disable promiscuous mode for the network card
ip link set eth0 txqueuelen 1200 # Set the network card queue length
ip link set eth0 mtu 1400        # Set the network card maximum transmission unit
ip addr show     # Display network card IP information
ip addr add 192.168.0.1/24 dev eth0 # Set IP address 192.168.0.1 for eth0 network card
ip addr del 192.168.0.1/24 dev eth0 # Delete IP address for eth0 network card

ip route show # Display system routing
ip route add default via 192.168.1.254   # Set the system default route
ip route list                 # View routing information
ip route add 192.168.4.0/24  via  192.168.0.254 dev eth0 # Set the gateway for the 192.168.4.0 network segment to 192.168.0.254, using the eth0 interface
ip route add default via  192.168.0.254  dev eth0        # Set the default gateway to 192.168.0.254
ip route del 192.168.4.0/24   # Delete the gateway for the 192.168.4.0 network segment
ip route del default          # Delete the default route
ip route delete 192.168.1.0/24 dev eth0 # Delete the route

Using the ip command to display the operational status of network devices:

[root@localhost ~]# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    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 qlen 1000
    link/ether 00:16:3e:00:1e:51 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:16:3e:00:1e:52 brd ff:ff:ff:ff:ff:ff

Display more detailed device information:

[root@localhost ~]# ip -s link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast   
    5082831    56145    0       0       0       0      
    TX: bytes  packets  errors  dropped carrier collsns
    5082831    56145    0       0       0       0      
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:16:3e:00:1e:51 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast   
    3641655380 62027099 0       0       0       0      
    TX: bytes  packets  errors  dropped carrier collsns
    6155236    89160    0       0       0       0      
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:16:3e:00:1e:52 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast   
    2562136822 488237847 0       0       0       0      
    TX: bytes  packets  errors  dropped carrier collsns
    3486617396 9691081  0       0       0       0

Display the kernel routing table:

[root@localhost ~]# ip route list
112.124.12.0/22 dev eth1  proto kernel  scope link  src 112.124.15.130
10.160.0.0/20 dev eth0  proto kernel  scope link  src 10.160.7.81
192.168.0.0/16 via 10.160.15.247 dev eth0
172.16.0.0/12 via 10.160.15.247 dev eth0
10.0.0.0/8 via 10.160.15.247 dev eth0
default via 112.124.15.247 dev eth1

Display the neighbor table:

[root@localhost ~]# ip neigh list
112.124.15.247 dev eth1 lladdr 00:00:0c:9f:f3:88 REACHABLE
10.160.15.247 dev eth0 lladdr 00:00:0c:9f:f2:c0 STALE

Get all network interfaces of the host:

ip link | grep -E '^[0-9]' | awk -F: '{print $2}'

Linux Command Manual

❮ Linux Comm Uudecode Linux Comm Minfo ❯