1

netstat and similar commands provide information on services bound to an IP. This information is however limited when a service binds to "all available interfaces":

root@srv ~# netstat -tulpn | grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1077/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      1077/sshd

In the case above, the SSH daemon bound to all available interfaces, but it is not explicit about which ones.

How to check all interfaces (or IP addresses) a service bound to?

3

Try ss.

Something like:

ss -o state established '( dport = :ssh or sport = :ssh )'

Might be what you are looking for:

$ ss -o state established '( dport = :ssh or sport = :ssh )'
Netid Recv-Q Send-Q        Local Address:Port                         Peer Address:Port                
tcp   0      0               10.12.11.93:ssh                            10.22.96.0:57244                 timer:(keepalive,119min,0)


Man page online: https://linux.die.net/man/8/ss

  • Thanks but this lists the established connections, not the binding (which may not have a connection right now) – WoJ Aug 3 '18 at 11:36
  • @WoJ For the binding maybe this is the answer you seek: unix.stackexchange.com/a/16058/191550 – maulinglawns Aug 3 '18 at 11:43
  • Thanks again, but this is the routing - independent of which service bound to which interface. – WoJ Aug 3 '18 at 11:53

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.