2

I known that I can give a specific name to the TUN interface using --dev option, but I didn't and I have now on a router machine something like a hundred client configs. with less clients I was able to dig the log to search for the name of the interface and link it to a named config file, but now there is too much activity.

I have played for a while with lsof and udevadm but I'm still not able to link a specific tunX interface with an OpenVPN instance.

I would like to know which OpenVPN instance/config-name/process is linked to a specific TUN, like tun4 for example, is there a solution for that?

slm
  • 363,520
  • 117
  • 767
  • 871
dominix
  • 524
  • 1
  • 5
  • 14
  • 1
    Be it for openvpn or a VM, it's the same: [How to find the connection between tap interface and its file descriptor?](https://unix.stackexchange.com/questions/462171/how-to-find-the-connection-between-tap-interface-and-its-file-descriptor). You can link it to the correct running process among candidates (openvpn processes) and hopefully to its config file – A.B Aug 15 '18 at 15:44

1 Answers1

1

So I came with a solution inspired by A.B comment.

$ ps ax | \
  awk '/[o]penvpn/{print $7" "$1;system("grep iff /proc/"$1"/fdinfo/*")}'` 

which give me both running config and it's linked TUN interface.

slm
  • 363,520
  • 117
  • 767
  • 871
dominix
  • 524
  • 1
  • 5
  • 14