Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #246164 > unrolled thread

11.2 sometimes wrong /etc/resolv.conf

Started byChristian Groessler <chris@groessler.org>
First post2022-03-10 17:40 +0100
Last post2022-03-12 17:50 +0100
Articles 4 — 4 participants

Back to article view | Back to linux.debian.user


Contents

  11.2 sometimes wrong /etc/resolv.conf Christian Groessler <chris@groessler.org> - 2022-03-10 17:40 +0100
    Re: 11.2 sometimes wrong /etc/resolv.conf Charles Curley <charlescurley@charlescurley.com> - 2022-03-10 18:30 +0100
    Re: 11.2 sometimes wrong /etc/resolv.conf ghe2001 <ghe2001@protonmail.com> - 2022-03-10 20:50 +0100
    Re: 11.2 sometimes wrong /etc/resolv.conf Anssi Saari <as@sci.fi> - 2022-03-12 17:50 +0100

#246164 — 11.2 sometimes wrong /etc/resolv.conf

FromChristian Groessler <chris@groessler.org>
Date2022-03-10 17:40 +0100
Subject11.2 sometimes wrong /etc/resolv.conf
Message-ID<DZtZv-QGG-3@gated-at.bofh.it>
Hi,

when I boot my laptop with Debian 11.2 and LAN cable connected, I'm 
sometimes getting a wrong /etc/resolv.conf.

The resolv.conf is not in fact wrong, but it's the one from the Wifi 
network. But when booting with network cable connected I want to have 
the resolv.conf of the cabled network.

Can I somehow force this? That the "cabled-network-nameserver" is used 
when the cable is connected?

regards,
chris

[toc] | [next] | [standalone]


#246167

FromCharles Curley <charlescurley@charlescurley.com>
Date2022-03-10 18:30 +0100
Message-ID<DZuLT-RbR-9@gated-at.bofh.it>
In reply to#246164
On Thu, 10 Mar 2022 17:22:34 +0100
Christian Groessler <chris@groessler.org> wrote:

> when I boot my laptop with Debian 11.2 and LAN cable connected, I'm 
> sometimes getting a wrong /etc/resolv.conf.
> 
> The resolv.conf is not in fact wrong, but it's the one from the Wifi 
> network. But when booting with network cable connected I want to have 
> the resolv.conf of the cabled network.
> 
> Can I somehow force this? That the "cabled-network-nameserver" is
> used when the cable is connected?

The cable network's DHCP server should provide the relevant information
automatically. If you are using NetworkManager, you can insert a script
to find out what it provides into /etc/NetworkManager/dispatcher.d/.
Something like:

echo "Routers value is |$DHCP4_ROUTERS|. IP4_GATEWAY is
|$IP4_GATEWAY|." echo "Environment is:" printenv

and send the output to a log file. The variable you want is
DHCP4_DOMAIN_NAME_SERVERS, and possibly others (see the results from
printenv).

You may have to request certain information from a badly configured
server. In your /etc/dhcp/dhclient.conf, something like:

request subnet-mask, broadcast-address, time-offset, routers,
	domain-name, domain-name-servers, domain-search, host-name,
	dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
	rfc3442-classless-static-routes, ntp-servers;

You will probably need at least the second and/or third line.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

[toc] | [prev] | [next] | [standalone]


#246170

Fromghe2001 <ghe2001@protonmail.com>
Date2022-03-10 20:50 +0100
Message-ID<DZwXn-SoI-1@gated-at.bofh.it>
In reply to#246164
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, March 10, 2022 9:22 AM, Christian Groessler <chris@groessler.org> wrote:

> Hi,
>
> when I boot my laptop with Debian 11.2 and LAN cable connected, I'm
> sometimes getting a wrong /etc/resolv.conf.
>
> The resolv.conf is not in fact wrong, but it's the one from the Wifi
> network. But when booting with network cable connected I want to have
> the resolv.conf of the cabled network.
>
> Can I somehow force this? That the "cabled-network-nameserver" is used
> when the cable is connected?

How about:

Create a resolv.com file with the cable network info (with a different name; I use /etc/resolv.com.qw).

Create a shell script that gets the current IP (hostname -I), checks for the desired nameserver IP, and copies your resolv.com.qw to /etc/resolv.com if necessary.  Or maybe always copy the file (one-liner in .bashrc) if you always want the same nameserver and want to save a couple ms.

Put the script at the bottom of the .bashrc (or equiv) in everybody's login dir.

The script will run when anybody logs in -- long after the network has been configured.

--
Glenn English


-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wsBzBAEBCAAGBQJiKlPnACEJEJ/XhjGCrIwyFiEELKJzD0JScCVjQA2Xn9eG
MYKsjDKYKAgAk87zZAIrAyhVKU9YD1cU4vXoZ08xLBJGQfy78yKXFaAEEwEw
qfg83L6YsDEdqX01DFU7Gvv0DyrPfNatit+Ut2/76cLJkfzDiGeqB1KzyI3a
R+yzLJy0aq71Ww/8dG4XUEAXt7ieIop3akjnmIHa0qUxo7rrFvVr8hG1hT22
NLWYGqFBgB4TnXJMbGDEyIXZUmsnvdzXcn883sXWna++Hg5r179rt+EG+rwn
vL0LWaeKV7TccFnP8J1siLFi9ZkeAZ5w5JXvPlkL5UKLnfIabcu1CORRHsIP
jWLSSs7ywRrwskvc/6+HvlsljPKbCsEPk3qocNoiAxkN6O+7t6FMdg==
=xTLN
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#246239

FromAnssi Saari <as@sci.fi>
Date2022-03-12 17:50 +0100
Message-ID<E0d6i-1hRi-7@gated-at.bofh.it>
In reply to#246164
Christian Groessler <chris@groessler.org> writes:

> Hi,
>
> when I boot my laptop with Debian 11.2 and LAN cable connected, I'm
> sometimes getting a wrong /etc/resolv.conf.
>
> The resolv.conf is not in fact wrong, but it's the one from the Wifi
> network. But when booting with network cable connected I want to have
> the resolv.conf of the cabled network.

I think you mean when you're plugged in both wifi and ethernet are
connected and your whole connection is over one or the other, probably
whichever connected last? So your question is really, how to turn off
wifi when using fixed ethernet? Using NetworkManager, one might guess?

It's surprising to me this doesn't seem to be handled by NetworkManager
GUI. Or actually when I think of how weird and broken and undocumented
NetworkManager is, maybe I shouldn't be surprised.

Anyways, here's an explanation on how to make NetworkManager do what I
guess you want it to do:
https://unix.stackexchange.com/questions/487640/disable-wifi-on-connection-to-ethernet-with-networkmanager

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web