Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a similar requirement to the OP of this thread.

I want the following configuration:

-Physical host (PhyHost) reachable from the network at IP 10.1.101.89
-LXC container (LxcHost) reachable from the network at IP 10.1.101.95
Each contactable from the other.

OS = Ubuntu Server 12.04LTS

PhyHost /etc/network/interfaces

auto br0
iface br0 inet static
    address 10.1.101.89
    netmask 255.255.255.0
    broadcast 10.0.0.255
    gateway 10.1.101.111
    pre-up ifconfig eth0 down
    pre-up ifconfig eth0 0.0.0.0 promisc up
    pre-up brctl addbr br0
    pre-up brctl addif br0 eth0
    bridge_fd 9
    bridge_hello 2
    bridge_maxpage 12
    bridge_stp off

auto br0:1
    address 10.1.101.95
    netmask 255.255.255.0
    gateway 10.1.101.111

iface eth0 inet manual
    pre-up ifconfig eth0 0.0.0.0 promisc up
    pre-up brctl addif br0 eth0
    pre-down brctl delif br0 eth0
    pre-down ifconfig eth0 down

LxcHost /etc/network/interfaces

auto eth0
iface eth0 inet static
    address 10.1.101.95
    netmask 255.255.255.0
    gateway 10.1.101.111
*I added some pre-up route add command here, being away from the system, I have forgotten what I used here*

As it is here the LxcHost was completely isolated and couldn't contact any other host. I added some pre-up route add and post-down commands (hence the note above) that completely escape me right now, but these brought connectivity from LxcHost out to the network. Normally I'd wait till I had all the information correct before posting, but I'm pretty keen to get some suggestions and tips on best practice.

lxc.conf used to create container

lxc.network.type=veth
lxc.network.link=br0:1
lxc.network.flags=up
lxc.network.hwaddr=
lxc.network.ipv4=10.1.101.95/24

The behaviour I get from this set up is that PhyHost is contactable from the network (ping, ssh etc) on 10.1.101.89. When I ssh to 10.1.101.95, I find myself logging into PhyHost also.

LxcHost can reach the internet, and the network including PhyHost, all hosts (including PhyHost) communicate only with PhyHost at the address 10.1.101.95.

Other issues that I've had to address:

  • No response to the second IP addess - solved by setting eth0 to promiscuous
  • No network connectivity from LxcHost to any - solved with pre-up route commands on LxcHost eth0.
share|improve this question
1  
It came down to my misunderstanding of how bridging works... I was adding a subinterface (br0:1) and assigning it an IP address on the physical host, then assigning the same IP to the container. When I simply gave the container a unique IP it worked. so I've been able to do away with the subinterface and it all works. –  Raymund Mar 2 '13 at 1:07
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.