[lxc-users] ssh the LXC container from outside world

Sitesh Behera sitesh.behera at bankbazaar.com
Thu Apr 16 16:24:03 UTC 2015


Hi All,

I need some guidance on how i can ssh a LXC container from outside world.

I am having a host which is having ip address: 192.168.13.4

I have a lxcbr0 bridge configured with IP address @ 192.168.14.100

I want to spawn containers with static IP from 192.168.14.200-254

So have the following configs :

1)  cat /etc/default/lxc-net
USE_LXC_BRIDGE="true"

LXC_BRIDGE="lxcbr0"
LXC_ADDR="192.168.14.2"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="192.168.15.2/24"
LXC_DHCP_RANGE="192.168.14.200,192.168.14.254"
LXC_DHCP_MAX="25300"


2) /etc/iptables.rules

iptables -A FORWARD -s 192.168.14.0/24 -o eth0 -j ACCEPT
iptables -A FORWARD -d 192.168.14.0/24 -o lxcbr0 -j ACCEPT

3) /etc/network/interfaces

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

pre-up iptables-restore < /etc/iptables.rules


4) cat /var/lib/lxc/uat/config

# Common configuration
lxc.include = /usr/share/lxc/config/ubuntu.common.conf

# Container specific configuration
lxc.rootfs = /var/lib/lxc/uat/rootfs
lxc.mount = /var/lib/lxc/uat/fstab
lxc.utsname = uat
lxc.arch = amd64

# Network configuration
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:a2:13:e8
lxc.network.ipv4 = 192.168.14.231/24
lxc.network.ipv4.gateway = 192.168.14.1
lxc.start.auto = 1
lxc.start.delay = 5
lxc.cgroup.memory.limit_in_bytes = 4096M
lxc.cgroup.cpuset.cpus = 0-3



My issue is i can ping the container and even ssh from the local host. But
unable to do so from any other host on the 192.168.13.x network. Please
note the machine which hosts LXC is also on 192.168.13.X network.

-Sitesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20150416/60d35b48/attachment.html>


More information about the lxc-users mailing list