Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On 10/06/15 03:18, Daurnimator wrote: 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 Why wouldn't you tell the client to connect to localhost instead? (Relatedly, on my development laptop I have dnsmasq set up to resolve [anything].localhost to 127.0.0.1, which means I can even use name-based virtual hosting in local testing - maybe it would be worthwhile for systemd-resolved and/or nss-myhostname to behave similarly?) -- Simon McVittie Collabora Ltd. http://www.collabora.com/ ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On 3 June 2015 at 06:40, Daurnimator q...@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? So in my case, I don't have /etc/hosts file at all and use nss-myhostname et.al. modules. Specifically I have nsswitch.conf like so: hosts: files myhostname resolve dns mymachines My naive expection for the following call: # getent hosts `hostname` To return something like, e.g.: 127.0.1.1 $hostname $hostname.$domain But instead I get: fe80::5054:ff:fe12:3456 $hostname Whist it is perfectly valid, it's atypical from usual setups elsewhere. And subtle things seem to rely on the usual setup, e.g. Erlang Port Mapper Daemon / zerromq fail to start, as hostname - 127.0.*.* - localhost mappings are kind of expected. (there were other things as well, that were fixed up by other people) Sure, I could fix the world to connect/resolve localhost, instead of `hostname`, but for the time being this situation became defacto expected =( I would like to see an option to myhostname module to return 127.0.1.1 when asking for current machine `hostname`. -- Regards, Dimitri. Pura Vida! https://clearlinux.org Open Source Technology Center Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On Wed, 10.06.15 11:17, Simon McVittie (simon.mcvit...@collabora.co.uk) wrote: On 10/06/15 03:18, Daurnimator wrote: 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 Why wouldn't you tell the client to connect to localhost instead? (Relatedly, on my development laptop I have dnsmasq set up to resolve [anything].localhost to 127.0.0.1, which means I can even use name-based virtual hosting in local testing - maybe it would be worthwhile for systemd-resolved and/or nss-myhostname to behave similarly?) This is actually already what happens. Here's the call that checks whether a hostname should be considered equivalent to localhost: https://github.com/systemd/systemd/blob/master/src/shared/hostname-util.c#L129 Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On Wed, 10.06.15 12:18, Daurnimator (q...@daurnimator.com) wrote: On 9 June 2015 at 20:36, Lennart Poettering lenn...@poettering.net wrote: On Wed, 03.06.15 16:31, Daurnimator (q...@daurnimator.com) wrote: On 3 June 2015 at 16:01, Lennart Poettering lenn...@poettering.net wrote: On Wed, 03.06.15 15:40, Daurnimator (q...@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. Why not use localhost to connect to here, instead of $HOSTNAME? In general: nss-myhostname resolves without any /etc/hosts 1. localhost to 127.0.0.1 and ::1 2. your local hostname $HOSTNAME to the set of locally configured IP addresses, excluding the ones of the loopback device, except when those are the only addresses configured, in which case 127.0.0.2 is returned. 3. gateway to the addresses of the gateways of all the default routes currently in effect If you want $HOSTNAME to always resolve to a loopback address, then that's an indication that you probably actually want to use localhost. Vice verse, if you want localhost to map to your local IP addresses then you probably want to use $HOSTNAME instead. The behaviour described above is very much in line with how things have been set up on popular distros for a while actually, except this is now fully dynamic instead of requiring one-time editing of /etc/hosts.. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On Wed, 03.06.15 16:31, Daurnimator (q...@daurnimator.com) wrote: On 3 June 2015 at 16:01, Lennart Poettering lenn...@poettering.net wrote: On Wed, 03.06.15 15:40, Daurnimator (q...@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. 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... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On 9 June 2015 at 20:36, Lennart Poettering lenn...@poettering.net wrote: On Wed, 03.06.15 16:31, Daurnimator (q...@daurnimator.com) wrote: On 3 June 2015 at 16:01, Lennart Poettering lenn...@poettering.net wrote: On Wed, 03.06.15 15:40, Daurnimator (q...@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. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On 3 June 2015 at 16:01, Lennart Poettering lenn...@poettering.net wrote: On Wed, 03.06.15 15:40, Daurnimator (q...@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 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?) And even then we'll return 127.0.0.2 rather than 127.0.0.1, to avoid confusing software that expects localhost mapping only to 127.0.0.1 and vice versa. Also see nss-myhostname(8). ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] nss-myhostname: why don't loopback interfaces appear?
On Wed, 03.06.15 15:40, Daurnimator (q...@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. We return addresses on the loopback device only when there's no other address known. And even then we'll return 127.0.0.2 rather than 127.0.0.1, to avoid confusing software that expects localhost mapping only to 127.0.0.1 and vice versa. Also see nss-myhostname(8). Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] nss-myhostname: why don't loopback interfaces appear?
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? $ uname -n daurn-m3800 $ getent hosts daurn-m3800 fe80::aed1:b8ff:fec0:d113 daurn-m3800 fe80::9eeb:e8ff:fe1b:f42d daurn-m3800 $ getent ahostsv4 daurn-m3800 192.168.2.229 STREAM daurn-m3800 192.168.2.229 DGRAM 192.168.2.229 RAW 192.168.2.21STREAM 192.168.2.21DGRAM 192.168.2.21RAW $ getent ahostsv6 daurn-m3800 fe80::aed1:b8ff:fec0:d113 STREAM daurn-m3800 fe80::aed1:b8ff:fec0:d113 DGRAM fe80::aed1:b8ff:fec0:d113 RAW fe80::9eeb:e8ff:fe1b:f42d STREAM fe80::9eeb:e8ff:fe1b:f42d DGRAM fe80::9eeb:e8ff:fe1b:f42d RAW # For reference, my current network setup: $ ip addr 1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: wlp6s0: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether ac:d1:b8:c0:d1:13 brd ff:ff:ff:ff:ff:ff inet 192.168.2.229/24 brd 192.168.2.255 scope global dynamic wlp6s0 valid_lft 64025sec preferred_lft 64025sec inet6 fe80::aed1:b8ff:fec0:d113/64 scope link valid_lft forever preferred_lft forever 5: enp0s20u2u4u4: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 9c:eb:e8:1b:f4:2d brd ff:ff:ff:ff:ff:ff inet 192.168.2.21/24 brd 192.168.2.255 scope global dynamic enp0s20u2u4u4 valid_lft 64025sec preferred_lft 64025sec inet6 fe80::9eeb:e8ff:fe1b:f42d/64 scope link valid_lft forever preferred_lft forever ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel