SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 309357
Accepted
Davie
Davie
Asked: 2009-10-09 01:57:50 +0800 CST2009-10-09 01:57:50 +0800 CST 2009-10-09 01:57:50 +0800 CST

Ping a Specific Port

  • 772

Just a quick sanity check here.

Can you ping a specific port of a machine, and if so, can you provide an example?

I'm looking for something like ping ip address portNum.

ping
  • 18 18 Answers
  • 2708720 Views

18 Answers

  • Voted
  1. Best Answer
    sfussenegger
    2009-10-09T02:00:00+08:002009-10-09T02:00:00+08:00

    You can't ping ports, as Ping is using ICMP which is an internet layer protocol that doesn't have ports. Ports belong to the transport layer protocols like TCP and UDP.

    However, you could use nmap to see whether ports are open or not

    nmap -p 80 example.com
    

    Edit: As flokra mentioned, nmap is more than just a ping-for-ports-thingy. It's the security auditers and hackers best friend and comes with tons of cool options. Check the doc for all possible flags.

    • 824
  2. Pipo
    2009-10-09T02:01:02+08:002009-10-09T02:01:02+08:00

    Open a telnet session to the specific port, for example:

    # telnet google.com 80
    Trying 74.125.226.48...
    Connected to google.com.
    Escape character is '^]'.
    

    To close your session, hit Ctrl+].

    • 218
  3. Kjetil Limkjær
    2014-10-27T13:09:23+08:002014-10-27T13:09:23+08:00

    If you're on a windows installation with powershell v4 or newer, you can use the test-netconnection powershell module:

    Test-NetConnection <host> -port <port>
    

    Example: Test-NetConnection example.com -port 80

    This cmdlet also has the alias tnc. Eg tnc example.com -port 80

    • 153
  4. Rahul Patil
    2013-04-10T17:55:46+08:002013-04-10T17:55:46+08:00
    $ nc -vz google.com 80
    Connection to google.com 80 port [tcp/http] succeeded!
    
    • 121
  5. CodhubIV
    2010-09-03T20:23:37+08:002010-09-03T20:23:37+08:00

    You can use PaPing:

    http://code.google.com/p/paping

    C:\>paping.exe www.google.com -p 80 -c 4
    paping v1.5.1 - Copyright (c) 2010 Mike Lovell
    
    Connecting to www.l.google.com [209.85.225.147] on TCP 80:
    
    Connected to 209.85.225.147: time=24.00ms protocol=TCP port=80
    Connected to 209.85.225.147: time=25.00ms protocol=TCP port=80
    Connected to 209.85.225.147: time=24.00ms protocol=TCP port=80
    Connected to 209.85.225.147: time=24.00ms protocol=TCP port=80
    
    Connection statistics:
            Attempted = 4, Connected = 4, Failed = 0 (0.00%)
    Approximate connection times:
            Minimum = 24.00ms, Maximum = 25.00ms, Average = 24.25ms
    
    • 84
  6. kenorb
    2015-11-01T16:11:59+08:002015-11-01T16:11:59+08:00

    Try curl command, like:

    $ curl host:port
    

    For example:

    $ curl -s localhost:80 >/dev/null && echo Success. || echo Fail.
    Success.
    

    Above command will return Fail on a non-zero exit status codes. In some particular cases, such as empty or malformed response (see man curl), you may want to handle specific exit codes as successful, so please check this post for more detailed explanation.

    • 37
  7. Martin B
    2009-10-09T02:00:36+08:002009-10-09T02:00:36+08:00

    No, you can't, because ping uses the ICMP protocol, which doesn't even have a concept of ports.

    • 30
  8. Ayan Mullick
    2014-12-13T11:49:13+08:002014-12-13T11:49:13+08:00

    I found a simpler solution using PsPing:

    psping 192.168.2.2:5000
    

    It's part of Windows Sysinternals.

    PsPing implements Ping functionality, TCP ping, latency and bandwidth measurement.

    • 27
  9. c4f4t0r
    2013-12-23T15:12:44+08:002013-12-23T15:12:44+08:00

    On Linux you can use hping but it uses TCP, rather than ICMP.

    hping example.com -S -V -p 80
    
    • 18
  10. Rob
    2009-10-09T02:06:28+08:002009-10-09T02:06:28+08:00

    Ping is very specific but if you want to check whether a port is open or not, and are running a Windows box then PortQry is your friend.

    I've only used it for testing Domain Controllers for connectivity issues, but it worked a treat for that, so should work for you.

    • 11

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Resolve host name from IP address

    • 8 Answers
  • Marko Smith

    How can I sort du -h output by size

    • 30 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What's the command-line utility in Windows to do a reverse DNS look-up?

    • 14 Answers
  • Marko Smith

    How to check if a port is blocked on a Windows machine?

    • 4 Answers
  • Marko Smith

    What port should I open to allow remote desktop?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    Deepak Mittal How to run a server on port 80 as a normal user on Linux? 2008-11-11 06:31:11 +0800 CST
  • Martin Hope
    MikeN In Nginx, how can I rewrite all http requests to https while maintaining sub-domain? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 What is the difference between double and single square brackets in bash? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch How do I change my private key passphrase? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt How does IPv4 Subnetting Work? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve