!/bin/bash
systemctl status xxxx -l > /tmp/ip.txt
$IP=(egrep -o '([0-9]{1,3}.){1,3}[0-9]{3}' /tmp/ip.txt >/tmp/ip_block.txt)
firewall-cmd --add-rich-rule="rule family="ipv4" destination address="$IP" reject"
firewall-cmd --add-rich-rule="rule family="ipv4" destination address="$IP" reject" --per
firewall-cmd --reload
用这个脚本想自动屏蔽非法IP时,提示如图错误,求解?
修改后的代码如下