Jump to Navigation

191 - iptables firewall configuration (RedHat)

1. Check the iptable status in Linux Server.

# iptables --line-numbers -n -L

2. Modify the configuration file.

# vi /etc/sysconfig/iptables

3. You will see default rules as follows.

*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 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

4. Restart service.

# chkconfig iptables on  (if you need)
# service iptables restart

5. Parameters.

INPUT - The default chain is used for packets addressed to the system. Use this to open or close incoming ports
(such as 80,25, and 110 etc) and ip addresses / subnet (such as 202.54.1.20/29).

OUTPUT - The default chain is used when packets are generating from the system.
Use this open or close outgoing ports and ip addresses / subnets.

FORWARD - The default chains is used when packets send through another interface.
Usually used when you setup Linux as router. For example, eth0 connected to ADSL/Cable modem and eth1 is connected to local LAN.
Use FORWARD chain to send and receive traffic from LAN to the Internet.

RH-Firewall-1-INPUT - This is a user-defined custom chain. It is used by the INPUT, OUTPUT and FORWARD chains.

 



Main menu 2

Story | by Dr. Radut