Skip to content

Eternal Center

  • System (系统)
  • Services (服务)
  • Databases (数据库)
  • Clusters (集群)
  • Big Data (大数据)
  • Cloud Computing (云计算)
  • Languages (语言)
  • Project (项目)
  • Writings (写作)
  • Eternity (永恒)
  • News (消息)
  • Chronicle (编年史)
  • Words (言)
Posted on April 25, 2022April 25, 2022 by Mingyu Zhu

[内容] iptables 防火墙规则持久化 (让防火墙规则开机自启)

内容一:Rocky Linux & RHEL iptables 防火墙规则持久化

# service iptables save

内容二:Rocky Linux & RHEL 和 openSUSE & SUSE iptables 防火墙规则持久化
2.1 导出现在 iptables 防火墙的规则

# iptables-save > /root/iptables_save

(补充:这里以将 iptables 防火墙规则导出到 /root/iptables_save 文件为例)

2.2 创建用于加载 iptables 防火墙规则的 systemctl 管理文件

# vim /etc/systemd/system/iptables_save.service

创建以下内容:

[Unit]
Description=iptables_save
After=default.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-restore < /root/iptables_save

[Install]
WantedBy=default.target

(补充:这里以创建 systemctl 管理文件 /etc/systemd/system/iptables_save.service 将 /root/iptables_save 文件里的内容导入到 iptables 防火墙为例)

2.3 加载刚刚创建的 systemctl 管理文件

# systemctl daemon-reload

2.4 给刚刚创建的 systemctl 管理文件添加执行权限

# chmod u+x /etc/systemd/system/iptables_save.service

(补充:这里以给 systemctl 管理文件 /etc/systemd/system/iptables_save.service 添加执行权限为例)

2.5 让防火墙规则开机自启

# systemctl enable iptables_save.service

(补充:这里以开机自启 iptables_save.service 服务为例)

CategoriesChinese (中文), System (系统), System Firewall (系统防火墙), System Login Security (系统登录安全), System Network (系统网络), System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志), System Port Security (系统端口安全), System Security (系统安全)

Post navigation

Previous PostPrevious [内容] iptables 防火墙规则的导出和导入
Next PostNext [步骤] Red Hat Satellite 打补丁或升级

Aspiration (愿景):

Everyone can achieve self achievement and self happiness fairly

每个人都能公平地实现自我成就和自我幸福

Position (位置):

Running on Evolution Host and DigitalOcean

正在 Evolution Host 和 DigitalOcean 上运行

Logo (徽标):

Additional Information (其他信息):

About Manual Clone Contact Disclaimer Donation Friendly Links 关于 说明书 克隆 联系 免责申明 捐赠 友情链接

Standby IP Address (备用 IP 地址):

152.69.204.95  150.230.63.10  Please configure before use / 请先配置再使用

Search Outside Website (站外搜索):

Google Wikipedia Bing
Proudly powered by LNMP Proudly powered by WordPress