Intention to use OpenDNS as the DNS server

Discussion in 'Tomato Firmware' started by Kiwi8, May 31, 2008.

  1. Kiwi8

    Kiwi8 LI Guru Member


    I intend to use the two OpenDNS servers as the first two DNS servers to refer too.

    I had also taken a look at this thread and know where to add them in:

    But I do not understand how to add in my ISP's DNS servers too as is the current case, as the backup in case it fails. My ISP's DNS servers might change, so how can I set my router such that it will query the ISP for the DNS servers' IP address?

    Thanks in advance.
  2. TexasFlood

    TexasFlood Network Guru Member

    Under Advanced -> DHCP/ DNS, tick the box for "Use Received DNS With Static DNS". But doing that defeats the filtering & blocking features of OpenDNS if those are important to you.
  3. Kiwi8

    Kiwi8 LI Guru Member

    Well, as mentioned in the thread:

    I want the OpenDNS servers to be queried first before the ISP's DNS servers. But it is not possible, it seems, or I do not know how to do it.
  4. srouquette

    srouquette Network Guru Member

    in the textarea under Advanced -> DHCP/ DNS, add this line:

  5. Kiwi8

    Kiwi8 LI Guru Member

    Yeah, but the problem is, my ISP gives me 3 DNS servers, so I can't put the two OpenDNS servers into the fields in the basic settings page, as that will leave only 1 for my ISP to give me only 1 DNS server. But if I put the OpenDNS servers into the configuration page, it'll be ranked behind the 3 ISP DNS servers.
  6. TexasFlood

    TexasFlood Network Guru Member

    If you know the DNS servers provided by your ISP, couldn't you add a startup script with a sleep up front to write your own /etc/resolv.dnsmasq file with all the entries you want?
  7. Kiwi8

    Kiwi8 LI Guru Member

    Possible... but I would prefer to obtain the necessary servers from the ISP via DHCP, just in case they change the server IP addresses.
  8. TexasFlood

    TexasFlood Network Guru Member

    I understand, just don't know how to do it, maybe a feature request. If you have "Use Received DNS With Static DNS" ticked on the Advanced -> DHCP / DNS page then you can periodically check the Basic -> DDNS page to see what servers are listed towards the bottom to see if anything has changed.

    *Edit: Now that I think about it, if the data is there to check visually then you should be able to find it and use it in a script. Did a quick look at the nvram variables and wan_get_dns looks like it contains the ISP supplied DNS entries so just parse that in your script to create the /etc/resolv.dnsmasq you want.

    I'm not much of a script writer but if you wanted to quick and dirty try this out, the below should work. Untick "Use Received DNS With Static DNS" so you just have OpenDNS entries in /etc/resolv.dnsmasq and this should add the ISP provided ones, this assumes that 3 are being provided as you previously stated. Might want to go check, do a "nvram get wan_get_dns" and see how many entries there are. If only two, as in my case, then remove the 3rd line. Put a sleep in front of it if you want to save it as a startup script. Not sure how long the sleep needs to be, maybe start with 5 and increase if it doesn't work. Actually, just tested it and I had to bump it to 10 for it to work as an Init script. Maybe it's a better fit for "WAN Up" than Init, maybe doesn't matter, not sure.

    *Note, seems to not work correctly with Tomato 1.21, changes get removed
    echo "nameserver" `nvram get wan_get_dns|cut -d " " -f 1`>>/etc/resolv.dnsmasq
    echo "nameserver" `nvram get wan_get_dns|cut -d " " -f 2`>>/etc/resolv.dnsmasq
    echo "nameserver" `nvram get wan_get_dns|cut -d " " -f 3`>>/etc/resolv.dnsmasq
  9. TexasFlood

    TexasFlood Network Guru Member

    Seems to be working OK here so far. Set it up this way here as well, to get the benefit of OpenDNS but the fallback of my ISP if needed. As I said, I'm not much of a script writer and somebody else here can probably come up with a more elegant way. But hey, if it works, that's what counts, :-D Lemme know if it works for you or not.
  10. Kiwi8

    Kiwi8 LI Guru Member

    Thanks, it seems to work here too. :)
  11. TexasFlood

    TexasFlood Network Guru Member

    Just loaded up dd-wrt so I can see what TCP Vegas is like and it works on dd-wrt as well, with some slight modications (path goes to /tmp rather than /etc).
  12. TexasFlood

    TexasFlood Network Guru Member

    Good to hear.

    FYI, I put mine under the WAN-Up tab and added some checking to make sure the DNS servers don't get added more than once. My ISP provided DNS servers both start with 68.67 so I just check and don't add them if there are already two entries matching that in the /etc/resolv.dnsmasq file.

    if [ `grep -c 68.87 /etc/resolv.dnsmasq` -lt 2 ]; then echo "nameserver" `nvram get wan_get_dns|cut -d " " -f 1`>>/etc/resolv.dnsmasq ;fi
    if [ `grep -c 68.87 /etc/resolv.dnsmasq` -lt 2 ]; then echo "nameserver" `nvram get wan_get_dns|cut -d " " -f 2`>>/etc/resolv.dnsmasq ;fi
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice