ip 指令的作用與 ifconfig 十分相似, 而 ip 指令在 RHEL 及 CentOS 也是預設安裝。而除了查詢網路設定外, 也可以用作設定網路, 以下是 ip 指令的一些常見用法。
查詢網卡名稱及使用的 IP 地址, 即如同直接執行ifconfig 一樣:

  1. $ ip a

  1. $ ip addr

  1. $ ip address

  1. $ ip addr show
  1. 1: lo: mtu 16436 qdisc noqueue state UNKNOWN
  2. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  3. inet 127.0.0.1/8 scope host lo
  4. inet6 ::1/128 scope host
  5. valid_lft forever preferred_lft forever
  6. 2: eth0: mtu 1500 qdisc mq state UNKNOWN qlen 1000
  7. link/ether 00:50:56:8a:6e:84 brd ff:ff:ff:ff:ff:ff
  8. inet 10.20.0.14/24 brd 10.30.0.255 scope global eth0
  9. inet6 fe80::250:56ff:fe8a:6e84/64 scope link
  10. valid_lft forever preferred_lft forever

查詢 ipv4 或 ipv6 的資訊:

ipv4:

  1. $ ip -4 addr

ipv6:

  1. $ ip -6 addr

查詢個別網卡的資訊:

  1. $ ip addr show eth0

  1. $ ip addr list eth0

  1. $ ip addr show dev eth0

給網卡定義 IP 地址:

  1. $ sudo ip addr add 10.20.0.15/24 dev eth1

從網卡移除 IP 地址:

  1. $ sudo ip addr del 10.20.0.15/24 dev eth1

啟動網卡:

  1. $ sudo ip link set dev eth1 up

停用網卡:

  1. $ sudo ip link set dev eth1 down

顯示 Routing Table

  1. $ip r

  1. $ ip route

  1. $ ip route show

  1. $ ip route list

https://www.opencli.com/linux/ip-command