[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cannot see a process listening on 127.0.0.1



Andy Smith wrote:
> 
> On Thu, Aug 20, 2020 at 12:09:03PM +0700, Victor Sudakov wrote:
> > There is a process listening on 127.0.0.1:8081 but for some reason
> > netstat/sockstat/ss do not show it listening on IPv4. Is this a bug or a
> > feature?
> 
> I think it's listening on an IPv4-mapped IPv6 address so it can
> accept either v4 or v6. Does this answer your question?
> 
>     https://unix.stackexchange.com/questions/152612/netstat-why-are-ipv4-daemons-listening-to-ports-listed-only-in-a-inet6
> 
> Daemons that want to receive connections will do the equivalent of:
> 
>     bind(address, port)
> 
> The address will determine the interface and whether it is v4 or v6
> or whatever. If they instead do:
> 
>     bind(INADDR_ANY, port)
> 
> then this will bind to every interface whether it's v4 or v6 and the
> daemon will get udp6 or tcp6 sockets that can from fromn/to a v4 address.

Thank you, Andy, that explains it. 

It's different in *BSD which got me confused. In *BSD, even if you bind
to INADDR_ANY, you'll see something like this in sockstat output:

root     dovecot    39601 21 tcp4   *:110                 *:*
root     dovecot    39601 22 tcp6   *:110                 *:*
root     dovecot    39601 23 tcp4   *:995                 *:*
root     dovecot    39601 24 tcp6   *:995                 *:*

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/

Attachment: signature.asc
Description: PGP signature


Reply to: