Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces - Mailing list pgsql-admin

From Tom Lane
Subject Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces
Date
Msg-id 2642499.1746455484@sss.pgh.pa.us
Whole thread Raw
In response to Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces  (Stelios Malathouras <s.malathouras@deltasoftsolutions.net>)
Responses Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces
List pgsql-admin
Stelios Malathouras <s.malathouras@deltasoftsolutions.net> writes:
> Our local tests, with listen_addresses = '*',  show that the postgres listener accepts connections immediately to the
newIP. 
> The same behavior is observed when adding a new network interface.  Postgres accepts connections to the new network
interface(and IP) immediately without requiring a restart. 

It might be platform-dependent.  We call getaddrinfo(3) only once at
postmaster start, passing node = NULL if you said "*", and then
bind(2) to each resulting address.  The Linux manpage for getaddrinfo
quoth

       If  the  AI_PASSIVE  flag  is  specified in hints.ai_flags, and node is
       NULL,  then  the  returned  socket  addresses  will  be  suitable   for
       bind(2)ing  a  socket  that  will  accept(2) connections.  The returned
       socket address will contain the "wildcard address" (INADDR_ANY for IPv4
       addresses, IN6ADDR_ANY_INIT for IPv6 address).  The wildcard address is
       used by applications (typically servers) that intend to accept  connec‐
       tions  on  any  of  the host's network addresses.

The POSIX standard for getaddrinfo also says that these parameters
yield a wildcard address, but it doesn't say in so many words that
that results in accepting connections on any of the machine's
interfaces.  Maybe it says that elsewhere, though; I didn't go
digging.  In any case, you're probably fine on any Linux box,
but if you want to rely on this behavior on some other platform
I'd advise testing first.

            regards, tom lane



pgsql-admin by date:

Previous
From: Pratik Pandit
Date:
Subject: Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces
Next
From: Stelios Malathouras
Date:
Subject: Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces