background image

Manpage of IPTABLES

ANDed with the mask before the comparison). 

  

owner

This module attempts to match various characteristics of the packet creator, for locally-generated packets. 
It is only valid in the OUTPUT chain, and even this some packets (such as ICMP ping responses) may 
have no owner, and hence never match. 

--uid-owner userid 

Matches if the packet was created by a process with the given effective user id. 

--gid-owner groupid 

Matches if the packet was created by a process with the given effective group id. 

--pid-owner processid 

Matches if the packet was created by a process with the given process id. 

--sid-owner sessionid 

Matches if the packet was created by a process in the given session group. 

--cmd-owner name 

Matches if the packet was created by a process with the given command name. (this option is 
present only if iptables was compiled under a kernel supporting this feature) 

  

state

This module, when combined with connection tracking, allows access to the connection tracking state for 
this packet. 

--state state 

Where state is a comma separated list of the connection states to match. Possible states are 
INVALID meaning that the packet is associated with no known connection, ESTABLISHED 
meaning that the packet is associated with a connection which has seen packets in both directions, 
NEW meaning that the packet has started a new connection, or otherwise associated with a 
connection which has not seen packets in both directions, and RELATED meaning that the packet 
is starting a new connection, but is associated with an existing connection, such as an FTP data 
transfer, or an ICMP error. 

  

conntrack

http://www.iptablesrocks.org/syntax/man_iptables.htm (9 of 20) [2/13/2004 8:04:51 PM]

Summary of Contents for iptables

Page 1: ...vers the installation of iptables in a Redhat environment the syntax and structure associated with iptables and a collection a pre configured iptables configurations for a variety of applications This...

Page 2: ...Replace an existing rule from a desired chain in the current configuration iptables I chain that s a capital I as in Insert Insert a new rule into a desired chain of the current configuration iptables...

Page 3: ...Iptablesrocks org Syntax Structure Site last modified February 13 2004 15 27 51 http www iptablesrocks org syntax 2 of 2 2 13 2004 8 04 43 PM...

Page 4: ...warded packets COMPLETELY 3 With all incoming packets dropped by default it then grants incoming access to a select number of ports These ports are ports that a typical web server might allow Open inb...

Page 5: ...Iptablesrocks org Examples http www iptablesrocks org examples 2 of 2 2 13 2004 8 04 44 PM...

Page 6: ...lat file iptables script into the server s ruleset Q How do I export my server s iptables rulset to flat iptables script A The command iptables save path to firewall_script will export the current ipt...

Page 7: ...esrocks org If you would like to contact me please fill out the form below and then click Send It Your name Your e mail Comments Questions home syntax structure examples faq contact links Site last mo...

Page 8: ...www netfilter org Linuxguruz Iptables Tutorial http www linuxguruz com iptables howto iptables HOWTO html Qmailrocks org My qmail installation guide Djbdnsrocks org My djbdns installation guide home...

Page 9: ...ain unused port What if you want to block someone from your server Get the answers right here What if I want to open another port While it is possible to append rules to your live iptables configurati...

Page 10: ...ou take a look at the firewall script you will notice that TCP port 3389 is not mentioned anywhere in the script and to be more specific it is not mentioned in the INPUT portion of the script Well sin...

Page 11: ...make sure you enable your iptables safetynet before you start playing with your firewall setup You don t want to accdientally lock yourself out of your server Starting your fiewall on boot The final p...

Page 12: ...stions May we post your comments on this website Yes No your name e mail address will not be posted A note on privacy Some people worry about providing their e mail address on the form You don t need...

Page 13: ...ck myself out of my server I will only need to wait a maximum of 10 minutes before the bad firewall rules will be dropped and I ll be able to shell into my server again If you are a newbie at iptables...

Page 14: ...up and lock yourself out of your server while you are implementing or testing new iptables configurations With this crontab running should you lock yourself out you will only have to wait a maximum o...

Page 15: ...TING p tcp m tcp tcp flags FIN SYN FIN SYN j DROP A PREROUTING p tcp m tcp tcp flags FIN SYN RST PSH ACK URG FIN PSH URG j DROP A PREROUTING p tcp m tcp tcp flags FIN SYN RST PSH ACK URG NONE j DROP A...

Page 16: ...tcp dport 783 j ACCEPT A OUTPUT p tcp m tcp dport 993 j ACCEPT A OUTPUT p tcp m tcp dport 3306 j ACCEPT A OUTPUT p tcp m tcp dport 12000 j ACCEPT A OUTPUT p tcp m tcp dport 15000 j ACCEPT A OUTPUT p t...

Page 17: ...hain iptables t table X chain iptables t table P chain target options iptables t table E old chain name new chain name DESCRIPTION Iptables is used to set up maintain and inspect the tables of IP pack...

Page 18: ...is configured with automatic module loading an attempt will be made to load the appropriate module for that table if it is not already there The tables are as follows filter This is the default table...

Page 19: ...les are inserted at the head of the chain This is also the default if no rule number is specified R replace chain rulenum rule specification Replace a rule in the selected chain If the source and or d...

Page 20: ...representing one of these protocols or a different one A protocol name from etc protocols is also allowed A argument before the protocol inverts the test The number zero is equivalent to all Protocol...

Page 21: ...When the argument precedes the f flag the rule will only match head fragments or unfragmented packets c set counters PKTS BYTES This enables the administrator to initialize the packet and byte counte...

Page 22: ...fied using the format port port If the first port is omitted 0 is assumed if the last is omitted 65535 is assumed If the second port greater then the first they will be swapped The flag sport is a con...

