Iptables Settings for CENTOS6 servers (host firewall)
Vim/etc/sysconfig/iptables-config
Add to:
iptables_modules= "Ip_nat_ftp ip_conntrack_ftp" in order to enable the IPTABLES support FTP service module
Reboot will fail then set boot boot:
1 Script content:
vim/etc/sysconfig/iptables.sh
#!/bin/bash
Iptables-a clean_in-p TCP! --syn-m State--state New-j DROP
Iptables-a input-p TCP--tcp-flags all none-j DROP
Iptables-a input-p TCP--tcp-flags all all-j DROP
Iptables-a input-d 192.168.1.255-p icmp-j DROP
Iptables-a input-d 255.255.255.255-p icmp-j DROP
Iptables-a input-d 192.168.1.202-m State--state invalid-j DROP
Iptables-a input-d 192.168.1.202-p tcp-m multiport--dport 21,22,80-m State--state new-j ACCEPT
Iptables-a input-d 192.168.1.202-p tcp-m State--state related,established-j ACCEPT
Iptables-a input-d 192.168.1.202-p udp-m State--state related,established-j ACCEPT
Iptables-a input-d 192.168.1.202-p ICMP--icmp-type 8-m limit--limit 2/second--limit-burst 5-m State--state NEW,ES Tablished-j ACCEPT
Iptables-a output-s 192.168.1.202-m State--state established-j ACCEPT
Iptables-save >/etc/sysconfig/iptables-v1
echo "" >/etc/sysconfig/iptables
Sed-i "/^$/D"/etc/sysconfig/iptables
Service Iptables Restart
Iptables-f
Iptables-restore </ETC/SYSCONFIG/IPTABLES-V1
2 Give it permission to execute
chmod 755/etc/sysconfig/iptables.sh
3 Use a scheduled task (security) when testing
Yum-y Install at
Service ATD Restart
/etc/sysconfig/iptables.sh && at now + minutes
At> Service iptables Restart
4 test the script and put it in/etc/rc.d/rc.local every time the boot executes.
Vim/etc/rc.d/rc.local
Add to
/etc/sysconfig/iptables.sh
5 restart
----------------------------------------------------------------------
Iptables Settings for CENTOS6 servers (host firewall)