Last update at :2024-05-28,Edit by888u
This code can block mainland China IP. Of course, changing the IP library address (cn.zone file) can block specific IPs and IP segments.
1. Block Chinese IP and save the following code as blockcn.sh
ipset -N china hash:net rm cn.zone wget -P . https://we.com/wp-content/uploads/2018/04/cn.zone for i in $(cat /root/cn.zone ); do ipset -A china $i; done iptables -I INPUT -p tcp -m set --match-set china src -j DROPThen, execute:
shblockcn.sh2. Unblock Chinese IP and save the following code as boblockcn.sh:
ipset -N china hash:net rm cn.zone wget -P . https://we.com/wp-content/uploads/2018/04/cn.zone for i in $(cat /root/cn.zone ); do ipset -A china $i; done iptables -D INPUT -p tcp -m set --match-set china src -j DROPThen, execute:
sh noblockcn.shvia: https://www.lowendtalk.com/discussion/141800/blocking-attack-ips-ddos-ips-from-china
3. Further optimized script This script is based on the IP segment provided by ipdeny.com. The above script can be added and deleted accurately and in real time, each with its own advantages and disadvantages. 1. Download
wget --no-check-certificate https://us.com/wp-content/uploads/2018/04/block-ips.sh2. Use
Here is China as an example. If you want to block other countries, please modify the final code parameters yourself
Add rules
bash block-ips.sh -a cnStart blocking
bash block-ips.sh -b cnList of blocked countries
bash block-ips.sh -lUnblock
bash block-ips.sh -u cnView other country codes: http://www.ipdeny.com/ipblocks
via: https://lolico.moe/projects/block-countries-ips.html
Recommended site searches: vps dynamic ip, foreign space service providers, ip reverse check, domain name query network, ip detailed address query, registered password retrieval, free ip proxy server, domain name purchase, host space, US vps host, < /p>
发表评论