Loading

普通用户iptables规则持久化,开机自动恢复

本文档对于docker环境下并不适用,docker环境的iptables持久化请参考https://www.cnblogs.com/wiseo/p/15000745.html

添加iptables规则后使用以下命令进行规则持久化

sudo iptables-save > /home/<用户名>/iptables

设定开机自动恢复iptables规则

# 在开机启动脚本最后添加恢复规则命令
$ sudo vi /etc/rc.d/rc.local
cd /home/<用户名>/iptables
su test && sudo iptables-restore < /home/<用户名>/iptables
# 添加执行权限
$ sudo chmod +x /etc/rc.d/rc.local
# 重启服务器测试
$ sudo reboot
posted @ 2021-07-09 13:40  亚里士多智  阅读(655)  评论(0编辑  收藏  举报