DHCP server in tomato

Discussion in 'Tomato Firmware' started by skiv71, Oct 14, 2008.

  1. skiv71

    skiv71 Addicted to LI Member

    Hi, i have a router running latest tomato.

    I need to have the clients configured with split DNS and i havent been able to do this using tomato alone.

    So i disable the DHCP and leave a standalone PC running with a DHCP server configured to give clients 2 DNS servers...

    i.e. DNS1: (AD DNS server)
    DNS2: (tomato router)

    can i configure tomato to configure clients with the same info.

    everytime i've tried, the clients just have the tomato router as DNS and not 2, or first choice as the AD DNS server.

    If i can, then i can reenable DHCP server on the tomato and ditch the standalone PC running a DHCP server.


  2. mstombs

    mstombs Network Guru Member

  3. HennieM

    HennieM Network Guru Member

    Yes, you need to get this line (or similar) into the DNSmasq config (usually /etc/dnsmasq.conf)
    dhcp-option = option:router,,
    which lists both routers (default gateways) in the order that you prefer.

    See http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html and then figure out how to manipulate the "Dnsmasq Custom Configuration" under Advanced > DHCP/DNS in Tomato.

    Alternatively, I would THINK that you can write a script that just appends the above line to your dnsmask.conf, followed by a restart of dnsmasq.
  4. skiv71

    skiv71 Addicted to LI Member

    hi, thanks for the input.

    i'm having probs editing the dnsmasq.conf file. i edit it, save it, even commit (not sure if i should be doing this bit?) and the changes dont take.

    just to confirm, adding the option:router, will give clients 2 DNS servers, as shown in the status properties?

    or will they still have a single DNS of <router> and the router will query these in order?

    I really want the first.


  5. HennieM

    HennieM Network Guru Member

    My apologies - I gave you the router option, and not the DNS server option. (I have learnt to read at some stage, but it evades me from time to time...;)

    Anyway, regarding editing files on your Tomato (or any device running off firmware for that matter).

    The files in /etc are all temporary files created in the RAM of the router. More specifically, Tomato makes a RAM disk, which it mounts under /tmp. Within /tmp, it creates a directory etc. This /tmp/etc directory is then symlinked to /etc. So, when you work in /etc, you are actually working in /tmp/etc, or on the ramdisk. The ramdisk becomes nothing/blank when your Tomato restarts, and Tomato creates files and stuff on this ramdisk everytime it starts up.

    What you want to do, is create some script or variables that are stored in Tomato's non-volatile RAM, and then manipulate this piece of code from nvram into the correct file on the ramdisk when Tomato starts up. The variables and stuff stored in nvram needs to be put in there using a special program, and similar for reading the nvram variables. Luckily Jon (Tomato's author) made it easy for us store/read stuff to/from nvram.

    Done with the lecture, now for some more practical hints.

    To have one or more DNS servers used by Tomato, you need to get the lines
    into these 2 files


    (I don't know which one Tomato and dnsmasq uses, so I would modify both to be safe).

    These file(s) would already contain one of the desired lines - the default name server that you specify in the normal setup of Tomato. We therefore need to append the line containing the 2nd name server. For this discussion, we assume the resolv.conf files(s) already contain the line
    so we want to append the 2nd one.

    In Tomato, go to Administration > Scripts, and you'll find a box under "Init". Into that box, paste this
    sleep 10
    echo "nameserver" >> /etc/resolv.conf
    echo "nameserver" >> /etc/dnsmasq.conf
    and save it. (This save now saves your init script into nvram, so no fiddling with reading/writing nvram required).
    When Tomato now (re)starts, the init script wil run, but the script will first wait 10 seconds for Tomato to finish its startup things, and then append the desired line to both files.
  6. skiv71

    skiv71 Addicted to LI Member

    hi again..

    ta 4 the further advice, but alas still no joy. clients have only the router as dns and not the split arrangement i was hioping for (like i can distribute with my pc based dhcp server).

    is dnsmasq a dhcp server?

    are we going about this the right way?

    in my dhcp server i can list:-



    i wish it were that simple with this router.


  7. HennieM

    HennieM Network Guru Member

    Set your DHCP to have the clients point to Tomato as their DNS server. Tomato will query the 2 DNS servers in turn.
  8. Thyrael

    Thyrael Addicted to LI Member

    you can untick the option "Use Internal Caching DNS Forwarder" in Advanced -> DHCP/DNS in your router and do a release/renew on your computers. it works for me but i dont use internal dns servers.
  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