Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Block incoming connections from Russian IPs to your Chia node using iptables and ipset.
- # Adapted from https://mtxserv.com/vps-server/doc/how-to-block-ip-addresses-by-country
- # Execute as root or using sudo.
- # 1. Install ipset:
- apt install ipset
- # or
- yum install ipset
- # 2. Create a new ipset called "ru".
- ipset create ru hash:net,port
- # 3. Create a file with the following contents, make it executable:
- #!/bin/bash
- COUNTRIES=('ru')
- ipset flush ru
- for i in "${COUNTRIES[@]}"; do
- echo "Ban IP of country ${i}"
- for IP in $(wget -O - https://www.ipdeny.com/ipblocks/data/countries/${i}.zone)
- do
- ipset add ru $IP,8444
- done
- done
- # 4. Execute the file you have just created to fill the ipset, it should take only a few seconds.
- # 5. And finally, create an iptables entry to put the new ipset to work.
- iptables -I INPUT -m set --match-set ru src -j DROP
Add Comment
Please, Sign In to add comment