LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to read IP tables (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-read-ip-tables-865605/)

maobin 02-28-2011 07:36 PM

How to read IP tables
 
Hi ppl,
I run the below command
Code:

cat /etc/sysconfig/iptables
and got this

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

Can any one teach me how to read this? or point me to the man I can read?

corp769 02-28-2011 07:54 PM

Quote:

Originally Posted by maobin (Post 4274592)
Hi ppl,
I run the below command
Code:

cat /etc/sysconfig/iptables
and got this

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

Can any one teach me how to read this? or point me to the man I can read?

Sure... Type in "man iptables" on the command line. Cheers,

Josh

maobin 02-28-2011 08:41 PM

so for example

-A RH-Firewall-1-INPUT -i lo -j ACCEPT

This means append to chain named "RH-Firewall-1-INPUT", the interface in qn is "lo" and jump to "ACCEPT"?

and for,

-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT

this means append to chain named "RH-Firewall-1-INPUT",protocol in qn is tcp that match tcp from port 631 and jump to "ACCEPT"?

am i right in saying that?

corp769 02-28-2011 08:44 PM

It is not jumping, you are just telling it accept the packet data if the destination port is 631 (cups) and it is a tcp packet. Hope that helps you understand it better.

http://en.wikipedia.org/wiki/Iptables

Wikipedia has an excellent description of operation.

Cheers,

Josh

maobin 02-28-2011 09:33 PM

Quote:

Originally Posted by corp769 (Post 4274638)
It is not jumping, you are just telling it accept the packet data if the destination port is 631 (cups) and it is a tcp packet. Hope that helps you understand it better.

http://en.wikipedia.org/wiki/Iptables

Wikipedia has an excellent description of operation.

Cheers,

Josh

Ic, Thanks alot for the assistance. :)

salasi 03-01-2011 03:22 AM

An excellent (if a teensy bit long) document on iptables is available at:

http://iptables-tutorial.frozentux.net/

Available in several versions; I'd advise downloading a readable version, rather than just looking at the html, because you'll probably want to keep going back to various parts over a period of time.

corp769 03-01-2011 03:39 AM

Quote:

Originally Posted by maobin (Post 4274663)
Ic, Thanks alot for the assistance. :)

No problem!


All times are GMT -5. The time now is 04:53 PM.