Adding "Custom DNS Server" to /tmp/ via /lib/netifd/dhcp.script

Hi All,

I would like to add a custom DNS Server IP which will resolve custom FQDN addresses.

So, ISP provided DNS server will resolve common FQDN addresses and My custom DNS server will resolve specific/custom locally provided FQDN addresses.

For this, I have added this line echo "nameserver" >> /tmp/ at end to function setup_interface() in script /lib/netifd/dhcp.script. I have outputted '/tmp/' in dhcp.script and verified "nameserver" is successfully present in /tmp/

But If I view /tmp/ file from console, My DNS server is not present. Anyone can help me findout what is happening here??

Steps To Simulate :-
Empty '/tmp/dns_log.txt' file. NetIfd script output will be stored in '/tmp/dns_log.txt'.
root@OpenWrt:~# echo "" > /tmp/dns_log.txt

Empty '/tmp/' file.
root@OpenWrt:~# echo "" > /tmp/

To obtain new DNS address.
root@OpenWrt:~# /etc/init.d/network restart

View NetIfd script output.

root@OpenWrt:~# cat /tmp/dns_log.txt
DNS_DEBUG:NetIfd: Append Custom DNS Server: to /tmp/ [Status: 0]
DNS_DEBUG:NetIfd: Contents of /tmp/
# Interface wan

Checking '/tmp/' file. My DNS Server "nameserver" is lost.

root@OpenWrt:~# cat /tmp/
# Interface wan

PerumalPreformatted text

Why don't you do one of the following:

Client <> OpenWrt <> Local DNS <> Public DNS Servers Forwarders configured in Local DNS


Client <> Hostnames configured in OpenWrt <> Public DNS Forwarders configured in OpenWrt

Why do you not use the uci config /etc/config/dhcp and set there

list rebind_domain 'example.local'
list server '/example.local/'

in dnsmasq section.

This would resolve all domains as *.example.local and example.local with the dns server
The rebind_domain option is needed because dnsmasq prevents to resolve a domain with a local ip apart from your configured local domain.


Thanks for your time, I will take a look on this.

The proper solution is to simply add option dns to any of your interfaces in /etc/config/network.
Neither do you need to edit the DHCP handler script, nor /etc/config/dhcp.

For this requirement i prefer my solution.