The VPS server blocks the IP address of a certain country from accessing the one-click script

888u

Last update at :2024-02-08,Edit by888u

Recently, some foreign IPs have been posting spammy external link comments to bloggers. There are a lot of them every day. I was thinking about how to only allow users from mainland China to access the website. After some searching, I found a way to directly block them. A script for a certain country can be blocked by blocking the IP of the country that sends spam comments. Let’s share the installation tutorial of this script.

Suitable for system

This tutorial is suitable for common Linux series systems such as Centos, Ubuntu, and Debian.

Script address

GitHub address: https://github.com/iiiiiii1/Block-IPs-from-countries

Installation tutorial

Download script

wget https://raw.githubusercontent.com/iiiiiii1/Block-IPs-from-countries/master/block-ips.sh

Give script execution permissions

chmod +x block-ips.sh

Run script

./block-ips.sh

Graphic tutorial

Download running process: Enter 1 and press Enter. When banning an IP for the first time, the IP list will be downloaded first and just wait. After downloading, you will be prompted to enter the country code to be banned. Note that it must be lowercase here! ! ! Just press Enter after completing the input.

Check the country code: http://www.ipdeny.com/ipblocks/

When unblocking, re-run the script and select Unblock.

Recommended site search: registered domain names, US server rental, io domain name registration, US server, mobile server rental, ICP quick registration, online IP check, server space rental, virtual host ranking, free cn domain name registration,

p>

The VPS server blocks the IP address of a certain country from accessing the one-click script

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码