Ubuntu LXC Port Forwarding

2012-06-28 20:37:00 +0000

So you have a service running in an LXC container behind a bridge, and you need ports forwarded for that service. In this case, we'll use Minecraft as an example, which runs on port 25565. Our container's IP is 10.0.3.116.

sudo iptables -t nat -I PREROUTING -p tcp -d $PUBLICIP --dport 25565 -j DNAT --to 10.0.3.116:25565
sudo iptables -A FORWARD -p tcp -d 10.0.3.116 --dport 25565 -j ACCEPT
comments powered by Disqus