查看规则

sudo iptables -L -n -v --line-numbers
sudo iptables -L -n -v --line-numbers | head -n 10

删除第1条

iptables -D INPUT 1

保存规则

sudo service iptables save

前置条件

sudo yum install iptables-services
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl enable iptables
sudo systemctl start iptables

持久化 ipset

# 保存 ipset 配置
sudo ipset save > /etc/ipset.conf
# 启用开机恢复
echo "ipset restore < /etc/ipset.conf" | sudo tee -a /etc/rc.local
# 确保 rc.local 可执行
sudo chmod +x /etc/rc.local

导出规则配置

sudo iptables-save > /root/iptables-backup-$(date +%F).rules

导入规则配置

sudo iptables-restore < /root/iptables-backup-2025-11-29.rules

去掉注释行

sed -i 's/#.*//' /root/iptables-backup-2025-11-29.rules
分类: 默认分类 标签: 暂无标签

评论

-- 评论已关闭 --

目录