VPS, dedicated server one-click shielding Chinese IP (can be other countries)

VPS, dedicated server one-click shielding Chinese IP (can be other countries)

This code can block domestic IP. Of course, by changing the IP library address (cn.zone file), you can block specific IPs and IP segments.

1. Block Chinese IP
Save the following code as blockcn.sh

 ipset -N china hash:net rm cn.zone wget -P . https://zhujiwiki.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 DROP

Then, execute:

 sh blockcn.sh

2. Unblock Chinese IP
Save the following code as boblockcn.sh:

 ipset -N china hash:net rm cn.zone wget -P . https://zhujiwiki.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 DROP

Then, execute:

 sh noblockcn.sh

via: https://www.lowendtalk.com/discussion/141800/blocking-attack-ips-ddos-ips-from-china

3. Further optimized script <br />This script is based on the IP segment provided by ipdeny.com. The above script can add and delete IP segments accurately and in real time, and each has its own advantages and disadvantages.
1. Download

 wget --no-check-certificate https://zhujiwiki.com/wp-content/uploads/2018/04/block-ips.sh

2. Use

Here we take China as an example. If you want to block other countries, please modify the last code parameter yourself.

Adding rules

 bash block-ips.sh -a cn

Start blocking

 bash block-ips.sh -b cn

List of blocked countries

 bash block-ips.sh -l

Unblock

 bash block-ips.sh -u cn

For other country codes, please visit: http://www.ipdeny.com/ipblocks

via: https://lolico.moe/projects/block-countries-ips.html

<<:  Hostsolutions: €1.99/month/2GB memory/30GB space/30TB traffic/OpenVZ/Romania/No copyright

>>:  5wire: £4.5/month/1GB RAM/10GB SSD space/unlimited traffic/KVM/UK

Recommend

ServersSoft: €55/month/X3440/16GB memory/8TB space/100TB traffic/Netherlands

ServersSoft, a foreign hosting provider, was esta...

WINNERvps: $4.99/month/512MB memory/10GB SSD/500GB traffic/4 IP/Xen/Phoenix

WINNERvps, which has been introduced before, is a...

Kimsufi: €4.99/month/2GB memory/500GB space/unlimited traffic

Previously, we introduced their dedicated server ...

HOSTBD24:$10/year/512MB/5GB SSD space/1TB traffic/OpenVZ/Los Angeles

HOSTBD24, one of the models is now available at a...

Gestion DBI: $4.7/year/256MB memory/20GB space/500GB traffic/OpenVZ/Los Angeles

Gestion DBI, stable merchant, and excellent servi...

Eleven2 latest discount code

Hosting details: http://www.eleven2.com/shared-ho...