@
zuolan 多谢分享~
第一种情况在 source ~/.bashrc 的时候就运行命令了,而不是我在输入 ninja_f2b_all_ban_ip 的时候。
第二种情况也不行,因为$5 总是 0.0.0.0
样本是这样的:
REJECT all -- 96.239.28.45 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 59.45.175.67 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 59.45.175.97 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 221.194.47.242 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 94.23.32.200 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 89.234.157.254 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 86.88.193.96 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 86.201.8.190 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 72.14.182.209 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 59.63.166.104 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 59.49.38.210 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 59.45.175.98 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 59.45.175.24 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 58.218.198.144 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 52.168.148.108 0.0.0.0/0 reject-with icmp-port-unreachable
最后我找了个 function 的方式,
function ninja_f2b_all_ban_ip() {
sudo iptables -L -n | awk '$1=="REJECT" && $4!="0.0.0.0/0"'
}