Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Modifications to resolv.conf

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
mojosound
Posts: 2
Joined: 2018-09-14 15:21

Modifications to resolv.conf

#1 Post by mojosound »

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

#3 Post by mojosound »

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.

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Modifications to resolv.conf

#4 Post by bw123 »

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?
resigned by AI ChatGPT

Post Reply