[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Google
 
Web openvpn.net

Re: [Openvpn-users] detect tun interface associated with openvpn instance


  • Subject: Re: [Openvpn-users] detect tun interface associated with openvpn instance
  • From: James Yonan <jim@xxxxxxxxx>
  • Date: Tue, 4 Oct 2005 23:56:05 -0600 (MDT)

On Tue, 4 Oct 2005, /dev/rob0 wrote:

> On Monday 2005-October-03 23:57 UTC, I wrote:
> > I am seeking a scripted means of detecting the tun interface which is
> > associated with a particular openvpn instance. I can easily identify
> 
> Perhaps it will be clearer if I discuss The Ultimate Goal.
> 
> I want to have a command-line tool to verify the connectivity of any 
> particular openvpn peer tunnel.
> 
> I already use a script ... "vpn VPNNAME [start|stop|status]", like a 
> SysVinit-style init script. The "status" command returns the PID. I 
> want to extend it to test and report whether or not the peer is 
> reachable. The PID merely means that this end of the tunnel is up.
> 
> > the PID's of all openvpn ... pidof(8) (killall5). But I have not yet
> > found a simple way to identify which tun (or perhaps even tap,
> > although I only use --dev tun) that PID is using.
> >
> > I've been looking at lsof(1) and netstat(8), as well as poking around
> > the /proc tree. This is Linux, but I would prefer something portable,
> > if that's possible. Linux /proc/$PID/fd/{3,4} ?
> 
> File descriptors 3 and 4 are symbolic links to sockets identified by 
> number. I don't know what the numbers mean. There's nothing there to 
> suggest that my tun0 VPN is using tun0. File descriptor 5 is a symlink 
> to /dev/net/tun.
> 
> > I know I can get the IP addresses from the interfaces and the config
> > filename from /proc/$PID/cmdline, then look up the IP from the file,
> > but that's ugly. Am I missing something simple? Thanks.
> 
> A less ugly idea is to write a status file along with (or appended to?) 
> the PIDfile. That will work for me, but won't be useful for others.
> 
> It just seems odd that there's no way to determine the association 
> between a tun/tap interface and the userspace program it is working 
> with. I bet there is, it's just beyond my skill level to find it.

Why don't you just write an --up script which takes the environmental 
variable corresponding to the tun/tap interface ($dev) and writes it to a 
file?  (see the man page)

James

____________________________________________
Openvpn-users mailing list
Openvpn-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/openvpn-users