Created
March 19, 2023 14:49
-
-
Save WinLinux1028/5bd36fbf9cbe4499d5fecd044eddf400 to your computer and use it in GitHub Desktop.
Cloudflare以外が443番ポートにアクセスすることを阻止するシェルスクリプト
This file contains hidden or 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
#!/bin/bash | |
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT | |
for ip in `curl "https://www.cloudflare.com/ips-v4"` | |
do | |
iptables -A INPUT -p tcp -m multiport --dports 443 -s ${ip} -j ACCEPT | |
done | |
iptables -A INPUT -p tcp -m multiport --dports 443 -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment