Date

1、放行ip

[root@chenshi ~]# cat firewalladd.sh

#!/bin/bash

read -p "请输入防火墙将要开放的ip:" sourceip

firewall-cmd --zone=public --add-rich-rule "rule family='ipv4' source address=$sourceip accept" --permanent

firewall-cmd --reload

2、恢复

[root@chenshi ~]# cat firewallrecover.sh

#!/bin/bash

#firewall-cmd --list-all|grep address|awk '{print $4}'|awk -F '"' '{print $2}'

firewall-cmd --load-zone-defaults=public --permanent

firewall-cmd --zone=public --add-rich-rule "rule family='ipv4' source address=公司ip accept" --permanent

firewall-cmd --remove-service=ssh --permanent

firewall-cmd --reload

Comments