Report this

What is the reason for this report?

How to redirect IP address to Domain name?

Posted on November 29, 2014

Hello guys, i have bought cloudflare security, and i have noticed my IP address is still can be accessed from IP address. and i have noticed a little DDoS attack at my server today again. i want to make it like if someone try to access my IP address then it will redirect directly to my domain name(example.com). maybe it is can stop direct access to my IP address? well i am not sure i just think maybe it is also one way to stop the direct access on IP address. and one more quest does cloudflare stop all access to our Server or just port 80 and 443? and DDoS attack can be on any port or just 80?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

CloudFlare has a list of IP addresses which can be allowed with iptables, the rest can be dropped.

iptables -A INPUT -p tcp -m multiport --dports 80,443 --src 199.27.128.0/21 -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dports 80,443 --src 173.245.48.0/20 -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dports 80,443 --src 103.21.244.0/22 -j ACCEPT
[...]
iptables -A INPUT -p tcp -m multiport --dports 80,443 -j DROP

Add all the IP addresses in that list before the DROP statement. Now no one can directly connect to your Droplet via HTTP/HTTPS. Also check CloudFlare frequently to ensure you do not miss IP address changes.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.