Posted: Fri Dec 30, 2011 18:54 Post subject: howto: replace stock dnsmasq with optware dnsmasq
Posting this because it took me a bit of digging to figure out and I did not find a tutorial or howto anywhere else. There may be better ways, if that is the case please let me know - I am still a dd-wrt newb. Hopefully it helps a few of you. It might belong on the wiki but that does not want to let me create an account so I'm posting it here for now.
Here is how I did it and why:
Why: I had a dying computer that was hosting dnsmasq for my SOHO LAN. I have a few computers, some Android devices, VOIP, DNLA, blah blah blah going and I like dnsmasq for the control it gives me over DHCP and DNS. Caching DNS helps as well. I need to retire this poor old PC and move on. I'm not sure why but the built in dnsmasq did not like the configuration options I had in my old dnsmasq.conf and I got tired of trying to figure out what the problem was and decided to just use the optware version which as of this writing is the latest and greatest and is also the same as was running on my Ubuntu computer that was dying. I also had some static addresses that I wanted to assign, etc.
Everything works fine for me at this point except dnsmasq which as I said above, doesn't like whatever I am trying to do.
Once installing optware core was complete I ran into a couple of challenges.
1. How to get the new dnsmasq installed? I'm new to optware and so wasn't real sure.
2. How to get the installed optware version of dnsmasq working?
3. How to get the default to stay shutdown?
4. How to get the optware version to run at startup.
So, I am not a newb when it comes to linux but as I said I am new to dd-wrt and optware.
The blow by blow:
To find out what packages are available (optware must be installed and working) use ipkg:
That is going to be a ton of crap so try this:
ipkg list|grep dnsmasq
and you should get this:
root@fsmsouth:~# ipkg list|grep dnsmasq
dnsmasq - 2.59-1 - DNS and DHCP server
OK, so now install it:
root@fsmsouth:~# ipkg install dnsmasq
Installing dnsmasq (2.59-1) to /opt/...
To complete the installation, you should check /opt/etc/dnsmasq.conf,
and then run /opt/etc/init.d/S56dnsmasq to start dnsmasq.
Now we have it installed but the default dnsmasq supplied with dd-wrt is still running. To complete the next few step it would be helpful if you were using a wired ethernet connection to the router and using a static IP address in case something goes wrong. Something like dnsmasq or the built in dhcp not giving out addresses on the network while you are messing with the router. Just saying you might want to stop right here and assign yourself a fixed IP for a few minutes.
So now that we are using a wire and have a fixed IP (you were paying attention right?), we will proceed.
Go to Setup->Network Address Server Settings (DHCP)
Disable DHCP Server and all DNSMasq options here
Save (down at the bottom of the page)
Go to Services->DNSMasq and disable dnsmasq
Wait for the router to let you back in (right about now you are wishing you had a static IP address since DHCP is now completely off and dns is shutdown and if you don't have a static ip you are bummed out and I am the honeybadger )
We need a working dnsmasq config and we want it to survive subsequent dnsmasq upgrades etc. The default conf file for the optware version is /opt/etc/dnsmasq.conf so, ssh to the router (or telnet if that is your thing):
and now lets edit the default file with vi (you are a cool kid eh? or do you use some other editor?)
go to the last line of the file and add this (or be a wild child and put it as the first line, it doesn't matter, the whole of the default file is commented out)
":wq" i.e. save and exit
Now edit /opt/etc/dnsmasq.local.conf and configure it however you want. Most of my version is below, all comment lines are stripped out for your enjoyment (grep -ve "^\#" dnsmasq.local.conf |grep -v '^\W*$')
Yes, I know, /opt/etc/dnsmasq.leases is not really the places to be writing things to but I like having all my dnsmasq stuff in one place - I'm lazy that way.
contents of /opt/etc/dnsmasq.local.hosts - this can be used to replace /etc/hosts when using dnsmasq - but read the man pages for details
contents of /opt/etc/dnsmasq.local.resolv
# these are the dns servers at opendns.com - put whatever name servers you want here
Now we need a service to run. ipkg will have installed a startup script in /opt/etc/init.d called S56dnsmasq but it will not run on my Csico E3000 - it pukes out some errors and doesn't list correctly as a service, have proper start, stop, and status options so I backed up the original, copied the init script from portmap and changed it to run dnsmasq - it could probably be cleaned up even more but this one works for me, we'll also create a link to a shutdown script while we are at it:
Looks like you are linking the start script with the kill script.
I would have thought you wanted to disable the stock DNSMasq on the Router's webgui (SERVICES tab) and let the S56dnsmasq optware script start when the Optware scripts get called.
Maybe I missed something.
@ zoomlink glad you enjoyed it
Sorry for the delayed response - just wandered back to the forum.
In order to successfully get the stock dnsmasq to stay disabled I had to disable it in the two places that I mentioned.
The link to the kill script is a common technique for scripts that support start and stop as a parameter. The S series scripts in init.d get called in alpha numberical order during startup and the K ones during shutdown. So I am cleanly shutting down dnsmasq. However, re-reading your comment did give me pause to go and move my modified S56dnsmasq scripts so that they don't get clobbered during future optware upgrades.
These steps do not appear to work with "dnsmasq v2.62-1" as I am getting an error of
/opt/sbin/dnsmasq: can't resolve symbol '_dl_app_init_array'
when trying to run dnsmasq.
Anyone got a solution to this?
Notes: Using E3000 with 19545M KongVPN K26
Try sudo /opt/sbin/dnsmasq . _________________ 3 times Asus RT-N16 running Merlin fork RT-N16_184.108.40.206_374.43_2-23E3j9527.trx with entware-ng, formerly used Kong 22000++ kingkong-nv32k-broadcom with OTRW2
Joined: 24 Feb 2009 Posts: 2026 Location: Sol System > Earth > USA > Arkansas
Posted: Sun Jan 20, 2013 16:36 Post subject:
Try sudo /opt/sbin/dnsmasq .
That is actually not even related to the problem.
If dnsmasq has what it considers "errors" in its configuration file, it dies and gives the above error. This is not limited to the problem of running as root. Therefore one must put the "user=root" option in the configuration file to properly work under DD-WRT.
So many quirks with DD-WRT. So little information. _________________ E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]
Try Dropbox for syncing files - get 2.5gb online for free by signing up.