All credit to Matt Wilcox for this excellent article, for which this post is based – thank you, Matt! https://mattwilcox.net/web-development/unexpected-ddos-blocking-china-with-ipset-and-iptables/ All commands run as root!
1
2
3
4
yum install-yipset
vi blockchina(see below forcontents)
chmod755blockchina
./blockchina
Do this once only:
1
iptables-AINPUT-ptcp-mset--match-set china src-jDROP;service iptables save
Then add blockchina to the root cron
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
#
# blockchina
#
DIR=/etc
# Create the ipset list
ipset-Nchina hash:net
# remove any old list that might exist from previous runs of this script
Step 1. Execute the following two commands: postconf -e smtpd_sender_restrictions=pcre:/etc/postfix/rejected_domains postconf -e reject_unauth_destinations=pcre:/etc/postfix/rejected_domains If that doesn’t work, you may hand-edit main.cf and add/edit these lines:
The do/while statement is sometimes used to break out of a block of code when an error condition occurs. For example:
1
2
3
4
5
6
do{
// do some stuff
if($error_condition)
break;
// do some other stuff
}while(false);
Because the condition for the loop is false, the loop is executed only once, regardless of what happens inside the loop. However, if an error occurs, the code after the break is not […]