Difference between revisions of "Iptables on Ubuntu 14.04"

From MyWiki
Jump to: navigation, search
Line 4: Line 4:
 
iptables -S  ( reflects the commands necessary ) <br>
 
iptables -S  ( reflects the commands necessary ) <br>
 
iptables -F  ( flush the current rules ) <br><br>
 
iptables -F  ( flush the current rules ) <br><br>
'''Connecting to a vm from external'''<br>
+
'''Connecting to a vm from external''' ( This is good, it works )<br>
 
<source lang="text">
 
<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 80 -j DNAT --to-destination 10.0.0.1:80

Revision as of 17:08, 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 ( This is good, it works )

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