Friday, April 15, 2011

How to block access to your server from all IP except your

If your server had CSF then do the below step

close off all UDP/TCP ports in csf.conf, then add the IP's you want to allow access to csf.allow and csf.ignore. Just make sure you add the ips BEFORE doing so or you will lock yourself out.

after that run the below command

csf -r

If you are using IPTABLES then
#The below line will DROP all incoming connections.
iptables -P INPUT DROP

#Allow specific IPs to specific ports for example port 22 for IP 1.1.1.1
iptables -A INPUT -p tcp -s 1.1.1.1 --d-port 22 -j ACCEPT

In this fashion you can add your IPs in the allow list.

No comments:

Post a Comment