linux – 使用iptables保护mongodb端口
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux – 使用iptables保护mongodb端口,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1989字,纯文字阅读大概需要3分钟。
内容图文
这是我的iptables配置:
sudo iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo any anywhere anywhere
859 103K ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
5 260 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh
3 230 ACCEPT tcp -- any any anywhere anywhere tcp dpt:27017
4 208 ACCEPT tcp -- any any anywhere anywhere tcp dpt:28017
0 0 ACCEPT all -- any any localhost anywhere
0 0 ACCEPT all -- any any 111.111.111.111 anywhere
0 0 ACCEPT all -- any any 222.222.222.222 anywhere
64 3844 DROP all -- any any anywhere anywhere
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 764 packets, 227K bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- any any localhost anywhere
0 0 ACCEPT all -- any any 111.111.111.111 anywhere
0 0 ACCEPT all -- any any 222.222.222.222 anywhere
如果我在浏览器中写入ip,如果我的mongodb服务器端口为28017,我可以看到一个promt输入用户名和密码:
#ip mongodb server
000.000.000.000:28017
我希望除了这两个ips以外的任何人都有接近mongodb的端口:
111.111.111.111
222.222.222.222
我该怎么做?
解决方法:
你能尝试以下iptables规则吗?
-A INPUT -m state --state NEW -p tcp --destination-port 27017 -s 111.111.111.111 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --destination-port 27017 -s 222.222.222.222 -j ACCEPT
看起来你忘了放入源IP标志.
内容总结
以上是互联网集市为您收集整理的linux – 使用iptables保护mongodb端口全部内容,希望文章能够帮你解决linux – 使用iptables保护mongodb端口所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。