1

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"

config_tunl0=( 
        "xxx.xxx.xxx.xxx netmask 255.255.255.255"
        "yyy.yyy.yyy.yyy netmask 255.255.255.255"
        "zzz.zzz.zzz.zzz netmask 255.255.255.255"
)

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 0.0.0.0 brd 0.0.0.0
    inet xxx.xxx.xxx.xxx/32 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
  address xxx.xxx.xxx.xxx
  netmask 255.255.255.255

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.
   ...done.

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

davidsmalley
  • 457
  • 1
  • 6
  • 14

2 Answers2

3

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
  address xxx.xxx.xxx.xxx
  netmask 255.255.255.255

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.

Christopher Cashell
  • 9,128
  • 2
  • 32
  • 44
2

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:
  netmask 255.255.255.255

  # Local address (inside tunnel) (required)
  address 192.168.1.1 

  # dstaddr = remote address (inside tunnel)
  dstaddr 192.168.2.2

  # 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
Marc Tamsky
  • 121
  • 2