DNS problem

I’m new to OpenSuse and I have the following problem:

I’m using NetworkManager , but I have an OpenVPN client wrapper script which is updating the /etc/resolv.conf when I’m connecting to my remote network. The problem is that after it has been manually updated ( echo “nameserver 1.2.3.4” > /etc/resolv.conf ) NetworkManager doesn’t add its updates anymore.

I’ve tried to remove NetworkManager to handle my connections manually…but after it has been modiffied by my vpn script, “dhclient wlan0” doesn’t seem to update the /etc/resolv.conf.

On 11/02/2012 06:36 AM, silviu ht wrote:
>
> I’m new to OpenSuse and I have the following problem:
>
> I’m using NetworkManager , but I have an OpenVPN client wrapper script
> which is updating the /etc/resolv.conf when I’m connecting to my remote
> network. The problem is that after it has been manually updated ( echo
> “nameserver 1.2.3.4” > /etc/resolv.conf ) NetworkManager doesn’t add its
> updates anymore.
>
> I’ve tried to remove NetworkManager to handle my connections
> manually…but after it has been modiffied by my vpn script, “dhclient
> wlan0” doesn’t seem to update the /etc/resolv.conf.

That is normal. When a user makes changes to resolv.conf, the system assumes
that the user wants those changes to be permanent, and it does not overwrite it.

There are probably several ways to solve your problem, but the one that will
work is to modify your vpn script to restore the old resolv.conf when the
connection is broken.

By the command you overwrite the entire resolv.conf. If you want to append something to a file, use “>>” instead of “>”

Yes, but that means that the new resolver is only used after all the other ones above it fail.
This gives us two possibilities:

  1. the original one(s) do(es) not fail, this would mean that the whole addition is useless;
  2. it/they fail(s) (not available in that network), but the failing mostly means “time-out”, which will be a severe performance punishment coming with every DNS action.

I’ve found out that I can run “netconfig -f update” to update the resolv.conf. The main problem was when the system was turned off with the /etc/resolv.conf written by the vpn connect script… at the next startup /etc/resolv.conf hasn’t been updated by NetworkManager and name resolution didn’t work because the nameserver was unreachable without the vpn, I’ve fixed issue this by running neconfig -f update at each startup, but it in case if the vpn is unexpectedly dropped I need to run netconfig -f update manually.

For your better understanding. It is not NetworkManager does not update /tc/resolv.conf directly. It is the starting of device that uses DHCP to get that information.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Exactly; this command is pretty nice for fixing this when my
NetworkManager-managed VPN doesn’t get properly disconnected (pretty
rare, but happens once in a while). For those running as root all of
the time:

sudo /sbin/netconfig -f update

The manpage for netconfig comments on some ways to do some pretty
granular stuff, but I’ve never gone into that so, as always when running
as ‘root’, proceed with some caution.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQk9PaAAoJEF+XTK08PnB5DFcP/2Xp6gyjq5FFiv33Y0DJOvIo
27wmwuCNLAFZqbVQFjwFkIk39kPxnsXtzVobeNFjE0zJIgZYOr2yUHtMkTBvlZGC
Y0ySoSKQaVwIdtzDNeWxyhETO+9+Ehbi6oFrS/l2OYY73w8UOnXR0olUzqpHN6ge
fUgZNeFv1HJDTeIOMTf4Umix8zeG9Gl+ogkYhsf2VW/UUVwMe24WGgwof6mqooKY
mH7ueomLg7UxX8KTOtRiNoLRe0wtH+YfTrC01tzrxbRpARW9rhtTgQ6Khbcvq/q5
YOSu4vvZIHa9k6duHKu7gw1bpLOXpYWNZGE0NzOvKkrYZHxBzmZ6knSGGJSW7oTp
shQ05XQW1EqveyZc/cdV+wrTxP9XROLatdH6EOmpEtxH6HZ6O3PscIKRKqKgzxoO
aLYoD3Pin9yrQuOubWQpj2Tb+U6gpfseep99OHmxLAvSOlsN/0LI1CCt6153KHiW
1LU3k0SjY8KkMGac2i3v4GEWPFhwGvj2VnMZuTfY0u/Tr0/7JXFbYTffCcGi21go
qWBds382e4qeAfoXE9jkj0SCdJPZ/fX6LcYyReKQexB0vfEZXGbyfnWobDdiGFOQ
U4Duc1Rk5vAUnl2pD9qPnDiyEzTH/UE/Kbu6Q0smTGiGJjB2nfp8eYr4Ggb/SdlE
fYyy63AHtK03UQJ6cMnu
=8PFP
-----END PGP SIGNATURE-----

One thing that I still don’t understand…why when I’m running “dhclient wlan0” /etc/resolv.conf is not updated anymore? If I want to run the dhcp client to reconfigure my nic and the dhcpd offers me an dns, for sure I would like /etc/resolv.conf to be updated.

lwfinger wrote:

That is normal. When a user makes changes to resolv.conf, the system assumes
that the user wants those changes to be permanent, and it does not overwrite it.

Look into an original /etc/resolv.conf. The comment at the beginning is crucial. When netconfig does not find this comment, it leaves the file alone, not to frustrate local manual changes. When I understand what is there correct, the last line

### Please remove (at least) this line when you modify the file!

should be there to let netconfig do it’s work. You could try puttiing it there together with your deviating nameserrver line.

On 11/02/2012 12:36 PM, silviu ht wrote:
>
> I’m new to OpenSuse and I have the following problem:
> I’m using NetworkManager , but I have an OpenVPN client wrapper script

NetworkManager has openVPN bits and pieces…are yours not working what
is causing you to use a script? and, how old might that script be
(written for your operating system and version–OH, you didn’t declare
either…what are you using?)

anyway, use YaST Software Management to make sure your NetworkManager
has all the bits it needs and maybe you won’t need that script…

(anyway, it sounds like that script was written either a different
distro or a very old SuSE–it sure doesn’t fit today’s NM and oS)


dd

On 2012-11-02 15:36, silviu ht wrote:
>
> One thing that I still don’t understand…why when I’m running “dhclient
> wlan0” /etc/resolv.conf is not updated anymore? If I want to run the
> dhcp client to reconfigure my nic and the dhcpd offers me an dns, for
> sure I would like /etc/resolv.conf to be updated.

It will not, because you modified it, and your modification has priority.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” (Minas Tirith))

Yes, you’re right. Since I’ve been using this script/configuration on different machines, I had something like “/etc/openvpn/conf.d/ and /etc/opevpn/keys.d” and a single connect script.

I’ve tried the openvpn plugin and I found that it also have the “update dns” option.

The problem is solved.

Thank you for your support. It looks like OpenSuSE has a great community :slight_smile:

> The problem is solved.

happy you got it sorted out…

> Thank you for your support. It looks like OpenSuSE has a great
> community :slight_smile:

yep, they are pretty cool.


dd