Thursday, July 10, 2008

netstat (UNIX and Windows)

Use netstat -an to see what sockets are defined on a host. A socket can either be LISTENING or ESTABLISHED.



Tips and tricks
You can search for specific port numbers or IP numbers using find (under Windows) or grep (under Unix). E.g.:
D:\>netstat -an |find "139"
TCP 160.124.19.99:139 0.0.0.0:0 LISTENING

TCP 160.124.19.99:139 160.124.19.100:1069 ESTABLISHED

TCP 160.124.19.99:1180 160.124.19.98:139 ESTABLISHED

TCP 160.124.19.99:1186 160.124.19.98:139 ESTABLISHED

TCP 160.124.19.99:3015 160.124.19.98:139 ESTABLISHED

/etc/mail# netstat -an |grep 23

tcp4 160.124.19.98.2884 196.35.241.75.23 ESTABLISHED

tcp4 160.124.19.98.23 160.124.19.99.3589 ESTABLISHED

tcp4 160.124.19.98.2305 196.25.210.248.80 FIN_WAIT_2

tcp4 *.23 *.* LISTEN

If a TCP socket is defined for a specific port number, then you should be able to telnet to that port on the host. E.g.
/etc/mail# telnet 160.124.19.99 139
Trying 160.124.19.99...

Connected to gridcraft.

Escape character is '^]'.

If you use a MS client, the IP address or name of the server will appear at the top of the window if a connection is established:

0 comments:

Post a Comment

 

Subscribe in Bloglines Msn bot last visit powered by MyPagerank.Net Yahoo bot last visit powered by MyPagerank.Net
I heart FeedBurner downtime checker The Ubuntu Counter Project - user number # 31290

 
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by TadPole
FOG FLAMES