1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Store DHCP leases in NVRAM?

Discussion in 'Tomato Firmware' started by mobrien118, Apr 29, 2009.

  1. mobrien118

    mobrien118 Addicted to LI Member

    Hi,

    Before I started tinkering and eventually bricked my WRT54G, which led me to discover this forum, I was looking for a way to keep DHCP leases in NVRAM.

    I can do this with DD-WRT, which is helpful for my setup where I have a MySQL server that I like to refer to by name, rather than IP, which has a static DHCP lease. I don't mean for this post to get into a discussion about why or why not this is a good idea*, but it works perfectly for my setup and I was wondering if Tomato affords the same functionality.

    Thanks,

    --mobrien118

    * If you'd like to discuss the pros/cons of my setup, we can do that too, but I just want to *kind of* stay on topic if possible. I love a *good* discussion, though.
     
  2. Kiwi8

    Kiwi8 LI Guru Member

    I thought Tomato already has a static DHCP page to add in hostnames for any particular private IP address u want?
     
  3. mobrien118

    mobrien118 Addicted to LI Member

    True! It does have static leases, but my experience with DD-WRT has been that if the router power cycles or reboots (due to power failure, config change, etc.) while the clients will still be accessible at the same IP address, it won't be accessible by its machine name until it re-acquires DHCP, thus being re-entered into the active clients lease table. I would assume this behavior would be the same for tomato, because if the leases are stored in volatile memory (I assume the default) then they would be cleared when power is cleared or memory is reset.

    Just to give a little supporting explanation on what i mean, when DNSMasq gets a request for a client lease, lt will look in the STATIC LEASE table for a match, if it's not there is will use an algorithm to calculate an IP address. Once an IP address has been assigned, the lease is entered into the ACTIVE LEASES table until either the lease expires (doesn't happen with static leases since they're permanent as long as the router is up) or it is removed due to expiration or cancellation.

    With DD-WRT, there is a box to check that will store the active lease in NVRAM, so that even if the power is pulled, when you boot back up, all of the leases (even temporary ones) are still there until they expire.

    Anyway, it's a great feature, and if it's not available in Tomato I think a feature request should be made for it!

    Hope this makes sense.

    --mobrien118
     
  4. fyellin

    fyellin LI Guru Member

    On Tomato, if a machine is listed in the static-lease table, it is accessible by the name given in that table even if has never gotten a lease. I use this trick so that some machines on my network that can't use DHCP can still be accessed by name.

    So giving all the machines you care about static IP addresses is one solution to your problem.
     
  5. mobrien118

    mobrien118 Addicted to LI Member

    Well, I guess that answers my question! Sorry, I would have tried it first before posting here, but, like I said, I bricked my only router available for testing.

    This is a great feature of Tomato and I'm very happy about that!

    Sorry to possibly prolong this thread, since technically my "requirements" are met, but curiosity always gets the best of me: I am still interested in whether or not there is an NVRAM way to store leases on Tomato because the one thing it allows for that isn't accounted for by fyellin's response is clients that DON'T have a static lease. In DD-WRT, they would be preserved through a power cycle while the Tomato way they wouldn't (I think).

    Like I said, this isn't that important, so if you don't know a way to do it, don't worry about posting and just let this thread settle to the bottom. I am already greatly considering changing my main router to Tomato after a little bit of testing on my soon to arrive new router and once I have a little of that "spare time" thing I keep hearing about. ;-)

    Cheers!

    --mobrien118
     
  6. fyellin

    fyellin LI Guru Member

    I don't think this is possible. Other posters may prove me wrong.

    I can't read JonZ's mind, but it seems that one of the design decisions of Tomato is to modify the nvram as little as possible. For the most part, changes to nvram are made only in response to user changes in the configuration. The "running" of Tomato is all done in ram.
     
  7. mstombs

    mstombs Network Guru Member

    I'm also not keen on auto nvram writes so generally also use the Tomato setting in the administration>debugging to "Avoid performing an NVRAM commit". Without this certain things are auto saved after wan reconnect, ddns update etc - I recall nvram commits go in the log.

    Windows and Wii's seem to do lot of dhcp requesting I wouldn't want every succesfull one to be written to flash.

    If all that is needed is saving the lease file before a controlled shutdown and restoring before re-enabling dnsmasq, then could probably be done with scripts - but wouldn't help with power cuts etc.
     

Share This Page