CentOS 7 默认没有ifconfig命令,如果需要安装执行如下命令
yum install -y net-tools
ip help查看命令帮助说明:
ip help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
vrf }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec |
-f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
-4 | -6 | -I | -D | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } | -br[ief] |
-o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
-rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}
其中ip管理的对象包括link(网络设备)、address(网络IP地址)、route(路由表)、neigh(缓存令居的ARP Mac地址)、tunnel(IP隧道)、netns(网络namespace)
查看netns id列表:
ip netns list-id
-d参数:查看详细信息
ip -d link show eth0
ip -d addr show eth0
如:
[root@host-192-168-3-167 ~]# ip -d addr show tunl0
4: tunl0@NONE: <NOARP,UP,LOWER_UP> mtu 1440 qdisc noqueue state UNKNOWN group default qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0 promiscuity 0
ipip remote any local any ttl inherit nopmtudisc numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
inet 10.100.4.192/32 brd 10.100.4.192 scope global tunl0
valid_lft forever preferred_lft forever
或
[root@localhost ~]# ip -d addr show dev tun0
5: tun0@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN group default qlen 1000
link/ipip 192.168.154.11 peer 192.168.154.12 promiscuity 0
ipip remote 192.168.154.12 local 192.168.154.11 ttl 64 pmtudisc numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
inet 192.168.155.10 peer 192.168.156.10/32 scope global tun0
valid_lft forever preferred_lft forever