My remote Linux machine is able to ping an IP address on an internet, but the same action is unable to get the netstat report for that IP.

ping a.b.c.d
64 bytes from a.b.c.d: icmp_seq=1 ttl=64 time=0.509 ms
64 bytes from a.b.c.d: icmp_seq=2 ttl=64 time=0.249 ms
64 bytes from a.b.c.d: icmp_seq=3 ttl=64 time=0.273 ms
64 bytes from a.b.c.d: icmp_seq=4 ttl=64 time=0.357 ms

but netstat is unable to get the output of,

netstat -an a.b.c.d | grep <some port>

it's just getting hang and not even returning my prompt, while I already have been sure about the connections it should list.

  • What are you trying to do? I don't think netstat does what you think it does. – Michael Homer Jul 21 '14 at 5:17
  • I wonder what netstat -an IP this would mean. Option -a lists all listening and non-listening sockets and -n shows numerical addresses. I think you misunderstood Mr. netstat. – beginer Jul 21 '14 at 5:24
  • meaning is same as that you said, except the output is expected for that IP, not considering the localhost – Keyshov Borate Jul 21 '14 at 5:54

netstat doesn't accept an IP address argument. The only non-option argument is a delay, and that's not in all versions.

The command will

Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

for the local machine. It doesn't have any access to data about other machines, only connections to and from the machine it's running on. It can take a while to do that, and loop forever with a delay.

If you're interested in information about connections from your machine to a particular other IP address you can use grep for it. Note that netstat is deprecated in any case, and its replacement ss has better inbuilt support for that use case.

  • Thanks Michael, but ss doesnt seem to be installed :( – Keyshov Borate Jul 21 '14 at 11:52
  • is there any other way? I want to get to know the netstat-like details but not for localhost, some other internet ip.. – Keyshov Borate Jul 21 '14 at 12:29
  • No. Log in to the machine and run your commands there. – Michael Homer Jul 21 '14 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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