1

I have set up a linux container on my server. The problem I have right now is that I cannot ping my linux container from my laptop, but I can ping the hypervisor.

I created the LXC by using:

lxc-create -n tomcat1 -t ubuntu

and then starting it. I didn't set any IP or anything, as it did by it self- with a another C-network that is not mine. Could this be the problem?

All help is appreciated.

1 Answer 1

0

In a default setup, a random class C will be chosen for the container's DHCP range. This also sets up a NAT/MASQ firewall on the host. As with any minimal NAT firewall, it only serves connections initiated from the server/container on the inside, but not from the outside.

One of the most used ways to reach the container is to setup a PREROUTING/FORWARD firewall rule, that will forward specific port (ranges) to the container.

Eg. if you have a webserver running in your container that you want to reach:

iptables -t nat -A PREROUTING -d [hypervisor_IP]/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination [container_IP]

This will forward the traffic that is going to your hypervisor's IP on port 80 (HTTP) to your container. So in your browser you'd go to http://[hypervisor_IP]/ and you will see the webpage that is served by your container's webserver.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .