What's new

Can't get dnsmasq conf to work

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Duncan Krebbers

New Around Here
I'm trying to intercept a click on Amazon Dash buttons to execute a script in my home automation controller, but I can't seem to get the jffs-part of it to work.

I followed the short guide from here, like this:

I've created two files on my computer

dnsmasq.conf.add
Code:
dhcp-script=/jffs/a/post-lease.sh

post-lease.sh
Code:
#!/bin/sh
touch /tmp/000wanstarted
NowLeasedMac=$2

# vitaminwater
if["$NowLeasedMac" == "mac-address1"]; then
wget "http://myip:3480/data_request?id=lu_action&output_format=xml&DeviceNum=28&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1"
echo "Caught Dash 1!"
fi

# starbucks doubleshot
if["$NowLeasedMac" == "mac-address2"]; then
wget "http://myip:3480/data_request?id=lu_action&output_format=xml&DeviceNum=28&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0"
echo "Caught Dash 2!"
fi
#

  1. I've enabled JFFS scripts and configs in the router and enabled SSH.
  2. Then, I connected via WinSCP and transferred the dnsmasq-file to /jffs/configs and gave it chmod 0777
  3. I created a jffs/a directory where I placed the post-lease.sh file, also with chmod 0777
  4. I've rebooted the router and pressed the dash-buttons but nothing happens. The log shows no sign of it and the /tmp/ folder is not created. The dash-buttons are showing in the client-list when I press them.
I've tried to rename dnsmasq.conf.add to dnsmasq.conf, but it doesn't work then either.
 
Check your System Log for any "custom config" event to confirm it was found by the firmware.
 
I've created two files on my computer
Make sure the end of line conversion (EOL) is Unix and not Windows.
Use Notepad++ to edit files if you are unsure, It's in the Edit menu.
 
Make sure the end of line conversion (EOL) is Unix and not Windows.
Use Notepad++ to edit files if you are unsure, It's in the Edit menu.
Thanks for your help, I've saved the files with Unix formatting now, but unfortunately this doesn't seem to change my problem. I've formatted the jffs partition and re-uploaded the files, but it still doesn't work and there is no mention of it in the log. I changed the log-level to show all messages: log file on Pastebin

Just to be sure, when I logged in to the router with WinSCP for the first time, I've clicked at the "up a level"-folder until I got to the root folder (with folders like asus_jffs, bin, cifs1, cifs2 etc). I opened the "jffs"-folder and placed the 2 files in the /a/ folder and /configs/ folder. That's correct, right?
 
Have a look at /etc/dnsmasq.conf

Make sure that your line (dhcp-script=/jffs/a/post-lease.sh) is being added to the end of it.

Regarding the /a/ folder; by convention user scripts would go in /jffs/scripts and config files in /jffs/configs. But in this case it shouldn't matter where your script is.
 
Does not work here either. Not as dnsmasq.conf.add and also not in dnsmasq.postconf as pc_append. The temp file does not get created.
dhcp-script is supported in the built in dnsmasq. Maybe @RMerlin knows why?
 
Have a look at /etc/dnsmasq.conf

Make sure that your line (dhcp-script=/jffs/a/post-lease.sh) is being added to the end of it.

Regarding the /a/ folder; by convention user scripts would go in /jffs/scripts and config files in /jffs/configs. But in this case it shouldn't matter where your script is.
I just run it in /jffs/scripts. No dice.
 
It works for me. But I'm using John's fork.
Code:
# grep dhcp-script /etc/dnsmasq.conf
dhcp-script=/jffs/scripts/test.sh

# cat /jffs/scripts/test.sh
#!/bin/sh
logger $0 $1 $2 $3 $4 $5 $6 $7 $8

# tail /tmp/syslog.log
May 11 01:22:19 dnsmasq-dhcp[1710]: DHCPACK(br0) 192.168.1.90 b8:8d:12:39:7b:48 mac
May 11 01:22:19 admin: /jffs/scripts/test.sh old b8:8d:12:39:7b:48 192.168.1.90 mac
May 11 01:22:19 dnsmasq-dhcp[1710]: DHCPREQUEST(br0) 192.168.1.90 b8:8d:12:39:7b:48
May 11 01:22:19 dnsmasq-dhcp[1710]: DHCPACK(br0) 192.168.1.90 b8:8d:12:39:7b:48 mac
May 11 01:22:19 admin: /jffs/scripts/test.sh old b8:8d:12:39:7b:48 192.168.1.90 mac
May 11 01:22:38 dnsmasq-dhcp[1710]: DHCPDISCOVER(br0) 192.168.1.156 b0:05:94:25:d8:b3
May 11 01:22:38 dnsmasq-dhcp[1710]: DHCPOFFER(br0) 192.168.1.156 b0:05:94:25:d8:b3
May 11 01:22:38 dnsmasq-dhcp[1710]: DHCPREQUEST(br0) 192.168.1.156 b0:05:94:25:d8:b3
May 11 01:22:38 dnsmasq-dhcp[1710]: DHCPACK(br0) 192.168.1.156 b0:05:94:25:d8:b3 PS4
May 11 01:22:38 admin: /jffs/scripts/test.sh old b0:05:94:25:d8:b3 192.168.1.156 PS4
 
Last edited:
Works for me. I created /jffs/configs/dnsmasq.conf.add then I issued a dnsmasq restart:

Code:
May 10 20:28:57 rc_service: service 22433:notify_rc restart_dnsmasq
May 10 20:28:57 custom config: Appending content of /jffs/configs/dnsmasq.conf.add.
May 10 20:28:57 dnsmasq[22436]: warning: interface ppp1* does not currently exist
May 10 20:28:57 dnsmasq[22436]: failed to execute /jffs/scripts/test.sh: No such file or directory

(I didn't create the actual test.sh, hence the errors)
 
My /etc/ folder does not contain a dnsmasq.conf file, so I created one myself and added the dhcp-script line to it. After reboot, nothing shows in the logs and the /etc/dnsmasq.conf file seems to be missing from the etc-folder again.

Code:
grep: /etc/dnsmasq.conf: No such file or directory

Could this have anything to do with my router being in Access Point mode?
 
Could this have anything to do with my router being in Access Point mode?
Doh!

Yes, this won't work in access point mode because it won't being running dnsmasq. You need put your script on the device that is running your LANs DNS/DHCP server (whatever that is).
 
Doh!

Yes, this won't work in access point mode because it won't being running dnsmasq. You need put your script on the device that is running your LANs DNS/DHCP server (whatever that is).

But that's the tricky part, the modem/router the Asus is connected to doesn't let me configure anything more advanced as a network-name. Since the Asus is the only device managing the wireless network I was hopeful I could pull this off this way.

Do you know of any other way to run a script on detection/connection of a specific Mac Address?
 
There's already been some discussions on these forums about this sort of thing (triggering events related to home automation devices). I'm not sure what the outcome was. Search the forums.
 
Most of the solutions I'm finding on the forums have to do with cronjobs that check for presence every x-minutes.

Like this one: Use Merlin for WiFiPresence

Since I'm trying to work with Amazon Dash buttons, I don't think this will work because they only stay active for about 10 seconds at a time. They do get discovered by the client list in the WebUI, so it seems to me there should be a way to get a script executed based on that detection.
 
Unfortunately there is no "event" that occurs when a client device connects. That is why those solutions use cron to periodically scan for the devices.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top