Configure iptables for CloudFlare

IPTABLES: Only Allow CloudFlare to Access Your Server's HTTP(s) Ports

Note: These are command line instructions

for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -s $i --dport http -j ACCEPT; done  
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -s $i --dport https -j ACCEPT; done  
iptables -A INPUT -p tcp --dport http -j DROP  
iptables -A INPUT -p tcp --dport https -j DROP  

And to re-allow connections from anywhere:

iptables -A INPUT -p tcp --dport http -j ACCEPT  
iptables -A INPUT -p tcp --dport https -j ACCEPT  


P.S. This is only for IPv4.

Was this answer helpful?

Also Read

Accessing the Console

If you are having trouble connecting to your virtual server, you may want to use the console in...

How do I enable TUN/TAP on my VPS?

If your VPS is hosted on our Cloud infrastructure, you can already use tunneling - there is no...

My VPS has restarted. Why?

Some Windows VPS users may experience unexpected restarts of their virtual servers. This is...

How to set Reverse DNS for my VPS

Many e-mail servers on the Internet are configured to reject incoming e-mails from any IP address...