4

I have installed LXC in ubuntu server 12.04 using this link. It was installed successfully and i am able login using ubutu/ubuntu as username and password. Then I tried to setup network for LXC container.

I changed in /etc/network/interface as

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 125.67.43.100
        netmask 255.255.255.0
        broadcast 178.33.40.255
        gateway 125.67.43.1

Content of /var/lib/lxc/mycontainer/config is:

lxc.utsname = mycontainer
lxc.mount = /var/lib/lxc/test/fstab
lxc.rootfs = /var/lib/lxc/test/rootfs


lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.veth.pair = vethmycontainer
lxc.network.ipv4 = 125.67.43.102
lxc.network.hwaddr= 02:00:00:86:5b:11

lxc.devttydir = lxc
lxc.tty = 4
lxc.pts = 1024
lxc.arch = amd64
lxc.cap.drop = sys_module mac_admin mac_override
lxc.pivotdir = lxc_putold

Containers etc/network/interface

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 125.67.43.102
        netmask 255.255.255.0
        broadcast 178.33.40.255
        gateway 125.67.43.1

This is how my configuration is

-------------        -----------         -----------   
| LXC       | -----> | Host OS | ------> | Gateway |
| Container |        | Ubuntu  |         |         | 
-------------        -----------         ----------- 
eth0 125.67.43.102   br0 <-> eth0        NAT GW:        
gw 125.67.43.1       br0 125.67.43.100   125.67.43.1    
                     gw 125.67.43.1

Ping 125.67.43.100   ping 125.67.43.1
ok                   OK
Ping 125.67.43.1     ping 125.67.43.102
FAIL                 OK

LXC container is not know outside host, any idea what i made wrong here?

Additional info

user@host$cat /proc/sys/net/ipv4/ip_forward is 1

I have added Nat rule

ip_tables -t nat -A POSTROUTING -s 125.67.43.102 -o eth0 -j MASQUERADE

Note: IPs I have used above is not original

niren
  • 253
  • 1
  • 5
  • 11

2 Answers2

2

Maybe this link will answer your question: https://wiki.debian.org/LXC/SimpleBridge

Seems like you should configure br0 instead of eth0 on the host (the first code block in your example).

I'm only guessing, though!

Your broadcast address does not match the network, I would use 125.67.43.255 in the above examples.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
LarsW
  • 21
  • 3
1

Your br0 should be the gateway of your container. Check about lxc.network.ipv4 syntax too. Maybe you should put subnet mask.

Eduardo Ramos
  • 268
  • 1
  • 6