Introduction

A small explanation of the /etc/network/interfaces file as found in modern debian distributions. I wrote this because I didn't find a comprenhensive document on how to use this file in more complex network situations. If you have more information and/or additions, please contact(dirkjan arago.utwente.nl) me so I can add them here.

For reference information check the man page. Man interfaces - Manpage of interfaces

example

first I auto load a couple of interfaces:

auto lo eth0 eth1

And I define the loopback interface, should always be there...

iface lo inet loopback

then I define eth0, which is my external interface, connecting to a cablemodem with _dhcp_:

iface eth0 inet dhcp

next is my internal network device, since the machine is a dhcp server it has a _static_ address, note that also a ipv6 address is added:

iface eth1 inet static
address 192.168.0.30
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
iface eth1 inet6 static
address 2001:7b8:331:1::1
netmask 48

The ipv4 part is pretty standard stuff, the ipv6 address is in a delegated subnet.

Adding a GRE tunnel

So course before trying this in the interfaces file, check that your kernel supports gre tunnels. The configuration on both sides of the tunnel would be mirrored. Here's an example of one endpoint:

iface zeus inet static
address 192.168.0.2
network 10.0.0.0
netmask 255.255.255.0
pre-up ip tunnel add zeus mode gre remote 212.120.124.15 local 130.89.193.99 ttl 255
up ip link set mtu 1500 dev zeus
up ip ro add 10.0.0.0/24 dev zeus
up ip ro del 192.168.0.0/24 dev zeus
post-down ip tunnel del zeus

The trick is in the pre-up rule, this defines the tunnel by calling the 'ip tunnel' command after which the tunnel can be treated like any other interface. The post-down rule makes sure the tunnel get destroyed when downed. I also had to add a route fix, but this is rather site specific...