Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 09-01-2008, 02:36 AM   #1
LQ Newbie
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
Post How to ping a device using port number ?


Is there any command/utility which would help me to ping a network device from solaris box by providing port number as the argument along with the ipaddress.

I tried the following :

/usr/sbin/ping -p <port> <ipaddress>

But this dint work.

Requirement :

I am using an application which would be doing provisioning of some services on a network device. This application works on Sun Solaris.
This application would access the network device using a user mentioned free port. Hence I need to know if the device is accessible on that particular port.
Old 09-01-2008, 02:42 AM   #2
Senior Member
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,189

Rep: Reputation: 49
Ping uses ICMP. and the connection you are trying to do would normally be a TCP/UDP. To know if the port is open either use nmap or a similar tool.

nmap -p port ipaddress (for tcp)
nmap -sU -p port ipaddress (for udp)
Old 09-01-2008, 03:41 AM   #3
Senior Member
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
If you're writing an application to do this, why wouldn't you just use the socket API to attempt to communicate over the given port? If it's accepted, you know the port is in use. If it times-out, it's being blocked by a firewall. If the connection is refused, you know it's not in use.

Of course, this only works for TCP. You can see if UDP packets are refused, but if they aren't refused it could be either because they were accepted, or because a firewall blocked them.

On the other hand, if you're checking to see whether your service is listening, why wouldn't you just build a test function into it that would respond to a status query?
Old 09-01-2008, 04:01 PM   #4
LQ Newbie
Registered: May 2004
Location: Brazil
Distribution: Debian
Posts: 7

Rep: Reputation: 0
You may have a look at tcptraceroute package as well. It's an interesting implementation of traceroute where you can choose a tcp/udp port to trace.

For example:

traceroute -p 80
Old 02-08-2012, 10:02 AM   #5
LQ Newbie
Registered: Feb 2012
Posts: 1

Rep: Reputation: Disabled
I think the answers do not hit the original Q

harisudhan originally asked if there was an external ping method
remote terminal inquires if a server is up ,

there is a new thread and the method is to use TELNET to the port
and if you do not get a timeout response, its a good sign the (remote)
port is responding (with something), i.e. "TELNET aaa.bbb.ccc.ddd 80<CR>"

icmp, tracert, port activity all aside as they don't help to t-shoot that remote
Old 02-08-2012, 12:29 PM   #6
LQ Newbie
Registered: Feb 2012
Location: Moscow
Distribution: Gentoo
Posts: 2

Rep: Reputation: Disabled
You can use hping utility for the task you need:

hping -s $port $target_hostname

You may use both udp and tcp with different flags set.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how finding out the device port number? hoshangi Linux - Desktop 1 11-19-2007 07:39 AM
USB to serail port adaptor COM port number areftaidi Linux - Software 2 09-25-2007 01:05 AM
Parallel Port & Serial Port device identification helpmeforlinux Linux - Hardware 3 01-02-2007 01:15 AM
ttl number in ping result. bruse Linux - Networking 2 11-17-2005 07:34 AM
Port number.... help rajsun Programming 2 04-12-2005 09:20 AM

All times are GMT -5. The time now is 04:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration