Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If I would like to confirm a port eg . port 111 is open to connect or not , I just use "netstat -na" to find it , if it is in "Listen" , then means it is open ?
or if I "telnet localhost 111" , if it pops the below message , then mean it is opened ?
Code:
Trying ::1...
Connected to localhost.
Escape character is '^]'.
"port open" usually means that no firewall blocks it. When a port is blocked by a firewall, all attempts to connect to it will simply be ignored.
The firewall can be on your server. You can check with the iptables command or, if your distro deploys it, firewall-cmd.
The firewall can be around your server, for example using a firewall appliance or, in an Amazon or OpenStack cloud, using security groups. I don't know of a method to check this from the server.
From outside, a command like telnet or nc can tell you if the port is open. In your example however, you use telnet on the same server as the port. You confirm that a process is listening on port 111, but you don't confirm whether the port is blocked. You have to run telnet or nc from a remote system to confirm this.
If your telnet or nc connection attempt succeeds, you know that the port is open and a process is listening.
If you get "connection refused", you know that the port is open but no process listens.
If you get a message like "no route to host", the server is either not accessible at all (it may be down or there is literally no route to it) or that particular port is blocked. You can then use a tool like ping to check if there is any connectivity.
I am sure nmap is also useful for such tests, but I don't know how to use it in this context.
in general: if there was a program running on the system which is listening on that port (=waiting for some kind of data) we used to say the port is open.
But it is not that trivial, because we can have firewalls, proxy servers, port mapping and other tricks which may make that port unavailable or available (depending on their config/usage). So port is opened does/may not mean it is reachable from another host.
Sorry, but this is a VERY bad bit of advice; why would anyone go to an unknown website and run something to scan their system for open ports?? You're advertising to some unknown parties what your IP address is, what ports/services are running, etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.