运维

Debian/Ubuntu/deepin-shell脚本来管理iptables安全策略

MarginNote 3 - Mac端PDF阅读批注工具 激活码价格:¥69.00
赤友 NTFS for Mac 助手 -  磁盘硬盘格式读写软件注册激活码价格:¥35.00
虫洞 -  iPhone安卓投屏操控 电脑手机多屏协同,价格:¥45.00
namesilo全网最便宜域名注册商,输入折扣码:nsilo20立减1美元!

前言
在Centos上都有iptables-services或者firewalld等iptables管理工具。那在Debian系列用什么管理工具呢?
Debian/Ubuntu/deepin-shell脚本来管理iptables安全策略
使用Debian
Debian安装完以后,要设置安全策略,发现没有iptables-services管理工具,What?好吧!只能找找有什么工具,发现有一个ufw。不是没有管理工具,只是我不会用。
Debian/Ubuntu/deepin-shell脚本来管理iptables安全策略
shell脚本管理
Debian/Ubuntu/deepin-shell脚本来管理iptables安全策略
ufw用不惯就不强求,自己写个脚本来解决:

#!/bin/bash
source /etc/profile
function save(){
iptables-save > /etc/iptables.rules
}
function restart(){
iptables-restore < /etc/iptables.rules
}
function stop(){
iptables -t nat -F
iptables -t nat -X
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P INPUT ACCEPT
iptables -t mangle -P FORWARD ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
iptables -t mangle -P POSTROUTING ACCEPT
iptables -F
iptables -X
iptables -P FORWARD ACCEPT
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t raw -F
iptables -t raw -X
iptables -t raw -P PREROUTING ACCEPT
iptables -t raw -P OUTPUT ACCEPT
}
if [ "$1" == "save" ]
then
save
elif [[ "$1" == "reload" || "$1" == "restart" ]]
then
restart
elif [[ "$1" == "stop" ]]
then
stop
else
echo "$0 [save|restart|reload|stop]"
fi
(0)

本文由 podipod软库网 作者:DevOps 发表,转载请注明来源!

ToDesk - 安全好用流畅远程控制软件 替代TeamViewer,价格:¥108.00
Eagle - 图片收集管理必备软件 激活码价格:¥119.00
PDF Expert 2 - Mac上优秀的PDF阅读编辑工具,价格:¥119.00

热评文章

发表评论