[Lxc-users] lxc container not visible from host, but host visible inside container

Serge Hallyn serge.hallyn at canonical.com
Fri Jul 6 15:01:14 UTC 2012


Quoting Li, Zeyang (a.banknote at gmail.com):
> Hi,
> 
> I ran into a problem where I cannot ssh to containers but I could do
> the reverse and ssh to the host from inside containers.
> I'm doing this on ubuntu 12.04 and followed official tutorial. It
> looks like it should be rather painless and I should be able to access
> container through hostname or ip after booting it.
> 
> Here is my container network setup, hostname "budda1"
> 
> ubuntu at budda1:~$ ifconfig
> eth0      Link encap:Ethernet  HWaddr 00:16:3e:8b:af:ba
>           inet addr:10.0.3.195  Bcast:10.0.3.255  Mask:255.255.255.0
>           inet6 addr: fe80::216:3eff:fe8b:afba/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:44 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:6963 (6.9 KB)  TX bytes:3248 (3.2 KB)
> 
> 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:16436  Metric:1
>           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
> 
> lxcbr0    Link encap:Ethernet  HWaddr 1a:cf:ac:d0:2e:b0
>           inet addr:10.0.3.1  Bcast:10.0.3.255  Mask:255.255.255.0

You can't have lxcbr0 in the container with the same ip as lxcbr0
on the host.  If you don't want to use lxcbr0 in the container at
all (that is, if you're not running nested containers) then edit
/etc/default/lxc and set

USE_LXC_BRIDGE="false"

and do 'sudo restart lxc-net'.

If you do want to run nested containers, then change the address
for lxcbr0.  The following values in /etc/default/lxc should work:

LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.5.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.5.0/24"
LXC_DHCP_RANGE="10.0.5.2,10.0.5.254"
LXC_DHCP_MAX="253"

Again, 'sudo restart lxc-net' to load these new values.


>           inet6 addr: fe80::18cf:acff:fed0:2eb0/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:0 (0.0 B)  TX bytes:554 (554.0 B)
> 
> 
> Here is my host network setup.
> 
> eth1      Link encap:Ethernet  HWaddr 00:0b:e0:f0:00:ed
>           inet addr:192.168.0.187  Bcast:192.168.0.255  Mask:255.255.255.0
>           inet6 addr: fe80::20b:e0ff:fef0:ed/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:3774669 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:19871338 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:325045419 (325.0 MB)  TX bytes:28140974879 (28.1 GB)
>           Interrupt:42 Base address:0xc000
> 
> 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:16436  Metric:1
>           RX packets:9002 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:9002 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:895944 (895.9 KB)  TX bytes:895944 (895.9 KB)
> 
> lxcbr0    Link encap:Ethernet  HWaddr 42:41:2f:06:48:54
>           inet addr:10.0.3.1  Bcast:10.0.3.255  Mask:255.255.255.0
>           inet6 addr: fe80::4041:2fff:fe06:4854/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:967 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:4742 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:265702 (265.7 KB)  TX bytes:362339 (362.3 KB)
> 
> vethDRRJNv Link encap:Ethernet  HWaddr ea:a8:65:4e:bc:af
>           inet6 addr: fe80::e8a8:65ff:fe4e:bcaf/64 Scope:Link
>           UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
>           RX packets:25 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:3506 (3.5 KB)  TX bytes:8848 (8.8 KB)
> 
> vethNoOhWO Link encap:Ethernet  HWaddr 42:41:2f:06:48:54
>           inet6 addr: fe80::4041:2fff:fe06:4854/64 Scope:Link
>           UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
>           RX packets:169 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:817 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:29672 (29.6 KB)  TX bytes:91511 (91.5 KB)
> 
> vethmo7HuT Link encap:Ethernet  HWaddr ca:34:1b:41:93:74
>           inet6 addr: fe80::c834:1bff:fe41:9374/64 Scope:Link
>           UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
>           RX packets:228 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:1114 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:45992 (45.9 KB)  TX bytes:110286 (110.2 KB)
> 
> virbr0    Link encap:Ethernet  HWaddr 8e:24:41:13:de:9a
>           inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
>           UP BROADCAST MULTICAST  MTU:1500  Metric:1
>           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
> 
> Thanks,
> Zeyang
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Lxc-users mailing list
> Lxc-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-users




More information about the lxc-users mailing list