English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Linux ip command is similar to ifconfig Commands are similar, but more powerful than the ifconfig command, mainly used to display or set network devices.
The ip command is a Linux enhanced version of the network configuration tool, used to replace the ifconfig command.
ip [ OPTIONS ] OBJECT { COMMAND | help }
OBJECT are commonly used objects, and the value can be one of the following:
OBJECT={ link | addr | addrlabel | route | rule | neigh | ntable | tunnel | maddr | mroute | mrule | monitor | xfrm | token }
The meanings of the values of commonly used objects are as follows:
OPTIONS are commonly used options, and the value 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 the values of the commonly used options are as follows:
help Provides help information for the command.
ip link show # Display network interface information ip link set eth0 up # Enable the network card ip link set eth0 down # Disable the network card ip link set eth0 promisc on # Enable the network card's promiscuous mode ip link set eth0 promisc offi # Disable the network card's promiscuous mode ip link set eth0 txqueuelen 1200 # Set the queue length of the network card ip link set eth0 mtu 1400 # Set the maximum transmission unit of the network card ip addr show # Display network card IP information ip addr add 192.168.0.1/24 dev eth0 # Set eth0 network card IP address192.168.0.1 ip addr del 192.168.0.1/24 dev eth0 # Delete eth0 network card IP address 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 # Set192.168.4.0 network segment's gateway is192.168.0.254, data goes through eth0 interface ip route add default via 192.168.0.254 dev eth0 # Set the default gateway to192.168.0.254 ip route del 192.168.4.0/24 # Delete192.168.4.0 network segment's gateway ip route del default # Delete the default route ip route delete 192.168.1.0/24 dev eth0 # Delete route
Use the ip command to display the running 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 core 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 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