specifying IPv6 addresses to fuser
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
开发者_Go百科
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 [::]
or 0.0.0.0
explicitly in order to support IPv6 or IPv4. And on Linux, if the net.ipv6.bindv6only
sysctl is set to 1
(like it is on Debian, but not most other distros, including CentOS or Ubuntu), then you will need to explicitly bind to [::]
and 0.0.0.0
to support both.
As for how to look it up in fuser
, do it like this:
# fuser 80/tcp
80/tcp: 3052 3143 3144 3146 3147 3148
Or to show what process is bound to the port:
# fuser -v 80/tcp
USER PID ACCESS COMMAND
80/tcp: root 3052 F.... apache2
www-data 3143 F.... apache2
www-data 3144 F.... apache2
www-data 3146 F.... apache2
www-data 3147 F.... apache2
www-data 3148 F.... apache2
One was fix was to disable ipv6:
Added to /etc/modprobe.conf:
alias net-pf-10 off
I don't think fuser likes ipv6.
精彩评论