Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In Windows, I go to command line and 'telnet ' to check the port. How to do the same in Unix?

It seems some people using 'tcpdump port ' commands. Is this monitoring the real time traffic? Thanks.

share|improve this question
    
nmap –  Zoredache Jul 15 '10 at 0:18
    
FYI if you ever have occasion to actually send data to a remote host and/or receive a response back, Linux/Unix has netcat which you can use in place of telnet for that. –  David Z Jul 15 '10 at 4:31
    
Also, and I'm sad I don't see it in the comments section here, Unix has telnet too. –  Slartibartfast Jul 15 '10 at 5:02
    
Thanks everyone, all answers have been really helpful. My last question is what tool is 'tcpdump port' commands in Unix? –  Stan Jul 15 '10 at 18:50
add comment

3 Answers

up vote 10 down vote accepted

nmap is a great general-purpose tool for such things and much else.

nmap host.domain.tld (or nmap host for a local machine, or nmap <ipaddr> to check a machine by address not name) will list what common ports are open.

nmap 192.168.23.1-254 -p 22,80,443 will scan a range of hosts by address to see if the TCP ports usually associated with SSH, HTTP and HTTPS are open.

See man nmap for many more options - it is the kitchen sink of network checking tools.

You may not have nmap installed at the moment, but it is in just about all distros standard repositories. For debian or ubuntu variants aptitude install nmap to install it, or find it in the GUI package manager of your choice. If it isn't available easily on your system, get it and more info from http://nmap.org/

You could also just use the same telnet client technique that you are already familiar with as that is available too and usually installed in one of the default packages, but nmap is a tool worth getting to know as it can be helpful for diagnosing network issues, just checking that things are as they should be, and so on. There are also a few decent graphical front-ends to it, if you would prefer to interact with it away from the command line.

share|improve this answer
2  
+1 nmap is way better than telnet for this task. –  David Z Jul 15 '10 at 4:30
add comment

If you're using bash, then the man pages state that you could write to /dev/tcp/HostNameOrIP/port. I've used this a few times and if the remote port is open, then there is no response. If the system cannot connect to the remote port, then it states the reason

[kevin@box ~]$ echo -n > /dev/tcp/www.yahoo.com/80
[kevin@box ~]$ nslookup www.no-such-domain.com
Server:         127.0.0.1
Address:        127.0.0.1#53

** server can't find www.no-such-domain.com: NXDOMAIN

[kevin@box ~]$ echo -n > /dev/tcp/www.no-such-domain.com/80
-bash: www.no-such-domain.com: Name or service not known
-bash: /dev/tcp/www.no-such-domain.com/80: Invalid argument
[kevin@box ~]$ echo -n > /dev/tcp/192.168.3.3/80    #no such server on my network
-bash: connect: No route to host
-bash: /dev/tcp/192.168.3.3/80: No route to host
[kevin@box ~]$ echo -n > /dev/tcp/192.168.3.1/88    #nothing listening on port 88
-bash: connect: Connection refused
-bash: /dev/tcp/192.168.3.1/88: Connection refused
[kevin@box ~]$
share|improve this answer
    
I wouldn't advise to rely on this trick, because at least debian bash packages have this feature stripped off. –  halp Jul 15 '10 at 1:40
    
Which is why I grumble at systems whose man pages say this works, but then I get 'no such file or directory'. –  Kevin M Jul 24 '10 at 0:11
add comment

You can use telnet on a *nix machine, too.

share|improve this answer
    
+1 - there's even an SSL capable variant. –  sybreon Jul 15 '10 at 6:10
    
@sybreon - I was not aware of that.. who provides it? –  warren Jul 15 '10 at 11:10
1  
You can download the Debian package or the source code from packages.debian.org/lenny/telnet-ssl –  sybreon Jul 16 '10 at 13:20
    
cool - I'll look into it –  warren Jul 16 '10 at 19:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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