ip命令

ip命令与ifconfig命令类似,但比ifconfig命令更加强大,主要功能是用于显示或设置网络设备、路由和隧道的配置等,ip命令是Linux加强版的的网络配置工具,用于代替ifconfig命令。

语法

ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename

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

OPTIONS := { -V[ersion] | -s[tatistics] | -r[esolve] | -f[amily] { inet | inet6 | ipx | dnet | link } | -o[neline] }

参数

OPTIONS

OBJECT

示例

查看网络接口信息,例如IP地址,子网等。

ip addr show

要查看eth0网卡信息。

ip addr show eth0

启用网络接口。

ip link set eth0 up

关闭网络接口。

ip link set eth0 down

查看路由和默认网关信息。

ip route show

获取到特定ip的路由信息。

ip route get to 192.168.111.111

查看arp条目。

ip neigh

查看网络统计。

ip -s link

查看详细帮助信息。

man ip

参考

https://www.computerhope.com/unix/ip.htm
https://www.commandlinux.com/man-page/man8/ip.8.html
https://www.geeksforgeeks.org/ip-command-in-linux-with-examples/