Created
March 4, 2022 21:39
-
-
Save ShortyDev/1fb19d2968c1ee3f68f43ee1fa0d7cfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -D INPUT -j cloudflare | |
iptables -F cloudflare | |
iptables -N cloudflare | |
iptables -A INPUT -j cloudflare | |
ip6tables -D INPUT -j cloudflare | |
ip6tables -F cloudflare | |
ip6tables -N cloudflare | |
ip6tables -A INPUT -j cloudflare | |
for i in `curl https://www.cloudflare.com/ips-v4 -L`; do iptables -I cloudflare -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done | |
for i in `curl https://www.cloudflare.com/ips-v6 -L`; do ip6tables -I cloudflare -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done | |
iptables -A cloudflare -p tcp -m multiport --dports http,https -j DROP | |
ip6tables -A cloudflare -p tcp -m multiport --dports http,https -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For blocking other ports except 80 (http) and 443 (https), you can just add/replace protocols on the iptables command.
Example:
--dports http,https,1337