Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
# 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

Now traffic on port 80 on the host will be forwarded to port 80 in the container IP specified.

You might want to delete the rule. Again, note this is not persistent upon reboot. Execute the exact same command to add, but change -A to -D,

Code Block
languagebash
 sudo # Immediately delete rule created, but this is not persistent on reboot. 
sudo iptables -t nat -D PREROUTING -p tcp -i eth0 --dport 80 -j DNAT --to-destination 10.0.3.10:80

If you test the rule and like it. Make it persistent,

Code Block
languagebash
# 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 

 

macvlan with Additional IP

...