...
In this example we setup Apache which runs on port 80 in the container which has been assigned the static IP 10.0.3.10.
Make sure the host is not listening on port 80,
Code Block | ||
---|---|---|
| ||
netstat -an | grep LISTEN | grep 80
tcp6 0 0 fe80::2cd7:eff:fea3::53 :::* LISTEN |
While on the host issue these commands,
Code Block | ||
---|---|---|
| ||
# Immediately enable port forwarding rule, but this is not persistent on reboot. sudo iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -j DNAT --to-destination 10.0.3.10:80 # Need to document how to turn this off using command line without rebooting. # ... # To make persistent. sudo apt-get install iptables-persistent # Tool replaces lots of manual work documented here, https://help.ubuntu.com/community/IptablesHowTo sudo /etc/init.d/iptables-persistent save sudo /etc/init.d/iptables-persistent reload |
...