[systemd-devel] nss-myhostname: why don't loopback interfaces appear?

Daurnimator quae at daurnimator.com
Tue Jun 9 19:18:36 PDT 2015


On 9 June 2015 at 20:36, Lennart Poettering <lennart at poettering.net> wrote:
> On Wed, 03.06.15 16:31, Daurnimator (quae at daurnimator.com) wrote:
>
>> On 3 June 2015 at 16:01, Lennart Poettering <lennart at poettering.net> wrote:
>> > On Wed, 03.06.15 15:40, Daurnimator (quae at daurnimator.com) wrote:
>> >
>> >> I was playing around with nss, and found that my loopback interface ip
>> >> doesn't appear from nss-myhostname.
>> >> Rather, my other ones do.
>> >> Furthermore, unless I request IPv4, link-local IPv6 addresses are
>> >> returned. Is this expected?
>> >
>> > We order the returned addresses by scope. Global addresses are
>> > placed first, local ones last.
>>
>> Then why are link local IPv6 addresses returned first?
>>
>> If this was the case, I would expect to see:
>>
>> 192.168.2.229
>> 192.168.2.21
>> fe80::aed1:b8ff:fec0:d113
>> fe80::9eeb:e8ff:fe1b:f42d
>> 127.0.0.1
>> ::1
>
> Currently the first ordering key is the address family (ipv4 before
> ipv6), the second ordering key is the scope (global before
> link-local).
>
> Are you suggesting we should turn this around, and sort by scope
> first, and by address family then? I might be open to such a change.

Here I was just observing that in my mind, a scope local ipv6 address
is less "global" than an ipv4 address;
and hence doubting your statement that things are ordered "most
global" to "least global"

>> > We return addresses on the loopback device only when there's no other
>> > address known.
>>
>> What's the rationale for this? (i.e. why not always just include
>> 127.0.0.1 and ::1 last?)
>
> Because they are an implementation detail I think. If something wants
> to know the local IP address, then returning that information is
> really useless...
>
> 127.0.0.x is really an address we should never present to the user
> ever, unless there#s no better way... I mean, I am pretty sure I could
> explain a non-technical person off the streat what an IP address is,
> but I am pretty sure I'd had quite some trouble explaining what the
> purpose of 127.0.0.1 is on top of that...

example use case, I'm testing a client/server protocol:
  - the server is running locally; and because it shouldn't be exposed
to the internet, it is bound to localhost.
  - I start the client and tell it to connect to $HOSTNAME
  - This should find it's way to the loopback interface.


More information about the systemd-devel mailing list