5

I can set up a persistent Linux tap interface and make it owned by a specific user and group with one of these:

tunctl -u someuser -g somegroup -t example.tap
ip tuntap add dev example.tap mode tap user someuser group somegroup

I can confirm the interface is there and see a bit of information about it with

ip link list dev example.tap

But how, after the fact, can I find out which user or group the interface is owned by? ip tuntap seems very sparsely documented and ip link list doesn't seem to show ownership.

2 Answers 2

6

An answer to this question suggested looking in /sys/, which turns out to help. For example:

cat /sys/class/net/example.tap/owner

reveals the uid of the owning user, or -1 if the interface isn't owned by a user. Similarly with group substituted for owner to get group ownership. I'm not sure if there's a "cleaner" method that doesn't involve delving into kernel filesystems.

2

Run ip(8) with the (under-documented) -d option:

$ sudo ip tuntap add dev tap0 mode tap user ben
$ ip -d link show tap0
40: tap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether c9:63:71:fa:8f:04 brd ff:ff:ff:ff:ff:ff promiscuity 0 
    tun type tap pi off vnet_hdr off persist on user ben addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 

Note user ben on the last line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .