Re: Weird resolver problem in Debian 8

2017-07-25 Thread Torbjörn Pettersson

Ah, ok.
Thank you! I was rather confused for a while there.


Regards
Torbjorn



On 25/07/17 17:46, Henrique de Moraes Holschuh wrote:

On Tue, 25 Jul 2017, Torbjorn Pettersson wrote:

Same result regardless of how many times I run it. Great,
but telnet, however, chooses one of the a records at "random".

DNS sortlist works mostly for apps using outdated APIs.  telnet in
stretch has long moved to the new APIs that are IPv6-enabled properly,
and therefore they will use *all* A and  records returned from the
DNS lookup (so *dns* sort order doesn't matter since it will consider
every result regardless of the order) and select which ones to try first
based on several hardcoded rules *and* (in glibc's case) local
configuration related to IPv6+IPv4 source address selection.

Please configure your network preference ordering in /etc/gai.conf, and
it should work for the majority of the stuff in Debian.  In fact, you
can even configure ipv4 ranges (or all of it) to be prefered over some
ipv6 ranges (or all of it), etc.





Re: Weird resolver problem in Debian 8

2017-07-25 Thread Henrique de Moraes Holschuh
On Tue, 25 Jul 2017, Torbjorn Pettersson wrote:
> Same result regardless of how many times I run it. Great,
> but telnet, however, chooses one of the a records at "random".

DNS sortlist works mostly for apps using outdated APIs.  telnet in
stretch has long moved to the new APIs that are IPv6-enabled properly,
and therefore they will use *all* A and  records returned from the
DNS lookup (so *dns* sort order doesn't matter since it will consider
every result regardless of the order) and select which ones to try first
based on several hardcoded rules *and* (in glibc's case) local
configuration related to IPv6+IPv4 source address selection.

Please configure your network preference ordering in /etc/gai.conf, and
it should work for the majority of the stuff in Debian.  In fact, you
can even configure ipv4 ranges (or all of it) to be prefered over some
ipv6 ranges (or all of it), etc.

-- 
  Henrique Holschuh



Re: Weird resolver problem in Debian 8

2017-07-25 Thread Torbjorn Pettersson



On 25/07/17 16:32, Torbjorn Pettersson wrote:

Hello folks,
I came upon a weird problem with the resolver on Debian 8.

root@myserver:~# cat /etc/resolv.conf
search strul.nu
nameserver 192.168.10.20
nameserver 192.168.20.20
sortlist 192.168.20.0/255.255.254.0

root@myserver:~# grep -i hosts /etc/nsswitch.conf
hosts:  files dns

root@myserver:~# grep -i mailgw /etc/hosts
root@myserver:~#




Checking addresses in dns:

root@myserver:~# host mailgw.strul.nu
mailgw.strul.nu has address 192.168.10.11
mailgw.strul.nu has address 192.168.20.11

And ping works the way it is supposed to, every time I run it. That is,
it uses the address suggested by the sortlist:



Oups. I see that I made some errors in transcribing this for email.
Corrected it below:

root@myserver:~# ping mailgw.strul.nu
PING mailgw.strul.nu (192.168.20.11) 56(84) bytes of data.
64 bytes from mailgw10.strul.nu (192.168.20.11): icmp_seq=1
ttl=64 time=0.132 ms
64 bytes from mailgw10.strul.nu (192.168.20.11): icmp_seq=2
ttl=64 time=0.133 ms

Same result regardless of how many times I run it. Great,
but telnet, however, chooses one of the a records at "random".


root@myserver:~# telnet mailgw.strul.nu smtp
Trying 192.168.20.11...
Connected to mailgw.strul.nu.
Escape character is '^]'.
220 mailgw10.strul.nu ESMTP



root@myserver:~# telnet mailgw.strul.nu smtp
Trying 192.168.10.11...


Anyone experienced something similar, or know what could be wrong?
In my head this should be handled by libc both for telnet and ping, so
the behavior should be the same?
Also, of course "telnet" in this case isn't really the problem, it's
just an example. The problem in this case is exim4, which behaves like
telnet, not like ping.

Regards
Torbjorn





Weird resolver problem in Debian 8

2017-07-25 Thread Torbjorn Pettersson

Hello folks,
I came upon a weird problem with the resolver on Debian 8.

root@myserver:~# cat /etc/resolv.conf
search strul.nu
nameserver 192.168.10.20
nameserver 192.168.20.20
sortlist 192.168.20.0/255.255.254.0

root@myserver:~# grep -i hosts /etc/nsswitch.conf
hosts:  files dns

root@myserver:~# grep -i mailgw /etc/hosts
root@myserver:~#




Checking addresses in dns:

root@myserver:~# host mailgw.strul.nu
mailgw.strul.nu has address 192.168.10.11
mailgw.strul.nu has address 192.168.20.11

And ping works the way it is supposed to, every time I run it. That is,
it uses the address suggested by the sortlist:

root@myserver:~# ping mailgw.strul.nu
PING mailgw.strul.nu (172.26.20.11) 56(84) bytes of data.
64 bytes from mailgw10.strul.nu (172.26.20.11): icmp_seq=1
ttl=64 time=0.132 ms
64 bytes from mailgw10.strul.nu (172.26.20.11): icmp_seq=2
ttl=64 time=0.133 ms

Same result regardless of how many times I run it. Great,
but telnet, however, chooses one of the a records at "random".


root@myserver:~# telnet mailgw.strul.nu smtp
Trying 172.26.20.11...
Connected to mailgw.strul.nu.
Escape character is '^]'.
220 mailgw10.strul.nu ESMTP



root@myserver:~# telnet mailgw.strul.nu smtp
Trying 172.26.10.11...


Anyone experienced something similar, or know what could be wrong?
In my head this should be handled by libc both for telnet and ping, so
the behavior should be the same?
Also, of course "telnet" in this case isn't really the problem, it's
just an example. The problem in this case is exim4, which behaves like
telnet, not like ping.

Regards
Torbjorn