Next: , Previous: , Up: Configuration   [Contents][Index]


4.5 Network interfaces

Before tinc can start transmitting data over the tunnel, it must set up the virtual network interface.

First, decide which IP addresses you want to have associated with these devices, and what network mask they must have.

Tinc will open a virtual network device (/dev/tun, /dev/tap0 or similar), which will also create a network interface called something like ‘tun0’, ‘tap0’. If you are using the Linux tun/tap driver, the network interface will by default have the same name as the netname. Under Windows you can change the name of the network interface from the Network Connections control panel.

You can configure the network interface by putting ordinary ifconfig, route, and other commands to a script named /etc/tinc/netname/tinc-up. When tinc starts, this script will be executed. When tinc exits, it will execute the script named /etc/tinc/netname/tinc-down, but normally you don’t need to create that script. You can manually open the script in an editor, or use the following command:

tinc -n netname edit tinc-up

An example tinc-up script, that would be appropriate for the scenario in the previous section, is:

#!/bin/sh
ifconfig $INTERFACE 192.168.2.1 netmask 255.255.0.0
ip addr add fec0:0:0:2::/48 dev $INTERFACE

The first command gives the interface an IPv4 address and a netmask. The kernel will also automatically add an IPv4 route to this interface, so normally you don’t need to add route commands to the tinc-up script. The kernel will also bring the interface up after this command. The netmask is the mask of the entire VPN network, not just your own subnet. The second command gives the interface an IPv6 address and netmask, which will also automatically add an IPv6 route. If you only want to use "ip addr" commands on Linux, don’t forget that it doesn’t bring the interface up, unlike ifconfig, so you need to add ‘ip link set $INTERFACE up’ in that case.

The exact syntax of the ifconfig and route commands differs from platform to platform. You can look up the commands for setting addresses and adding routes in Platform specific information, but it is best to consult the manpages of those utilities on your platform.


Next: , Previous: , Up: Configuration   [Contents][Index]