这是Linux中iptables的一个很好的起点吗?

这是Linux中iptables的一个很好的起点吗?,第1张

概述我是iptables的新手,我一直在尝试组建一个防火墙,其目的是保护Web服务器.以下规则是我到目前为止所组建的规则,我想听听这些规则是否有意义 – 而且我已经遗漏了任何必要的东西? 除了端口80,我还需要为外部连接打开端口3306(mysql)和22(ssh). 任何反馈都非常感谢! #!/bin/sh# Clear all existing rules.iptables -F# AC 我是iptables的新手,我一直在尝试组建一个防火墙,其目的是保护Web服务器.以下规则是我到目前为止所组建的规则,我想听听这些规则是否有意义 – 而且我已经遗漏了任何必要的东西?

除了端口80,我还需要为外部连接打开端口3306(mysql)和22(ssh).

任何反馈都非常感谢!

#!/bin/sh# Clear all existing rules.iptables -F# ACCEPT connections for loopback network connection,127.0.0.1.iptables -A input -i lo -j ACCEPT# ALLOW established trafficiptables -A input -m state --state ESTABliSHED,RELATED -j ACCEPT# DROP packets that are NEW but does not have the SYN but set.iptables -A input -p tcp ! --syn -m state --state NEW -j DROP# DROP fragmented packets,as there is no way to tell the source and destination ports of such a packet.iptables -A input -f -j DROP# DROP packets with all tcp flags set (XMAS packets).iptables -A input -p tcp --tcp-flags ALL ALL -j DROP# DROP packets with no tcp flags set (NulL packets).iptables -A input -p tcp --tcp-flags ALL NONE -j DROP# ALLOW ssh traffic (and prevent against DoS attacks)iptables -A input -p tcp --dport ssh -m limit --limit 1/s  -j ACCEPT# ALLOW http traffic (and prevent against DoS attacks)iptables -A input -p tcp --dport http -m limit --limit 5/s -j ACCEPT# ALLOW MysqL traffic (and prevent against DoS attacks)iptables -A input -p tcp --dport MysqL -m limit --limit 25/s -j ACCEPT# DROP any other traffic.iptables -A input -j DROP
解决方法 试试shorewall,提供开箱即用的合理防火墙.从网络启用对所需服务的访问.有一个,两个和三个接口的示例规则集.文档很好,并且积极维护.

我希望您能够限制哪些地址可以轻松访问MysqL.除非您最近探测过另一个端口,否则您还可以在端口关闭的情况下使用端口敲门来保护SSH.

总结

以上是内存溢出为你收集整理的这是Linux中iptables的一个很好的起点吗?全部内容,希望文章能够帮你解决这是Linux中iptables的一个很好的起点吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1033729.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存