You are not logged in.

#1 2024-02-24 10:29:58

dext
Member
From: Poland, Kraków
Registered: 2008-02-01
Posts: 121

[solved]Host resolves to wrong IP

Solution:
Apparently it's necessary to restart systemd-resolved.service after updating /etc/resolv.conf.

Original question:
How is this possible, what am I forgetting?

host and dig resolve to 192.168.13.2, curl uses 100.100.97.104 for some reason.

I have 15 years of professional experience with Linux, so feel free to roast me, but I finally want to know. Me and my colleagues have encountered this many times and multiple jobs, and everything I can find says it's impossible...

dext@gamprin ~ % cat /etc/resolv.conf
nameserver 192.168.13.2

dext@gamprin ~ % dig vaduz.rvalley.pl

; <<>> DiG 9.18.24 <<>> vaduz.rvalley.pl
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25989
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;vaduz.rvalley.pl.              IN      A

;; ANSWER SECTION:
vaduz.rvalley.pl.       0       IN      A       192.168.13.2

;; Query time: 0 msec
;; SERVER: 192.168.13.2#53(192.168.13.2) (UDP)
;; WHEN: Sat Feb 24 11:12:13 CET 2024
;; MSG SIZE  rcvd: 61

dext@gamprin ~ % host vaduz.rvalley.pl
vaduz.rvalley.pl has address 192.168.13.2

dext@gamprin ~ % curl -v vaduz.rvalley.pl
* Host vaduz.rvalley.pl:80 was resolved.
* IPv6: (none)
* IPv4: 100.100.97.104
*   Trying 100.100.97.104:80

More details:
Public DNS is set vaduz.rvalley.pl -> 100.100.97.104
192.168.13.2/vaduz.rvalley.pl is local LAN machine with DNSmasq, it resolves vaduz.rvalley.pl -> 192.168.13.2

I want vaduz.rvalley.pl to resolve to LAN IP, so the traffic doesn't go over WAN while I'm on this network.

Last edited by dext (2024-02-24 12:05:07)

Offline

#2 2024-02-24 10:41:54

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,152
Website

Re: [solved]Host resolves to wrong IP

Caching? https://everything.curl.dev/libcurl/caches
I.e.

$ CURLOPT_DNS_CACHE_TIMEOUT=0 curl -v vaduz.rvalley.pl

Last edited by schard (2024-02-24 10:53:37)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#3 2024-02-24 10:56:43

dext
Member
From: Poland, Kraków
Registered: 2008-02-01
Posts: 121

Re: [solved]Host resolves to wrong IP

Not a cache. It's just a short example. It's the same with browsers, and I cleared them, installed strange new ones to test, etc. Lynx the same, on multiple users.
What's actually interesting in this particular case, is that ssh resolves properly.

Last edited by dext (2024-02-24 10:57:31)

Offline

#4 2024-02-24 11:43:47

-thc
Member
Registered: 2017-03-15
Posts: 775

Re: [solved]Host resolves to wrong IP

I work with several split-brain DNS setups like yours and they don't show this behavior (curl resolves correctly).

- Make sure your /etc/nsswitch.conf still uses the default

hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns

- Check /etc/hosts
- Check if your setup uses systemd-resolved with a static /etc/resolv.conf

resolvectl status

Offline

#5 2024-02-24 12:03:15

dext
Member
From: Poland, Kraków
Registered: 2008-02-01
Posts: 121

Re: [solved]Host resolves to wrong IP

Thanks -thc, I've found the problem.

After observing "resolvectl status", I think there must be a bug in systemd-resolved. When /etc/resolv.conf gets updated, resolved correctly updates "DNS Servers", it correctly updates "Current DNS Server" in "Global section", but it doesn't update "Current DNS Server" in "Link" sections.

The solution is:

systemctl restart systemd-resolved.service

Offline

#6 2024-02-24 13:37:46

progandy
Member
Registered: 2012-05-17
Posts: 5,277

Re: [solved]Host resolves to wrong IP

As far as I know (I currently do not use resolved), you should not edit /etc/resolv.conf when using systemd-resolved. resolv.conf should preferably be a symlink that forwards all queries to systemd-resolved and changing the DNS should be done through your network management service or resolvectl.

If you use the compatibility mode and have resolved as the consumer while you write to resolv.conf with another program, then you probably have to add "Domains=~." to your resolved-configuration similar to this:
https://wiki.archlinux.org/title/System … d#Manually

Last edited by progandy (2024-02-24 13:45:02)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#7 2024-02-24 16:55:35

dext
Member
From: Poland, Kraków
Registered: 2008-02-01
Posts: 121

Re: [solved]Host resolves to wrong IP

progandy wrote:

you should not edit /etc/resolv.conf

I don't, NetworkManager handles it, I changed DNS settings on the router and reconnected.

Offline

Board footer

Powered by FluxBB