Interface name or ID of /dev/tun tunnels
Robert Watson
rwatson at FreeBSD.org
Mon Jul 10 11:27:19 UTC 2006
On Mon, 10 Jul 2006, Remi Denis-Courmont wrote:
> Is there any clean way to find out the name, or better yet the ID (since ID
> are immutable while names are not), of a tunnel device allocated from
> /dev/tun ?
>
> The question was already raised here, but I could find no answer:
> http://lists.freebsd.org/pipermail/freebsd-net/2004-March/003338.html
>
> If not, would it be possible to add, say, an ioctl() on tun/tap devices to
> return their ID (which could be converted to a name via if_indextoname()),
> or something similar? That should retain full backward compatibility...
>
> Or maybe there is another way to configure the tunnel a la ifconfig with
> only the file descriptor??
Take a look at devname(3), which includes an example of how to identify which
device was opened via /dev/tun.
Robert N M Watson
Computer Laboratory
University of Cambridge
More information about the freebsd-net
mailing list