7

I've written a program that is suppose to implement SLP (rfc2608) and I'm having trouble testing it. I'm not sure if the port is closed or there is something out there dropping my multicast datagrams. Is there a command I can run from a redhat terminal to tell me if a port is open on that box?

I've seen some posts on simply telneting to the port, etc..., but that only works for TCP ports, right? I've also read that there are sites that can test this sort of thing from the outside. But I really don't want to do that since I'm not interested in a full port scan, the box is on a private network, and even if it wasn't, I don't want it to look like a security incident is going on. I simply want to query and see if port 427 is open.

7

Hmm. Multicast, so telnet isn't going to work.

You can run tcpdump, I think, to see if traffic is getting to your server. Run something like this on your server:

tcpdump -i eth0 port 427 and see if anything shows up.

If nothing does, there's some sort of block elsewhere.

Check your local firewall with something like iptables -L -n to make sure the INPUT chain permits your traffic.

To further diagnose, you may need to start running traceroutes from your laptop, specifying the protocol and port (otherwise, it'll default to ICMP).

  • I like the idea of using trace route. Unfortunately, trace route for windows isn't as functional as I need it to be. The iptables command helped quite a bit. If I'm reading it right, it looks like I'm not running a firewall on this box, so something is happening on one of the routers or the TTL is too short. – Jason Thompson Apr 10 '12 at 14:57
4

Hmm, netstat -anp | grep 427 would do the trick. Maybe lsof -i | grep 427 as well.

To check from an outside linux host, you can use nmap. Perhaps nmap -sT -p 427 or nmap -sU -p 427 (for UDP).

  • 1
    Thanks. I'm able to see that my app is listening, I'm just unable to check if the port is being blocked by the firewall. – Jason Thompson Apr 10 '12 at 14:33
  • Do you have iptables enabled? – ewwhite Apr 10 '12 at 14:56
1

netstat locally and nmap on a remote host.

I often use

netstat -plunt

and

netstat -ant

to get a picture of what is going on.

  • 1
    netstat seems to show me what ports are listening and what connections are established, but how do I know if a port is actually open? When I run my application, I see that it's listening, I just can't communicate with it from my laptop to the server (about 4 hops). I'm interested in what the cause of this lack of communication is. Is the port blocked or are my datagrams being dropped? – Jason Thompson Apr 10 '12 at 14:27
1

I am guessing that by port open you mean it's not blocked by the firewall. In that case you can run the following command on the host machine (incase of redhat/centos 7):

firewall-cmd --list-ports | grep -w <Port No.>

In case of redhat6/centos6 , you can execute

iptables --list-rule | grep -w <Port No.>

I hope this helps..

-3

When a port is in the listening state, it means that it is ready and waiting for a connection to be established.

Your application has to be making use of the port at that particular point in time before the port can then be in the connection 'ESTABLISHED' state

To sum it up, the port being in the listening state is a good\positive result.

I hope this helps you understand better..

  • This does indicate if an application is listening on the port, but not if it is open on the host firewall – Thomas Berger Nov 9 '17 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.