Which one WAN or LAN?So, say I wanted to change the DNS1 setting (as shown in this post) via SSH; how would I do it? i.e. which command(s) would I use?
Under DNS and WINS settingsWhich one WAN or LAN?
Yes. You also need this for it to take effect for new clients.I think I got it sorted out, does this look right?
Code:nvram set dhcp_dns1_x=192.168.0.234 | nvram commit
service restart_dnsmasq
What OS are you using? The behaviour you want is exactly what Windows does, it only uses the 1st DNS server and will only use the second if it doesn't get a response within 1 second from the first.Adding a second DNS IP to the "DNS 2" settings anywhere just causes the software to use both DNS's, bypassing Pi-hole half the time.
Well, I have the DNS set on my router, so that all devices on my LAN go through my Pi-hole + DNSCrypt; so Linux I guess is my OS in this case.What OS are you using? The behaviour you want is exactly what Windows does, it only uses the 1st DNS server and will only use the second if it doesn't get a response within 1 second from the first.
No, I mean the OS of the DHCP client. e.g. Windows 7, MacOS, etc.Well, I have the DNS set on my router, so that all devices on my LAN go through my Pi-hole + DNSCrypt; so Linux I guess is my OS in this case.
I've just checked this with a Windows 7 client and dnsleaktest.com and it's working as expected, i.e. only using DNS1 when both are DNS1 and DNS2 are defined.I've already tried using LAN IP as DNS1 and a regular public IP (like 1.1.1.1) as DNS2 in the router, but when I checked with a leaktest site, it was showing me that about half of the requests were still using the DNS2 IP, bypassing my pihole setup.
No, I mean the OS of the DHCP client. e.g. Windows 7, MacOS, etc.
I've just checked this with a Windows 7 client and dnsleaktest.com and it's working as expected, i.e. only using DNS1 when both are DNS1 and DNS2 are defined.
EDIT: I don't use DNSCrypt so it's possible that that is slowing down your DNS responses to such and extent that it's failing over to the second DNS server.
EDIT 2: Just checked from an Ubuntu 18.04 client and that's working as expected as well.
Yes. You also need this for it to take effect for new clients.
Code:service restart_dnsmasq
nvram set dhcp_dns1_x=123.123.123.123 | nvram set dhcp_dns2_x=321.321.321.321 | nvram commit | service restart_dnsmasq
Clients won’t get the new DNS settings until they renew their DHCP leases, and that is up to the client.Me again, Colin!
SO I've gotten back around to playing with this and some weird things are happening. First Let me just describe my desired behavior:
I simply want to be able to run the command:
Code:nvram set dhcp_dns1_x=123.123.123.123 | nvram set dhcp_dns2_x=321.321.321.321 | nvram commit | service restart_dnsmasq
And had the router just start using those new DNS's without a restart/reboot.
Using that code so far does change the DNS's properly, however, it's very squirrly whether any device will instantly start using the new DNS's. For example, on a Windows 10 machine, I have the NIC adapters set to 'automatically get DNS', and if I do a ipconfig /all sometimes it'll show the DNS switch properly, other times it'll still show the old one, even after doing a ipconfig /flushdns.
Other times it seems to work right away.
Last night, all devices on the LAN behind the router stopped working, even after reboots (of the devices). The only fix was to hard reboot the router via power cycle. Very confusing.
Anyone with more expertise in this area than I (which is near zero) have any idea what's happening?
Using pipes (|) for the above code would be bad practice. I suggest you change "|" to ";"I simply want to be able to run the command:
Code:nvram set dhcp_dns1_x=123.123.123.123 | nvram set dhcp_dns2_x=321.321.321.321 | nvram commit | service restart_dnsmasq
Hi DaveClients won’t get the new DNS settings until they renew their DHCP leases, and that is up to the client.
Thanks, I was wondering that myself last night after I posted, and saw a post on stack that also said that.Using pipes (|) for the above code would be bad practice. I suggest you change "|" to ";"
nvram set dhcp_dns1_x=123.123.123.123; nvram set dhcp_dns2_x=321.321.321.321; nvram commit; service restart_dnsmasq;
nvram set dhcp_dns1_x=123.123.123.123; nvram set dhcp_dns2_x=321.321.321.321; nvram commit; service restart_dnsmasq; reboot
nvram set dhcp_dns1_x=123.123.123.123; nvram set dhcp_dns2_x=321.321.321.321; dhcp_enable_x=0; nvram commit; dhcp_enable_x=1; nvram commit; service restart_dnsmasq
You could try either of these network restart commands to force clients to disconnect and maybe renew their leases. Not sure it will work, and I haven’t tested it before suggesting it.Does anyone have any other ideas for this? A better workaround, or anything at all? Also, is there some sort of "soft" reboot command available that sort of "fast boots" the router rather than a full, slow reboot?
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!