Skip to contentSkip to conversation

Bind TUN to IPv4 Subnet

DISCUSSION Georg Wicherski 1 participant 1 message Jul 19, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hey Folks,

I need to bind a TUN device previously created by open("/dev/net/tun", O_RW) to a subnet, let's say 10.254.0.0/16. The ultimate goal is to have a tunnel endpoint for a IPv4 tunnel, where I can after writing the packet which came over the tunnel to the TUN device use an arbitary userland socket bound to one of the 2^16 IPs or just all of them with with INADDR_ANY.

What is the (sequence?) of ioctl's to configure the TUN device into `listening' on a whole subnet? If possible, I want to just specify a base address and a prefix length.

Digging into the curent 2.6.x kernel sources didn't help me much (yes, they are badly commented).

Thanks,
Georg Wicherski