Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS servers (re)set automatically to some wird settings after each device reboot #245

Open
klosz007 opened this issue Jan 6, 2025 · 1 comment

Comments

@klosz007
Copy link

klosz007 commented Jan 6, 2025

Hi,

I have IP address/gateway set statically.

I noticed that DNS servers in /etc/resolv.conf are set to some weird settings after each reboot, as follows:
nameserver 192.168.0.1
nameserver 8.8.4.4
nameserver 8.8.8.8
nameserver 114.114.114.114
nameserver 119.29.29.29
nameserver 223.5.5.5
(first is some 'local/private' IP but not from my local subnet, two next servers are Google's, the last three are unknown to me),

None of these servers would work in my case because my IoT network segment is only allowed to send DNS requests to my internal DNS servers, in my local/private subnet.

If /etc/resolv.conf is changed manually, it works fine then but it restores itself to incorrect values after every device reboot. Same about changing /boot/resolv.conf.

I found a wrokaround in another issue report (modify /etc/resolv.conf and then set immutable flag on it with chattr) and then it works as expected (changes to /etc/resolv.conf survive reboot). But it is really not as it should work.

@stvorl
Copy link

stvorl commented Jan 9, 2025

I found that NanoKVM DHCP client creates /etc/resolv.conf.dhcp with proper DNS server and domain suffix, obtained from DHCP server. But this left unused, unless copied or symlinked to /etc/resolv.conf.
So, after some experiments, and using your workaround, I created /etc/init.d/S99resolv-fix:

#!/bin/sh
mkdir -p /run/network

case "$1" in
  start)
        echo "Fixing resolv.conf to DHCP version"
        chattr -i /etc/resolv.conf
        rm /etc/resolv.conf
        cp /etc/resolv.conf.dhcp /etc/resolv.conf
        chattr +i /etc/resolv.conf
        ;;
  stop)
        ;;
  restart|reload)
        "$0" stop
        "$0" start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac
exit $?

It starts as service during reboot.
Sure, it's quite crude and optimistic solution, but it works.
However, I can't predict what consequences this will lead to. Probably, the default settings were made as is for some purposes, not just for fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants