获取openwrt中的物理接口列表

问题描述 投票:0回答:1

我们如何获取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也是逻辑的,但结果显示不同。

有人可以建议更好的方法吗?

python networking network-programming sh openwrt
1个回答
0
投票

您可以使用Python和

scapy
来获取接口列表。

from scapy.all import *
print(get_windows_if_list())
© www.soinside.com 2019 - 2024. All rights reserved.