对于网络攻击或者挖矿病毒,常常敌方是采用动态ip代理来进行数据信息中转的,因此无法通过查杀ip的手段来对其进行防御。另外,这类ip代理大多为外网服务器,如果是国内的代理,可以进行立案或者进行ip追溯,比较容易找到敌方信息。因此我们考虑封禁所有外网ip对主机的主动访问连接
自行下载参考链接:
linux命令下载
wget http://www.ipdeny.com/ipblocks/data/aggregated/cn-aggregated.zone | mv cn-aggregated.zone china_ip_list.txt
- #!/bin/bash
- ip=$(cat china_ip_list.txt)
- for ipna in $ip
- do
- echo "ufw allow from $ipna" >> rule_any_china_ip.sh
- done
sudo bash test.sh
sudo nohup bash rule_any_china_ip.sh &
netstat -nat
使用dsniff命令断开外网的连接,流程完成。
附件:
sudo ufw status numbered
大约添加了6000多个规则

生成规则例子
- ufw allow from 1.0.1.0/24
- ufw allow from 1.0.2.0/23
- ufw allow from 1.0.8.0/21
- ufw allow from 1.0.32.0/19
- ufw allow from 1.1.0.0/24
- ufw allow from 1.1.2.0/23
- ufw allow from 1.1.4.0/22
- ufw allow from 1.1.8.0/21
- ufw allow from 1.1.16.0/20
- ufw allow from 1.1.32.0/19
- ufw allow from 1.2.0.0/23
- ufw allow from 1.2.2.0/24
- ufw allow from 1.2.4.0/22
- ufw allow from 1.2.8.0/21
- ufw allow from 1.2.16.0/20
- ufw allow from 1.2.32.0/19
- ufw allow from 1.2.64.0/18
- ufw allow from 1.3.0.0/16
- ufw allow from 1.4.1.0/24
- ufw allow from 1.4.2.0/23
- ufw allow from 1.4.4.0/22
- ufw allow from 1.4.8.0/21
- ufw allow from 1.4.16.0/20
- ufw allow from 1.4.32.0/19
- ufw allow from 1.4.64.0/18
- ufw allow from 1.8.0.0/16
- ufw allow from 1.10.0.0/21
- ufw allow from 1.10.8.0/23
- ufw allow from 1.10.11.0/24
- ufw allow from 1.10.12.0/22
- ufw allow from 1.10.16.0/20
- ufw allow from 1.10.32.0/19
- ufw allow from 1.10.64.0/18
- ufw allow from 1.12.16.0/20
- ufw allow from 1.12.32.0/23
- ufw allow from 1.12.36.0/22
- ufw allow from 1.12.40.0/21
- ufw allow from 1.12.48.0/20
- ufw allow from 1.12.64.0/18
- ufw allow from 1.12.128.0/17
- ufw allow from 1.13.0.0/16
- ......