Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

IPTables:

# vi /etc/sysconfig/iptables
Press i for insert mode
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

# Block input connection from all IP

# Allow Loopback Interface


-A INPUT -i lo -j ACCEPT
# Allow Web Access from All IP
-A INPUT -p tcp --dport 80 -j ACCEPT
# Allow SSH from Trusted IP
-A INPUT -p tcp --dport 22 -s IP/32 -j ACCEPT

#Replace with IP Address

# Drop SSH from any other IP except Trusted IP


-A INPUT -p tcp --dport 22 -j DROP
# Allow Ping from all IP
-A INPUT -p icmp --icmp-type 0 -m limit --limit 2/s --limit-burst 5 -j ACCEPT
-A INPUT -p icmp --icmp-type 8 -m limit --limit 2/s --limit-burst 5 -j ACCEPT
# Accept all types of packet from Trusted IP
-A INPUT -s IP/32 -j ACCEPT

#Replace with IP Address

# Accept Packets from Trusted IP on specific port of your switch, add both origination & termination IP with port
-A INPUT -p udp --dport port -s IP/32 -j ACCEPT

# Insert add both origination & termination IP with port before COMMIT
COMMIT
Press Esc for command mode
To save & exit type- :wq
To exit without saving type- :!q
You need to restart iptables service after any change
To restart service:
# service iptables restart

To show iptables status:


# service iptables status
To add iptables on startup: (one time)
# chkconfig iptables on

You might also like