Modifications to resolv.conf

Kernels & Hardware, configuring network, installing services

Modifications to resolv.conf

Postby mojosound » 2018-09-14 15:47

I tried searching for this and could not find already asked. I am working on an embedded device similar to a raspberry pi running Debian for ARM. When the DHCP server assigns an address the resolv.conf file gets updated as expected. In particular, the name server information gets updated. However, sometimes the DHCP server does not return DNS settings intentionally. In this case, the resolv.conf file is not getting updated. This is not what I would like to happen. I would like to either have the old DNS information deleted or, at worst, set to 0.0.0.0 to indicate no data was received. I have been digging into the documentation for dhclient and I think my answer lies somewhere here. If I understand the documentation, I could execute a script on from the /etc/dhcp/dhclient-enter-hooks.d folder. The script in this folder would run on each operation. I would need to determine which operation(s) would be correct and what action to take. It seems PREINIT would work the first time but not help in the case of a renewed lease. BOUND, RENEW, REBIND, REBOOT also seem like good candidates.

That is the background. Here is are the questions:
1. Does this approach seem reasonable? If not, is there a better approach?
2. Which operations should I look at and would behavior need to differ for different operations? For example, the documentation states that the RENEW operation has a new set of variables prefixed with old_. That cold possibly have different behavior than bound which has
3. Are there variables that I would set/unset in the script or should I edit the resolv.conf file directly from the script?
4. Has anyone else done anything like this and have a sample script to share? The scripts I have found online show how to call an external script but not how to manipulate the resolve.conf file.

This is the the script example I found online:
case "$reason" in

BOUND|RENEW|REBIND|REBOOT)
sh myscript.sh
;;

esac
mojosound
 
Posts: 2
Joined: 2018-09-14 15:21

Re: Modifications to resolv.conf

Postby shep » 2018-09-14 17:45

shep
 
Posts: 223
Joined: 2011-03-15 15:22

Re: Modifications to resolv.conf

Postby mojosound » 2018-09-14 17:58

Thanks shep but I already looked at that and it does not help. I need to trigger off of a DHCP event and remove any name servers from resolv.conf if none are provided by the DHCP server.
mojosound
 
Posts: 2
Joined: 2018-09-14 15:21

Re: Modifications to resolv.conf

Postby bw123 » 2018-09-14 18:17

If you want a default nameserver (never tried 0.0.0.0) unless dhcp sets/overwrites it, then I think resolvconf pkg is probably what you want. Check the wiki link shep gave you again carefully. You could write your own script also I guess, but why reinvent the wheel?
User avatar
bw123
 
Posts: 3516
Joined: 2011-05-09 06:02
Location: TN_USA


Return to System configuration

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable