I'm working on a network automation project. I'm writing a python script that will remotely scan Ubuntu servers and network switches and then do its best to reconstruct the network's physical topology in a diagram. I think the script can do this, like so:
- For every Ubuntu server, make a list of the server's physical interfaces.
- If an interface is UP/UP, note its MAC address.
- For every network switch, examine all UP/UP ports that could be supporting end servers.
- Examine the switch's MAC Address table for the MAC of the host on the far end.
- If a match is found, update the diagram.
Step 1 is the current headache. When I run commands like ifconfig
, ip a
, ip link show
, lshw -C network -short
, ls /sys/class/net/
, netstat -i
, and others, I get a list of all network interfaces, physical and logical. For example, here's the list of interfaces on one of my servers:
bond0.10
bond0.11
br16
br17
eno3
enp216s0
enp94s0f
lo
virbr0
vnet0
vnet1
Which are physical? Which are virtual? I can make some educated guesses, but that's not good enough. I'd like to definitively identify which interfaces are the physicals and weed out the rest.
(I do not have admin access on these Ubuntu machines, so I can't install a utility like nmcli
.)
Any advice is wildly appreciated.