【发布时间】:2017-08-19 19:46:18
【问题描述】:
如何在openwrt中获取所有物理接口,我用ls -l /sys/class/net/试过了,但信息不正确。
lrwxrwxrwx 1 root root 0 Mar 21 10:26 eth0 -> ../../devices/virtual/net/eth0
lrwxrwxrwx 1 root root 0 Mar 21 10:26 eth1 -> ../../devices/virtual/net/eth1
lrwxrwxrwx 1 root root 0 Mar 21 10:26 tun0 -> ../../devices/virtual/net/tun0
lrwxrwxrwx 1 root root 0 Mar 22 09:50 wlan0 -> ../../devices/pci0000:01/0000:01:00.0/net/wlan0
lrwxrwxrwx 1 root root 0 Mar 22 09:50 wlan0-1 -> ../../devices/pci0000:01/0000:01:00.0/net/wlan0-1
实际上 eth0 和 eth1 是物理的,wlan0-1 也是逻辑的。但结果显示不同。
有人可以提出更好的方法吗?
【问题讨论】:
-
为什么不
ifconfig? -
ifconfig将返回所有接口,但我看不到任何表明该接口是物理的还是虚拟的。 -
只要虚拟接口是OSI第3层,那么您可以将
ip link show返回的MAC地址与ip addr show列出的第3层接口绑定的MAC地址进行比较。
标签: python networking network-programming sh openwrt