【问题标题】:Get list of physical interfaces in openwrt获取openwrt中的物理接口列表
【发布时间】: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


【解决方案1】:

您好,您可以使用 python scapy 获取接口列表

from scapy.all import *
print(get_windows_if_list())

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-08
    • 2012-03-18
    • 2015-03-15
    • 2017-10-22
    • 2016-09-09
    • 2017-05-12
    • 1970-01-01
    相关资源
    最近更新 更多