Skip to content

Instantly share code, notes, and snippets.

@ravibhure
Created February 14, 2017 12:25
Show Gist options
  • Save ravibhure/7c7d3746586aa36b58c59a25c191cafe to your computer and use it in GitHub Desktop.
Save ravibhure/7c7d3746586aa36b58c59a25c191cafe to your computer and use it in GitHub Desktop.
Ubuntu LXC Port Forwarding

Ubuntu LXC Port Forwarding

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment