Operating System - HP-UX
1822196 Members
3777 Online
109640 Solutions
New Discussion юеВ

Re: how to check if the port is open

 
SOLVED
Go to solution
Sunny Jaisinghani
Trusted Contributor

how to check if the port is open

hello Gurus,

Can you please tell me how to check a port if it is open between a server and client.

e.g. i want to check if port 161/UDP is open for server>client.

thanks in advance

sunny
9 REPLIES 9
Raju_S
Frequent Advisor

Re: how to check if the port is open

Hi,

From server give the command

telnet client 161

Regards
chetan a
Advisor

Re: how to check if the port is open

Hi Sunny,

"netstat -a" command will give you fair amoutn of information about Protocol, Recv-Q, Send-Q, Local Address(Local port number), Foreign Address,(state of connection) with respective headers.

Thanks!
Chetan
I can implement the switch, but switch will be risky :-)
Sunny Jaisinghani
Trusted Contributor

Re: how to check if the port is open

hi Chetan,

this is the output of netstat -an

does this mean that port 514/UDP is not open.

$netstat -an | grep 514
tcp 0 0 *.514 *.* LISTEN
udp 0 0 *.514 *.*


thanks
Sunny Jaisinghani
Trusted Contributor

Re: how to check if the port is open

relating to the above post

i executed the command on the server and got the output as mentioned above. i don't have access to the client.
chetan a
Advisor

Re: how to check if the port is open

Hi Sunny,

It means that server is ready to accept connections from any port of client to 514 port on the server.

LISTEN state implies that Server is ready to accept connection. For Port to be in listen state, it should be bound/open. Not that the state information is applicable only to tcp connections.

Suppose a client port(eg: 1234) connects/establishes tcp connection with server on 514 port, the output of the netstat will be as given below,

$netstat -an | grep 514
tcp 0 0 *.514 .1234 ESTABLISHED

Regards,
Chetan
I can implement the switch, but switch will be risky :-)
Sunny Jaisinghani
Trusted Contributor

Re: how to check if the port is open

hi Chetan
thanks for your reply

however can u please tell me how to check it for UDP connection at port 514.
chetan a
Advisor
Solution

Re: how to check if the port is open

Netstat when used with "-a" option will show all connections including passive udp connections used by server processes.

When netstat is used without any options only the active udp connections are shown along with other active connections.
eg:
netstat | grep udp
udp 0 0 onc46.ntp *.*
I can implement the switch, but switch will be risky :-)
rick jones
Honored Contributor

Re: how to check if the port is open

UDP does not have "connections" it only has endpoints.

As for whether a port is "open for server->client" that depends on what you mean by open and whether you are talking about what the server will use as a source port, or what the destination port will be on the client ("destination" from the standpoint of the server)

Netstat can show the ports to which local processes have bound sockets. It will say nothing about what is bound on a remote system, nor will it say anything about any firewalls or other filtering between the server and the client.

there is no rest for the wicked yet the virtuous have no pillows
Sunny Jaisinghani
Trusted Contributor

Re: how to check if the port is open

Thank you Chetan and Rick

Chetan as u said i checked netstat without any options. i did not get any active connections relating to the concerned port.

Rick thanks for the useful information.

Regards
sunny