Page 23: ...ort port port Destination port or port range specification See the description of the destination port option of the TCP extension for details icmp This extension is loaded if protocol icmp is specifi...

Page 24: ...source or destination ports Up to 15 ports can be specified It can only be used in conjunction with p tcp or p udp source ports port port port Match if the source port is one of the given ports The f...

Page 25: ...ted by a process with the given command name this option is present only if iptables was compiled under a kernel supporting this feature state This module when combined with connection tracking allows...

Page 26: ...original source address differs from the reply destination DNAT A virtual state matching if the original destination differs from the reply source ctproto proto Protocol to match by number or name ct...

Page 27: ...ie including the precedence bits tos tos The argument is either a standard name use iptables m tos h to see the list or a numeric value to match ah This module matches the SPIs in AH header of IPSec...

Page 28: ...he Linux kernel will print some information on all matching packets like most IP header fields via the kernel log where it can be read with dmesg or syslogd 8 This is a non terminating target i e rule...

Page 29: ...trols the nature of the error packet returned reject with type The type given can be icmp net unreachable icmp host unreachable icmp port unreachable icmp proto unreachable icmp net prohibited or icmp...

Page 30: ...rce ports below 512 will be mapped to other ports below 512 those between 512 and 1023 inclusive will be mapped to ports below 1024 and other ports will be mapped to 1024 or above Where possible no po...

Page 31: ...rts to use overriding the default SNAT source port selection heuristics see above This is only valid if the rule also specifies p tcp or p udp REDIRECT This target is only valid in the nat table in th...

Page 32: ...usually limiting it to your outgoing interface s MTU minus 40 Of course it can only be used in conjunction with p tcp This target is used to overcome criminally braindead ISPs or servers which block I...

Page 33: ...rious error messages are printed to standard error The exit code is 0 for correct functioning Errors which appear to be caused by invalid or abused command line parameters cause an exit code of 2 and...

Page 34: ...NAT HOWTO details NAT the netfilter extensions HOWTO details the extensions that are not in the standard distribution and the netfilter hacking HOWTO details the netfilter internals See http www netfi...

Page 35: ...COMMANDS PARAMETERS OTHER OPTIONS MATCH EXTENSIONS tcp udp icmp mac limit multiport mark owner state conntrack dscp pkttype tos ah esp length ttl unclean TARGET EXTENSIONS LOG MARK REJECT TOS http ww...

Page 36: ...LOG TCPMSS DSCP ECN DIAGNOSTICS BUGS COMPATIBILITY WITH IPCHAINS SEE ALSO AUTHORS This document was created by man2html using the manual pages Time 05 21 18 GMT January 07 2004 http www iptablesrocks...

Page 37: ...by initially blocking all incoming outgoing and forwarded packets COMPLETELY 3 With all incoming packets dropped by default it then grants incoming access to a select number of ports These ports are p...

Page 38: ...rnel logging configuration so that the firewall will log its activites to a custom logfile Here s how you do it vi etc syslog conf Add the following to the syslog conf file IPTables logging kernel mes...

Page 39: ...org Preparation Proceed to the next step home syntax structure examples faq contact links Site last modified February 13 2004 15 27 51 http www iptablesrocks org guide preparation php 2 of 2 2 13 200...

Page 40: ...e will set the script to run at regular intervals In the way should you lock yourself out of your server all you ll have to do is sit back and wait for the script to execute and for the firewall to re...

Page 41: ...irewall every 15 minutes crontab e 0 15 30 45 sbin iptables restore root firewall_reset That s it Now save and exit out of the crontab editor That s it Until the crontab is disabled your server s ipta...

Page 42: ...EROUTING p tcp m tcp tcp flags FIN SYN FIN SYN j DROP A PREROUTING p tcp m tcp tcp flags FIN SYN RST PSH ACK URG FIN PSH URG j DROP A PREROUTING p tcp m tcp tcp flags FIN SYN RST PSH ACK URG NONE j DR...

Page 43: ...m tcp dport 443 j ACCEPT uncomment the next line if you are running Spamassassin on your server A OUTPUT p tcp m tcp dport 783 j ACCEPT A OUTPUT p tcp m tcp dport 993 j ACCEPT A OUTPUT p tcp m tcp dpo...

Page 44: ...p anywhere anywhere tcp dpt http ACCEPT tcp anywhere anywhere tcp dpt pop3 ACCEPT tcp anywhere anywhere tcp dpt imap ACCEPT tcp anywhere anywhere tcp dpt https ACCEPT tcp anywhere anywhere tcp dpt ima...

Page 45: ...ning you will want to disable the safetynet crontab so that your firewall will remain up and running Proceed to the next step home syntax structure examples faq contact links Site last modified Februa...

Page 46: ...L portscans it should block many and make the others a bit more time consuming and troublesome A portion nmap probe s activities should be logged in the var log firewall logfile The log entries will c...

Page 47: ...gz And now let s start the installation cd iptables Log into mysql and do the database work mysql u root p create a database called iptables mysql create database iptables Now create an admin user for...

Page 48: ...the database feeder script vi scripts feed_db pl Make sure the following configuration section is set properly Make sure you enter the iptables_user mysql password where the x s are my dsn DBI mysql...

Page 49: ...our server and then logging in again via SSH The SSH connection will be recorded in the iptables logs and this will appear on the Iptables Log Analyzer screen If you need more help with Iptables Log A...

Reviews: