[lxc-users] Networking in Ubuntu with 2 ip failover in LXC

Tamas Papp tompos at martos.bme.hu
Wed Aug 13 07:58:23 UTC 2014


On 08/13/2014 09:47 AM, bryn1u85 . wrote:
> Hey everyone,
>
> I've been trying to configure Ubuntu LXC with 2 ip failover from OVH 
> but i failed :(
> I've been reading many howto's and still nothing. I have found on this 
> list same cool tutorial which has written by Olivier. There is a link: 
> https://lists.linuxcontainers.org/pipermail/lxc-users/2011-May/001980.html
>
> I don't know why i still can't get access to internet from LXC.
>
> My host ip: 94.23.237.216
> My ip fail over ip 1: 91.121.239.228
>
> I'll focus on one failover ip.
> I did as Olivier has subscribed.
>
> Host:
> root at ns321124:~# cat /etc/network/interface
> # The loopback network interface
> auto lo
> iface lo inet loopback
> auto eth0
>         iface eth0 inet static
>
> auto br0
>         iface br0 inet static
>         bridge_ports eth0
>         bridge_stp off
>         bridge_maxwait 0
>         bridge_fd 0
>         address 94.23.237.216
>         netmask 255.255.255.0
>         network 94.23.237.0
>         broadcast 94.23.237.255
>         gateway 94.23.237.254
> post-up /sbin/ifconfig br0:0 91.121.239.228 netmask 255.255.255.255 
> broadcast 91.121.239.228
> post-down /sbin/ifconfig br0:0 down

Use either post-up and /sbin/ip or 'iface br0:0 inet static.....'.

> root at ns321124:~# cat /var/lib/lxc/Oksymoron/config
> # Template used to create this container: 
> /usr/share/lxc/templates/lxc-ubuntu
> # Parameters passed to the template:
> # For additional config options, please look at lxc.container.conf(5)
>
> # Common configuration
> lxc.include = /usr/share/lxc/config/ubuntu.common.conf
>
> # Container specific configuration
> lxc.rootfs = /var/lib/lxc/Oksymoron/rootfs
> lxc.mount = /var/lib/lxc/Oksymoron/fstab
> lxc.utsname = Oksymoron
> lxc.arch = amd64
>
> # Network configuration
> lxc.network.type = veth
> lxc.network.flags = up
> lxc.network.link = br0
> lxc.network.name <http://lxc.network.name> = eth0
> lxc.network.ipv4 = 91.121.239.228

Use this IP either here or on the bridge iface, but not at both places.

> root at ns321124:~# cat /var/lib/lxc/Oksymoron/rootfs/etc/network/interfaces
> # The loopback network interface
> auto lo
> iface lo inet loopback
>
> auto eth0
> iface eth0 inet static
>         adress 91.121.239.228
>         netmask 255.255.255.255
>         broadcast 91.121.239.228

Define your network either in container:/etc/network/interfaces or in 
lxc config file, but not at both places.

>
>         post-up route add 94.23.237.254 dev eth0
>         post-up route add default gw 94.23.237.254
>         post-down route del 94.23.237.254 dev eth0
>         post-down route del default gw 94.23.237.254

Why not the standard 'gateway .....' configuration?

>
> For sure i did reboot and lunch lxc.
>
> Checking ifconfig in LXC called Oksymoron
>
> root at Oksymoron:/home/ubuntu# ifconfig
> eth0      Link encap:Ethernet  HWaddr 00:16:3e:3e:35:9e
>           inet addr:91.121.239.228  Bcast:255.255.255.255  Mask:0.0.0.0
>           inet6 addr: fe80::216:3eff:fe3e:359e/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:109 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:9448 (9.4 KB)  TX bytes:648 (648.0 B)
>
> lo        Link encap:Local Loopback
>           inet addr:127.0.0.1  Mask:255.0.0.0
>           inet6 addr: ::1/128 Scope:Host
>           UP LOOPBACK RUNNING  MTU:65536  Metric:1
>           RX packets:16 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:1248 (1.2 KB)  TX bytes:1248 (1.2 KB)
>
> Now try update.
> root at Oksymoron:/home/ubuntu# apt-get update
> Err http://archive.ubuntu.com trusty InRelease
>
> Err http://archive.ubuntu.com trusty-updates InRelease
>
> Err http://security.ubuntu.com trusty-security InRelease
>
> Err http://security.ubuntu.com trusty-security Release.gpg
>   Could not resolve 'security.ubuntu.com <http://security.ubuntu.com>'
> Err http://archive.ubuntu.com trusty Release.gpg
>   Could not resolve 'archive.ubuntu.com <http://archive.ubuntu.com>'
> Err http://archive.ubuntu.com trusty-updates Release.gpg
>   Could not resolve 'archive.ubuntu.com <http://archive.ubuntu.com>'
> Reading package lists... Done
> W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
>
> W: Failed to fetch 
> http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease
>
> W: Failed to fetch 
> http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease
>
> W: Failed to fetch 
> http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Could not 
> resolve 'archive.ubuntu.com <http://archive.ubuntu.com>'
>
> W: Failed to fetch 
> http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg 
>  Could not resolve 'archive.ubuntu.com <http://archive.ubuntu.com>'
>
> W: Failed to fetch 
> http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg 
>  Could not resolve 'security.ubuntu.com <http://security.ubuntu.com>'

This is a dns resolving issue.

t
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20140813/d9d25133/attachment-0001.html>


More information about the lxc-users mailing list