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

/etc/hosts file

Discussion in 'Tomato Firmware' started by otterson, Oct 18, 2008.

  1. otterson

    otterson Addicted to LI Member

    Is there any way to make the /etc/hosts file non-volatile?

    I want to have Tomato's DNS resolve local names, and when I put the names in /etc/hosts, that works. But I want to make that survive reboots...

    Is there a way to do this?

    Thanks,

    Jeff
     
  2. humba

    humba Network Guru Member

    You could write out a new file from one of the scripts you can add to tomato.
    Personally, what I did instead was adding static dhcp leases even for devices that don't use dhcp.. that will also result in the names being resolved appropriately from within my lan.
     
  3. mraneri

    mraneri LI Guru Member

    Yup. That's the best way to add a few IP's to DNS so they resolve... If you're looking to do ad blocking with your non-volatile hosts file, This is another option.

    I actually do both. (When you use static DHCP addresses, those actually go in /etc/hosts.dnsmasq, which is independent of etc/hosts... and dnsmasq loads BOTH files...)

    - Mike
     
  4. otterson

    otterson Addicted to LI Member

    Awesome. Thanks, Mike. I modified the script to fetch my hosts file from a local server.

    Jeff
     
  5. mraneri

    mraneri LI Guru Member

    Good deal. Glad it helped.

    You may want to change the delay before it fetches though, unless you're on a UPS, if you lose power, surely the router will come up and try to fetch the file before the server does.

    Just keep that in mind, or change the sleep delay to something like 5 minutes or so.

    - Mike
     
  6. m007

    m007 LI Guru Member

    I am using Dnsmasq for DNS cache with hosts. I just enable JFFS2 and create a new file in /jffs/hosts with list of LANs. Then add 'addn-hosts=/jffs/hosts' in Advanced -> DHCP/DNS -> Dnsmasq Custom Configuration box. It gets Dnsmasq to read /jffs/hosts. It works so far.

    Code:
    Dec 31 18:00:17 Router daemon.info dnsmasq[85]: read /etc/hosts - 0 addresses
    Dec 31 18:00:17 Router daemon.info dnsmasq[85]: read /jffs/hosts - 26 addresses
    Dec 31 18:00:17 Router daemon.info dnsmasq[85]: read /etc/hosts.dnsmasq - 1 addresses
    I wish firmwire has a feature to allow us to edit /etc/hosts by via WebUI.
     

Share This Page