1 Star 0 Fork 0

yll1024335892 / shell_script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
iptables_web.sh 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
#/bin/bash
#iptables -t filter -F #情况规则
#iptables -t filter -nvL --line #详细查看所有的规则
#设置当连接状态为RELATED和ESTABLISHED时,允许数据进入服务器
iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#tcp的20,21,22,80,443端口给允许放行
iptables -t filter -A INPUT -p tcp -m multiport --dports 20,21,22,80,443 -j ACCEPT
#允许内部数据循回
iptables -t filter -A INPUT -i lo -j ACCEPT
#允许外部ping服务器
iptables -t filter -A INPUT -p icmp -m icmp --icmp-type 8/0 -j ACCEPT
iptables -t filter -A INPUT -p icmp -m icmp --icmp-type 11/0 -j ACCEPT
#设置状态为RELATED和ESTABLISHED的数据可以从服务器发送到外部
iptables -t filter -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#允许服务器使用外部dns解析域名
iptables -t filter -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT
#出的端口给打开
iptables -t filter -A OUTPUT -p tcp -m multiport --dports 80,443 -j ACCEPT
#允许从服务器ping外部
iptables -t filter -A OUTPUT -p icmp -m icmp --icmp-type 8/0 -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -m icmp --icmp-type 11/0 -j ACCEPT
#centos7要安装iptables-service
#保存规则
service iptables save
#重启防火墙
systemctl restart iptables.service
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/1024335892/shell_script.git
git@gitee.com:1024335892/shell_script.git
1024335892
shell_script
shell_script
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891