2

I'm trying to route an additional IP of my server from Hetzner to a LXC instance (on Debian Jessie). I've found this guide http://www.jotschi.de/technik/2012/04/18/hetzner-lxc-linux-subnet-configuration.html and followed it.

My problem is that as soon as I restart the network the server will stay "offline" and I need to restore the configuration using the rescue system.

/etc/network/interfaces http://pastebin.com/KQQeDdcb

B and N represent a number and have been put in place only for this post. The bridge interface is disabled so I could restart the server.

Thank you for your help.

K.A.B.
  • 23
  • 5

2 Answers2

0

If you're losing connection to your host after setting up the bridge you are probably just misconfiguring the bridge.

Forget about the instance forwarding at first. Take your working network config and move it to the bridge. Assuming the linked pastebin is your current working configuration for the host:

auto  eth0
iface eth0 inet static
  address   176.B.N.20
  broadcast 176.B.N.31
  netmask   255.255.255.224
  gateway   176.B.N.1

Configure your bridge like this:

iface eth0 inet manual
auto  br0
iface br0 inet static
  bridge_ports eth0
  address   176.B.N.20
  broadcast 176.B.N.31
  netmask   255.255.255.224
  gateway   176.B.N.1

Check your network works, and only then proceed to add the necessary container routings with:

up ip route add 78.46.zz.116/32 dev br0

Note that I've used iproute2, net-tools is deprecated and usually just complicates things.

Also, be careful how you change network settings remotely.

If you do /etc/init.d/networking restart remotely without proper precautions (nohup, tmux or screen) you'll end up leaving the network in stopped state.

Usually you'll want to set your network manually with iproute2 or other tools and once you get it working translate that into a config file.

GnP
  • 955
  • 8
  • 15
  • This works except as soon as I add "bridge_ports eth0", the host machine is offline again. – K.A.B. Nov 02 '15 at 23:11
  • Oh and I loose connection to the host machine, not the container. I didn't get so far yet. Thank you for your help. – K.A.B. Nov 02 '15 at 23:21
  • @K.A.B. yes, I figured that was the problem. That's why I've said you're probably misconfiguring the bridge. I'm not sure it was clear in my answer, but once you setup the bridge the config for eth0 should be gone (see the `iface eth0 inet manual` line). Also, is bridge-utils installed? check with brctl and try creating the bridge manually instead of using ifupdown. How are you restarting the network after changing the `interfaces` file? – GnP Nov 03 '15 at 21:00
  • I checked it with both the default config of eth0 and the one you suggested (In which case the host remains offline). I did create the bridge manually each time (without brctl) and restarted the network with "/etc/init.d/networking restart". bridge-utils are installed. I'll try to use brctl now, but unless I write a comment stateing anything else assume it failed. – K.A.B. Nov 03 '15 at 23:51
  • Result: brctl addbr br0; brctl addif br0 eth0 took the host offline (Without prior modification to eth0) – K.A.B. Nov 03 '15 at 23:58
  • Additional note: I don't know if that helps, but MACs are important for my hoster. I did not change the MAC address of br0. The MAC address of eth0 is the one registred with my host(Hetzner.de). – K.A.B. Nov 04 '15 at 00:17
  • Yes, absolutely. Try setting the mac address on the bridge interface: `brctl addbr br0; ip link set dev br0 down; ip link set dev br0 addr [MAC]; ip link set dev br0 up; ip addr add 176.B.N.20/27 dev br0; ip route add default vía 172.B.N.1 dev br0; brctl addif br0 eth0` – GnP Nov 04 '15 at 09:37
  • Still no luck. This is the exact config I've used now (except for B and N). – K.A.B. Nov 04 '15 at 19:09
  • And I should maybe include the link -.- http://pastebin.com/MDwnznPS – K.A.B. Nov 04 '15 at 19:28
0

The hints given by gnt were absolutely correct. I only needed to change the order around and fix a silly typo.

This is the final config I've used (minus IPv6):

    iface lo inet loopback
     auto  br0
     iface br0 inet static
       bridge_ports eth0
       address   176.B.N.20
       broadcast 176.B.N.31
       netmask   255.255.255.224
       gateway   176.B.N.1
       # default route to access subnet
       up route add -net 176.B.N.0 netmask 255.255.255.224 gw 176.B.N.1 br0

     iface eth0 inet manual

Also helpful: How to create bridged network interface for Xen?

Thank you sooo much!

K.A.B.
  • 23
  • 5