Opening a port on Ubuntu

跟風遠走 提交于 2021-02-07 10:19:56

问题


I am trying to open up port on my Ubuntu machine to allow me to connect the Mongo using an external program. I ran this which is the command line to open a new port:

sudo iptables -A INPUT -p tcp --dport 27017 -j ACCEPT

but when I ran this to check if the new rule was there...

sudo netstat -ntlp | grep LISTEN

...the new port wasn't in the list - any ideas?


回答1:


I think the mangodb instance was not started, apart from that ,sudo netstat -ntlp | grep LISTEN gives the list ports that are active are being used now, first start your Mango instance sudo service mongodb start , then run this command sudo netstat -ntlp | grep LISTEN if you find 27017 in the list, then sudo iptables -L chack your iptable rule is added or not. If it is in that list good else, sudo iptables -A INPUT -p tcp --dport 27017 -j ACCEPT you can get more details on mangodb port and traffic @ http://docs.mongodb.org/manual/tutorial/configure-linux-iptables-firewall/




回答2:


In this case the Mongo config file needed updating to use port 27017. Once I had done this and restarted the service, the new port change was visible on in the list.



来源:https://stackoverflow.com/questions/28788740/opening-a-port-on-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!