Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ldirectord/heartbeat HA setup between a gentoo load balancer and gentoo real servers. Due to the limitations of my host I have the load balancing working via ipip tunnel.

I have the following settings on the gentoo real server:

(appended to the end of...) /etc/conf.d/net

iptunnel_tunl0="mode ipip"

        " netmask"
        "yyy.yyy.yyy.yyy netmask"
        "zzz.zzz.zzz.zzz netmask"

Those xxx/yyy/zzz ips are my shared ip addresses.

'ip address show' yields this:

4: tunl0: <NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN 
    link/ipip brd
    inet scope global tunl0
    inet yyy.yyy.yyy.yyy/32 scope global tunl0:1
    inet zzz.zzz.zzz.zzz/32 scope global tunl0:2

This all works fine.

I'm now trying to setup ipip tunnelling to an Ubuntu real server.

I can get the interface to appear using:

ip tunnel add tunl0 mode ipip

and then add IP addresses to it by appending this to /etc/network/interfaces

auto tunl0
  iface tunl0 inet static

Then my "ip addr show" command shows the same as on the gentoo machine

The problem is that the ip tunnel add.. doesn't persist across reboots, so the next time the networking tries to load we get this

# /etc/init.d/networking restart
* Reconfiguring network interfaces...
ssh stop/waiting
ssh start/running, process 2442
ssh stop/waiting
ssh start/running, process 2482
SIOCSIFADDR: No such device
tunl0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
tunl0: ERROR while getting interface flags: No such device
Failed to bring up tunl0.

How can I make the tunnel interface persist in the same way that it did in Gentoo?

share|improve this question
up vote 2 down vote accepted

There's two ways to handle this. If all you need is the one simple command, the easiest way is to add lines for pre-up and pre-down to your entry in /etc/network/interfaces:

auto tunl0

iface tunl0 inet static
  pre-up ip tunnel add tunl0 mode ipip
  post-down ip tunnel del tunl0 mode ipip

Alternately, if you want to do anything more complicated, you can add scripts to /etc/network/if-pre-up.d/ and /etc/network/if-post-down.d/ that are run prior to starting up, and after shutting down, the network, respectively.

share|improve this answer

Things have come a long way in 5 years. Lines belong in ( /etc/network/interfaces )

See man 5 intefaces for more details.

# Choose your own name for your tunnel interface (example uses 'mytun')
auto mytun
iface mytun inet tunnel
  mode ipip

  # Best I can tell, value of 'netmask' does nothing but is required:

  # Local address (inside tunnel) (required)

  # dstaddr = remote address (inside tunnel)

  # local = address of tunnel interface
  local x.x.x.x

  # endpoint = destination ip applied to ipip encapsulated packets (required)
  endpoint y.y.y.y

  # You may want to also consider using these two options
  # mtu 1480
  # ttl 63
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.