Skip to content

Instantly share code, notes, and snippets.

@WinLinux1028
Created March 19, 2023 14:49
Show Gist options
  • Save WinLinux1028/5bd36fbf9cbe4499d5fecd044eddf400 to your computer and use it in GitHub Desktop.
Save WinLinux1028/5bd36fbf9cbe4499d5fecd044eddf400 to your computer and use it in GitHub Desktop.
Cloudflare以外が443番ポートにアクセスすることを阻止するシェルスクリプト
#!/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