Difference between revisions of "Iptables on Ubuntu 14.04"
From MyWiki
| Line 3: | Line 3: | ||
iptables -L [ -n ]<br> | iptables -L [ -n ]<br> | ||
iptables -S ( reflects the commands necessary ) <br> | iptables -S ( reflects the commands necessary ) <br> | ||
| − | iptables -F ( flush the current rules ) <br> | + | iptables -F ( flush the current rules ) <br><br> |
| + | '''Connecting to a vm from external'''<br> | ||
| + | <source lang="text"> | ||
| + | iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 80 -j DNAT --to-destination 10.0.0.1:80 | ||
| + | iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 22 -j DNAT --to-destination 10.0.0.2:22 | ||
| + | iptables -I FORWARD -m state -d 10.0.0.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
| + | </source> | ||
Revision as of 17:03, 1 March 2016
Reference - https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-iptables-on-ubuntu-14-04
All commands assume root level access
iptables -L [ -n ]
iptables -S ( reflects the commands necessary )
iptables -F ( flush the current rules )
Connecting to a vm from external
iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 80 -j DNAT --to-destination 10.0.0.1:80 iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 22 -j DNAT --to-destination 10.0.0.2:22 iptables -I FORWARD -m state -d 10.0.0.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT