Using CentoS 5.5.
I have an Apache 2.x server running on port 9999 and I am trying to find it using fuser.
I can find it using netstat, i.e.:
netstat -an | grep 9999
outputs:
tcp 0 0 :::9999 :::* LISTEN
Question 1: Why is netstat displaying the port using IPv6 syntax?
Question 2: What fuser command can I use to find the pid of the server? None of the following work:
fuser -n tcp :::9999
fuser -n tcp 9999
fuser -4 -n tcp 9999
fuser -6 -n tcp 9999
fuser -6 -n tcp :::9999
Thanks!
Why is it listening on IPv6? Well, by default on Linux, binding to
[::]
will not only bind to IPv6, but will also bind to an IPv4–compatible address. The::ffff:0.0.0.0/96
space in IPv6 is used for IPv4–compatible connections.The advantage of the software doing this is that it only needs to bind to the one socket. It makes the coding slightly simpler.
Not all distros or operating systems do this. For example, Windows requires you to bind to both
[::]
or0.0.0.0
explicitly in order to support IPv6 or IPv4. And on Linux, if thenet.ipv6.bindv6only
sysctl is set to1
(like it is on Debian, but not most other distros, including CentOS or Ubuntu), then you will need to explicitly bind to[::]
and0.0.0.0
to support both.As for how to look it up in
fuser
, do it like this:Or to show what process is bound to the port: