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
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
You can use multiple ways -
brctl show
- Bridge membership can be displayed
ifconfig -a | grep HWaddr
- match with MAC addresses
ls -l /sys/class/net/
- virtual ones will show all in virtual and lan is on the PCI bus.
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
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.