是否可以获取 macvlan 接口的所有 MAC/IP?我有 macvlan 接口:
[root@srv ~]# ip a
..................
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:e7:e6:10 brd ff:ff:ff:ff:ff:ff
......................
4: macvlan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1
link/ether 52:54:00:e7:e6:11 brd ff:ff:ff:ff:ff:ff
inet 1.1.0.6/24 brd 1.1.0.255 scope global macvlan0
valid_lft forever preferred_lft forever
我有 16 个带有 macvlan 接口的 docker 容器
[root@srv ~]# docker ps | grep 'Up ' |wc
16 166 3512
[root@srv ~]#
[root@srv ~]# docker network inspect docker-net
............
"Driver": "macvlan",
............
"Containers": {
"17ee78a594720836674448a244432e549ca4b78592e24767b2c6d052b783bd8e": {
......
"MacAddress": "02:42:0a:64:00:f9",
"IPv4Address": "1.1.0.249/24",
},
"1d910302d5fb83e478a0a5d70e0e566d89127916d9788cc61f6356502e14eb4e": {
........
"MacAddress": "02:42:0a:64:00:ad",
"IPv4Address": "1.1.0.173/24",
},
"2943fe549df8fd052d9f6ca74f720c11f7c7342d597d72a5287977d29c6f196f": {
"MacAddress": "02:42:0a:64:00:eb",
"IPv4Address": "1.1.0.235/24",
},
我如何列出 macvlan0 的所有子接口?
ip netns
- 不显示任何内容
lsns -t net
- 显示 16 个 docker 的网络命名空间
arp -an
显示 <16 arp,以及一些来自其他主机的 arp(1.1.0.1,1.1.0.253,1.1.0.254)
[root@srv ~]# arp -an
? (1.1.0.1) at 00:00:0c:07:ac:1e [ether] on macvlan0
? (1.1.0.198) at 02:42:0a:64:00:c6 [ether] on macvlan0
? (1.1.0.238) at 02:42:0a:64:00:ee [ether] on macvlan0
? (1.1.0.253) at 7c:69:f6:d0:9a:81 [ether] on macvlan0
? (1.1.0.172) at 02:42:0a:64:00:ac [ether] on macvlan0
? (1.1.0.254) at 7c:69:f6:ba:a3:81 [ether] on macvlan0
? (1.1.0.173) at 02:42:0a:64:00:ad [ether] on macvlan0
? (1.1.0.234) at 02:42:0a:64:00:ea [ether] on macvlan0
? (1.1.0.174) at 02:42:0a:64:00:ae [ether] on macvlan0
? (1.1.0.235) at 02:42:0a:64:00:eb [ether] on macvlan0
? (1.1.0.249) at 02:42:0a:64:00:f9 [ether] on macvlan0
? (1.1.10.1) at 52:54:00:0e:84:51 [ether] on eth1
[root@srv ~]#
我知道,所有 macvlan0 接口都在不同的网络命名空间中,显然 ip link show macvlan0 show
无法显示不同命名空间中的子接口。但是还有其他命令可以获取所有命名空间中的所有 ip 和 MAC 吗?