Difference between revisions of "Iptables quick guide"

From thelinuxwiki
Jump to: navigation, search
(Pushed from thelinuxwiki.com.)
 
Line 8: Line 8:
 
  iptables -I OUTPUT -p tcp -d 1.1.1.1 --dport 873 -j ACCEPT
 
  iptables -I OUTPUT -p tcp -d 1.1.1.1 --dport 873 -j ACCEPT
  
 +
 +
== allow muliple ports example ==
 +
iptables -I OUTPUT -p tcp -d 1.1.1.1 --dport '''1024:65535''' -j ACCEPT
  
 
== NAT ==
 
== NAT ==

Revision as of 17:01, 6 August 2013

http://www.linode.com/wiki/index.php/Netfilter_IPTables_Mini_Howto

Contents

Changing the default policy in iptables

iptables -P INPUT DROP

allow outbound rsync and insert rule at the top of the chain

iptables -I OUTPUT -p tcp -d 1.1.1.1 --dport 873 -j ACCEPT


allow muliple ports example

iptables -I OUTPUT -p tcp -d 1.1.1.1 --dport 1024:65535 -j ACCEPT

NAT

show nat rules

iptables -L -t nat

hide nat behind and interface

iptables -t nat -A POSTROUTING -o tun0 -s 192.168.1.0/24 -j MASQUERADE

saving rules for reload on reboot

on fedora 17

iptables-save > /etc/sysconfig/iptables