Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

As far as i know, there are 4 main types of network interfaces in linux: tun, tap, bridge and physical.

When i'm doing sys admin on machines running KVM, i usually come accross tap, bridge and physical interfaces on the same machine, without being able to tell them apart. I can't see any significant differences in ifconfig results, as in ip results.

How can i know if an interface is tun/tap/bridge/physical ?

note: I don't claim there is no other types of network interfaces in linux, but i know only this 4 ones

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I don't think there's an easy way to distinguish them. Poking around in /sys/class/net I found the following distinctions:

  • Physical devices have a /sys/class/net/eth0/device symlink
  • Bridges have a /sys/class/net/br0/bridge directory
  • TUN and TAP devices have a /sys/class/net/tap0/tun_flags file
  • Bridges and loopback interfaces have 00:00:00:00:00:00 in /sys/class/net/lo/address
share|improve this answer
    
Good idea to look in /sys/ –  user368507 Jun 17 '12 at 15:43
    
Virtual devices may also have such a device symlink: ls -l /sys/class/net/lan1/device Shows /sys/class/net/lan1/device -> ../../../dsa.0 on a router running OpenWrt (embedded Linux). I found that physical Interfaces have an Interrupt entry in the output of ifconfig. It is strange that such a simple question about an Interface seems so hard to answer. Investigation continues ... –  Lumi Dec 1 '12 at 11:53

Regarding TUN and TAP devices: it is not enough to make the check above. The reason is that there may be cases when we create a tun device and (by error) call it tap10; or create a tap device and name it tun10. How can I know if it is a tun device or a tap device ? both of course will have "tun_flags" entry. The answer is to run "ethtool -i tunOrTapDeviceName".

In case of a tap device we will get: "bus-info: tap". In case of a tun device we will get: "bus-info: tun".

share|improve this answer
    
Isn't there a ethtool command to find if an interface it physical or bridge? –  madCode Sep 3 '13 at 14:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.