安全的iptables防火墙配置(只开通SSH,WEB,DNS服务)

发布时间:2020-07-20 05:27:33 作者:showerlee
来源:网络 阅读:25286
 
iptables -F 清空所有规则链
iptables -X 删除特定手工设置的链
iptables -Z 清空计数器
iptables -P INPUT DROP //默认INPUT规则 丢弃
iptables -P OUTPUT DROP //默认OUTPUT规则 丢弃
iptables -P FORWARD DROP //默认FORWARD规则 丢弃
iptables -A INPUT -d 192.168.10.250 -p tcp -m tcp --dport 22 -j ACCEPT //开SSH服务进站端口
iptables -A INPUT -d 192.168.10.250 -p tcp -m tcp --dport 80 -j ACCEPT //开WEB服务进站端口
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT //允许本地环回数据
iptables -A INPUT -p udp -m udp --sport 53 -j ACCEPT  //来自远程DNS服务器53端口的数据包进站通过
iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT  //进入本地服务器53端口的数据包进站通过
iptables -A INPUT -d 192.168.10.250 -p icmp -j ACCEPT //ICPM数据包可进入本地服务器
         
iptables -A OUTPUT -s 192.168.10.250 -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT //对SSH的服务进入的数据包开启出站端口
iptables -A OUTPUT -s 192.168.10.250 -p tcp -m tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT //对WEB的服务进入的数据包开启出站端口
iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT //允许本地环回数据
iptables -A OUTPUT -p udp -m udp --sport 53 -j ACCEPT  //从本地53端口出站的数据包出站通过
iptables -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT  //去往远程DNS服务器53端口的数据包出站通过
iptables -A OUTPUT -s 192.168.10.250 -p icmp -j ACCEPT //对对方ICMP数据包回应(ping命令回应数据包)
service iptables save //保存配置信息
service iptables start //开启防火墙服务
推荐阅读:
  1. Linux下防火墙iptables原理及实战
  2. 【Firewalld(Iptables)】

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

安全 防火墙 iptables

上一篇:OPC UA SDK 开发包使用说明

下一篇:PHP求周岁

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》