Skip to content

Instantly share code, notes, and snippets.

@mfakane
mfakane / update-iptables.sh
Last active February 15, 2018 16:59
国による IP ブロック
#!/bin/bash
cd /tmp
curl -O http://nami.jp/ipv4bycc/cidr.txt.gz && gunzip -f cidr.txt.gz
ipset create -exist WHITELIST hash:net
ipset flush WHITELIST
sed -n 's/^JP\t//p' cidr.txt | while read ADDRESS; do ipset add WHITELIST $ADDRESS; done
ipset create -exist BLACKLIST hash:net