-I INPUT -s 10.195.132.185 -j DROP
-I INPUT -s 10.230.91.2 -j DROP
查看列表
iptables -L
service iptables restart
vi /etc/sysconfig/iptables
centos7
systemctl stop firewalld
systemctl start firewalld
firewall-cmd --list-all
2、临时保存规则
#禁用IP
firewall-cmd --add-rich-rule='rule family=ipv4 source address=10.195.132.185 reject'
firewall-cmd --add-rich-rule='rule family=ipv4 source address=10.230.91.2 reject'
# 删除
firewall-cmd --remove-rich-rule='rule family=ipv4 source address=10.6.8.176 reject'
3. 永久保存规则
当前规则只是在运行时生效,不会永久保留。为了让规则永久生效,需要使用以下命令将规则存储到防火墙的数据库中:
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.195.132.185 reject'
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.230.91.2 reject'
以上命令将规则添加到了permanent区域,表示该规则会在重启后依然保留。如果要删除某个规则,可以使用类似的命令:
firewall-cmd --permanent --remove-rich-rule='rule family=ipv4 source address=192.168.0.1 reject'