当前位置: 首页 > 科技观察

Deepin管理Iptables的脚本

时间:2023-03-15 23:25:03 科技观察

介绍。我习惯在CentOS上使用iptables,把它当做一个服务来管理,但是Debian上没有对应的脚本,所以需要自己手动制作一个。服务文件现在基本都由systemd管理,可以直接编辑服务文件进行管理。sudovim/usr/lib/systemd/system/iptables.service[Unit]Description=iptablesrulesserviceAfter=network.target[Service]Type=oneshotExecStart=/usr/sbin/iptables-restore/etc/iptables.rulesExecReload=/usr/sbin/iptables-restore/etc/iptables.rulesExecStop=/usr/sbin/iptables-PINPUTACCEPTExecStop=/usr/sbin/iptables-FRemainAfterExit=yes[Install]WantedBy=multi-user.target加载文件sudosystemctldaemon-reloadsudosystemctlenableiptablessudosystemctlstartiptablessudoctlreload只在这里保存配置文件控制服务的启动、重新加载和关闭,不能保存配置文件。配置文件可以直接通过命令保存。/usr/sbin/iptables-save-f/etc/iptables.rules