Test if port is open, even if nothing there to respond?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
Test if port is open, even if nothing there to respond?
Hi Guys,
This might be a dumb question, but is it possible to test if a remote port is open, even if there is nothing there to respond to it?
For example a command like "telnet mydomain.com 80" will usually receive a response from an Apache server. What if I shut it down? Is there a way to validate it's a least open by connecting from a remote machine?
This doesn't make sense, the port is not open if there is nothing there. You'll see the same as if iptables was rejecting packets. Mind you, maybe that is enough for you if you would expect a firewall to drop silently rather than reject. The reciept of a TCP RESET packet does generally identify that the system exists.
The use of the term 'open' in this scenario seems to lead to all sorts of confusion. There isn't any 'gate' or other such obstacle that stops or enables traffic. A port that is 'open' is simply a port to which a process has bound, and is listening for a connection request. No listener = not open. Simple.
The telnet(1) test is fine; there are a couple other, more refined utilities as well. nmap(1), nc(1), and hping(1) all do a great job.
Example with nmap:
Code:
$ nmap -PN foo.local -p 80
If a tcp handshake is established, nmap says "open". If a tcp RST is received, nmap says "closed". If no reply is received, nmap says "filtered".
THANK YOU... You hit the nail on the head Anomie.
And I don't think the term "open" is a misnomer here. I'm testing connectivity to a port lying beyond several complex hardware firewalls and subnets. I would have said "accepting connections" if I was concerned with the program running underneath it.
it definitely IS a misnomer. Open = accepting connections.
Agree completely. An open port is one with a listening daemon that can accept connections. A closed port is one with no listening process. The connection will either be refused or if you have a decent firewall totally ignored.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.