How are network numbers selected for TUN device ?

mol-general@lists.maconlinux.org mol-general@lists.maconlinux.org
Mon, 15 Jul 2002 17:02:02 +0200


On Mon, Jul 15, 2002 at 04:13:31PM +0200, Benjamin Herrenschmidt wrote:
> Hi Samuel !
> 
> I noticed the tun device automatically gets assigned a NAT network
> of 192.168.x.0, where x is apparently always 2 here.
> 
> The problem is that my work internal network is already 192.168.2.0
> (and my home one is 10.0.1.0). I used to have MOL use 192.168.4.0
> back with 0.9.63 when I used my own tunconfig scripts.
> 
> How is that network number selected ? I didn't (yet) find a simple
> way to force the scripts to use 192.168.4.0

Well, mol derives the network number from the tun device name.
The name of the tun device is by default given by the session
number:

	netdev: tun${session} -tun
	
(this makes it possible to run multiple networked MOL sessions
in parallel).

The /etc/tunconfig scripts adds one to the tun device
number, e.g.

	tun0	->  192.168.1.0
	tun1	->  192.168.2.0
	...

(I figured 192.168.0.0 was commonly used for local networks,
so I added one to the network number. I guess I should
hav started at 192.168.100.0 or something :-(.

You can easily change 1 to 100 in /etc/mol/tunconfig though.
The line of intereset is

	TUN_NUM=`expr 1 + 0$TUN_NUM`

You should also change /etc/mol/dhcpd-mol.conf if you want
DHCP to work. Each subnet mol might use should be declared
as follows:

subnet 192.168.1.0 netmask 255.255.255.0 {
        option domain-name-servers      192.168.1.1;
        option routers                  192.168.1.1;
        host mol { 
                hardware ethernet       00:00:0D:EA:DB:EE;
                fixed-address           192.168.1.2;
        }
}

Note that the tunconfig script uses NAT to redirect
nameserver queries directed to the linux endpoint
of the tunnel to the first entry in /etc/resolv.conf.

/Samuel