1

On a Linux box, I see there exists a lot of virtual NIC's. If I want to know what's the link type when created them using 'ip link add ... type ...', what do I do?

Thanks, woody

Woody Wu
  • 191
  • 1
  • 9

3 Answers3

2

You can use multiple ways -

  1. brctl show - Bridge membership can be displayed

  2. ifconfig -a | grep HWaddr - match with MAC addresses

  3. ls -l /sys/class/net/ - virtual ones will show all in virtual and lan is on the PCI bus.

sanjayparmar
  • 633
  • 8
  • 19
2

ip -details link show will add almost (but not) all imaginable properties of an interface, including, usually at start of 3rd line, its type, eg a bridge, a veth, etc. Real ethernet or wireless devices won't show their hardware nature with this command except by the absence of such additional property. Wireless can be detected by the existence of its phy name in /sys/class/net/<ifname>/phy80211/name.

Here's a dirty script (that shouldn't be considered reliable because it's parsing unreliable format!) to display most types (but eg pimreg appearing with a PIM multicast daemon would have its special property link/pimreg before which wouldn't be shown):

$ ip -details link show |awk '/^[0-9]+:/ { line=NR; printf "\n%s ",gensub("(@.*|:)$","",1,$2) } NR == line+2 { printf "%s",$1 } END { printf "\n" }'

lo 
eth0 
wlan0 
dummy0 dummy
lxcbr0 bridge
virbr0 bridge
virbr0-nic tun
gre0 gre
gretap0 gretap
erspan0 erspan
ifb0 ifb
ifb1 ifb
vethIRMVCJ veth
vethQOHSJ9 veth
testbr0 bridge
wg0 wireguard
macvlan0 macvlan
A.B
  • 11,090
  • 2
  • 24
  • 45
1

There may be some other way. I use the reverse question:

ip link show type bridge

where you can substitute bridge with other type of NIC.

schweik
  • 263
  • 2
  • 9