Topics

Configuring iptables on CentOS

SELINUX

vi /etc/selinux/config
#
SELINUX=disabled

– reboot or run

 setenforce 0

– add iptables rules

mv /etc/sysconfig/iptables /etc/sysconfig/iptables.old
vi /etc/sysconfig/iptables
#add this rules
*filter
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp --icmp-type any -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#http port
-A INPUT -p tcp --dport 80 -j ACCEPT
# port  http://gadelkareem.com/2012/02/25/change--port-and-enable-x11-forwarding/
-A INPUT -p tcp --dport 4568 -j ACCEPT
# port http://gadelkareem.com/2012/02/27/configuring--on--with-different-port/
-A INPUT -p tcp --dport 5149 -j ACCEPT
-A INPUT -p tcp --dport 6713:8598 -j ACCEPT
#add your IP/s - only this IP will be allowed to  to all ports
-A INPUT -s 192.168.126.1  -j  ACCEPT

-A INPUT -j DROP
-A FORWARD -j DROP
COMMIT

– restart iptables

/etc/init.d/iptables restart

– Also, take a look on Using iptables to block ips that spam or attack your server post.