Local IP address preferred after DNS resolution?

by user1283043   Last Updated January 12, 2018 20:04 PM

I have consul as nameserver that resolves address from two instances of a service. DNS info via dig interface.http.service.consul:

...
interface.http.service.consul. 0    IN A    10.0.0.85
interface.http.service.consul. 0    IN A    10.0.1.22
...

ping will alternate between both addresses:

while true; do ping -c 1 interface.http.service.consul | grep PING; sleep 1; done
PING interface.http.service.consul (10.0.0.85) 56(84) bytes of data.
PING interface.http.service.consul (10.0.0.85) 56(84) bytes of data.
PING interface.http.service.consul (10.0.0.85) 56(84) bytes of data.
PING interface.http.service.consul (10.0.1.22) 56(84) bytes of data.
PING interface.http.service.consul (10.0.0.85) 56(84) bytes of data.
PING interface.http.service.consul (10.0.1.22) 56(84) bytes of data.
PING interface.http.service.consul (10.0.0.85) 56(84) bytes of data.

However curl or wget won't alternate between these two IPs. I checked the DNS requests:

They always prefer the "more local" target during a multiple curl calls:

19:43:17.979701 IP nginx.stage.35800 > dns01.node.staging.consul.domain: 49288+ A? interface.http.service.consul. (54)
19:43:17.980586 IP dns01.node.staging.consul.domain > nginx.stage.35800: 49288* 2/0/0 A 10.0.1.22, A 10.0.0.85 (86)
19:43:19.056563 IP nginx.stage.56584 > dns01.node.staging.consul.domain: 44478+ A? interface.http.service.consul. (54)
19:43:19.057605 IP dns01.node.staging.consul.domain > nginx.stage.56584: 44478* 2/0/0 A 10.0.0.85, A 10.0.1.22 (86)
19:43:34.873807 IP nginx.facemantest.36293 > dns01.node.staging.consul.domain: 43958+ A? interface.http.service.consul. (54)
19:43:34.875065 IP dns01.node.staging.consul.domain > nginx.stage.36293: 43958* 2/0/0 A 10.0.0.85, A 10.0.1.22 (86)

So the DNS response have either 10.0.0.85 or 10.0.1.22 as first A record. But curl always uses 10.0.1.22, never 10.0.0.85.

The machine where I run curl has 10.0.1.10 as IP address. It also looks like this affects the nginx proxy pass mechanism.

Here my question: Do http clients check the IP, and choose an IP that looks closer? Can I disable such a behavior?

Tags : dns ip-address


Related Questions


Why A Record is not working?

Updated March 29, 2015 07:01 AM

How to make your ISP provider and PC IP address

Updated July 02, 2015 13:01 PM


Domain owner uses my IP without permission

Updated June 11, 2015 12:01 PM

What does an asterisk/star in traceroute mean?

Updated June 08, 2015 22:01 PM