Artificial intelligent assistant

How to find out which process keeps tunnel interface(tun) up? If I create a `tun` interface with `ip tuntap add mode tun` command and force it administratively up with `ip link set dev tun1 up` command, then the interface itself is always "physically" down: root@A58:~# ip link show dev tun1 46: tun1: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 500 link/none root@A58:~# This makes sense as there are no applications connected to this interface. However, I also have `tun0` in my system which is "physically" up: root@A58:~# ip link show dev tun0 45: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 100 link/none root@A58:~# Is there a way to find out which process is connected to this `tun0` interface? I had no luck with `ps -ef | grep tun0` or `lsof | grep tun0`.

The Linux kernel exposes this info now in `/proc/$PID/fdinfo/$FD`. For example:


# grep ^iff: /proc/*/fdinfo/*
/proc/31219/fdinfo/5:iff: tun0
/proc/31235/fdinfo/5:iff: tun1
/proc/31252/fdinfo/5:iff: tun2
/proc/31267/fdinfo/5:iff: tun3


Tested with Debian 5.8.10.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 54ba05957b0b56338e7282202ec05118