持久化iptables规则

一、对 iptables 作必要的修改;

二、将 iptables 规则保存到文件中:

iptables-save > /etc/firewall.conf

三、新建一个脚本 /etc/network/if-up.d/import-iptables

#!/bin/sh
iptables-restore < /etc/firewall.conf

加上可执行权限:

chmod +x /etc/network/if-up.d/import-iptables

该脚本会在网络接口初始化后自动运行。

posted @ 2023-07-08 11:05  fmcdr  阅读(91)  评论(0编辑  收藏  举报