Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

First to restart DNSMasq use:

killall dnsmasq
dnsmasq --conf-file=/tmp/dnsmasq.conf

There are a few things to note:

There are two main files /tmp/dnsmasq.conf and /tmp/hosts.

  • When you change dnsmasq.conf and restart dnsmasq it will revert back to the way it was
  • You can edit /tmp/hosts and restart DNSMasq and it will read from /tmp/hosts
  • Having an entry in /tmp/hosts and /tmp/dnsmasq.conf will cause conflicts
  • /tmp/hosts gets overwritten upon reboot
  • Your best bet is to get it working, then setup a start-up script in dd-wrt. >> See https://wiki.dd-wrt.com/wiki/index.php/Startup_Scripts for howto, I used WebGUI for convenience.
  • I couldn't write files to my router so I store scripts on NAS

My example test case was blocking YouTube upon initial boot and creating a script to manually block and unblock it afterwards. It was a fun adventure!

I used the DD-WRT WebUI to setup the following command at startup which defaults to blocked:

  • If I wanted it unblocked by default I could omit this step
echo '127.0.0.1    youtube.com' >> /tmp/hosts && killall dnsmasq ; dnsmasq --conf-file=/tmp/dnsmasq.conf

I then created two scripts to be executed over SSH:

Enable YouTube:

sed -i '/youtube/d' /tmp/hosts && killall dnsmasq ; dnsmasq --conf-file=/tmp/dnsmasq.conf

Disable YouTube:

echo '127.0.0.1    youtube.com' >> /tmp/hosts && killall dnsmasq ; dnsmasq --conf-file=/tmp/dnsmasq.conf

Source:

https://wiki.dd-wrt.com/wiki/index.php/DNSMasq_Local_Network#6.29_Custom_dnsmasq_started_from_jffs2_or_mmc

 

  • No labels

1 Comment

  1. If anybody wants my windows scripts let me know, I have it down to two clicks and one keypress to block or unblock youtube!