We're going to use this case to explain the usage of various methods to build tunnels between networks.
192.168.1.2 192.168.2.2 ------------| |------------ | | 192.168.1.2 | 192.168.1.1 (router1) 192.168.2.1 (router2) | 192.168.2.3 ------------|---------------------=========---------------------|------------ | 10.0.0.1 10.0.0.2 | 192.168.1.3 | | 192.168.2.4 ------------| |------------ |---------------------------------| |---------------------------------| 192.168.1.0/24 192.168.2.0/24
In the above diagram we see a network structure wich consists of 2
seperate physical networks. The
To use VTun you need the Universal TUN/TAP driver either as module or as part of the kernel.
For kernel 2.6 ( Device Drivers ---> [*] Networking support <*> Universal TUN/TAP device driver support) For kernel 2.4 ( )
After you enable the TUN/TAP driver either as module or as part of the kernel, compile the new kernel (and if you choose to make it part of the kernel, reboot).
If you choose to compile as module: # make modules_install # modules-update # modprobe tunIf you choose to compile as part of the kernel: # mount /boot # make install # reboot
The last kernel related step that has to be taken is the creation of a tunnel device file:
# mkdir /dev/net # mknod /dev/net/tun c 10 200
VTun works with a server and a client. Both use the same daemon, but the
server has more configuration options (like compressions and encryption).
In the above diagram
VTun configuration is done with two seperate configuration files.
default { type tun; keepalive yes; } mysession { pass mysecretpassword; proto tcp; comp zlib:6; encrypt yes; up { ifconfig "%% 10.0.1.1 pointopoint 10.0.1.2"; }; down { ifconfig "%% down"; }; }
This file as two sections,
The client configuration file is basically the same as the server file. I removed all configuration options on which the client has no effect.
default { type tun; keepalive yes; } mysession { pass mysecretpassword; proto tcp; up { ifconfig "%% 10.0.1.2 pointopoint 10.0.1.1"; }; down { ifconfig "%% down"; }; }
Basically the only thing that changed is the "up" part, the ip addresses are switched in this one.