In the post DHCP/DNS Server on FreeNAS, I replaced the basic DHCP/DNS service available through my DSL router with a more advanced DHCP/DNS service using DNSMasq on FreeNAS. In this post, I repeat the exercise, but use DNSMasq on DD-WRT instead to achieve the same objective.
For this post, I’ll be working with Fritz!OS 06.98-55302 BETA, and DD-WRT build 35770 on a TP-Link Archer C7 DSL modem.
DD-WRT is Linux based firmware with advanced functionality for routers. What appealed to me about DD-WRT was the possibility of complementing my Fritz!Box with a more sophisticated router to overcome some of the Fritz!Box software limitations.
Which router should I use to run DD-WRT? Not all routers are compatible with DD-WRT. I had a boxful of old routers, none of which would support DD-WRT. The DD-WRT wiki suggested the TP-Link Archer C7 as a recommended router to buy. I picked one up from my local computer store for around AUS$150. I installed the most current version of DD-WRT I could find for it. This step is out-of-scope for this post. However, you will find it well documented in the DD-WRT wiki.
The primary objective is the same as for the post DHCP/DNS Server on FreeNAS with the difference being that DNSMasq on DD-WRT will be used instead DNSMasq on FreeNAS. Follow the steps in that post, but replace steps 3 and 4 with the steps described below.
As I had already implemented the FreeNAS version of DNSMasq, a personal objective for me was to add a backup DHCP/DNS server on cold standby that could be switched into service if required. Note that it isn’t possible to have a synchronised secondary DHCP/DNS server in active operation using DNSMasq (I’ve tried in vain!). The reasons are described here.
To accommodate the DD-WRT router, and to make the arrangement of DHCP servers more logical, I reworked the address ranges that the various DHCP servers, I could bring into play, would serve. This required me to review step 1 of the post DHCP/DNS Server on FreeNAS. The results are tabled below.
On my network, DNSMasq on the DD-WRT router will be configured to serve the block of 50 addresses starting at 10.1.1.101.
Step 3: Offline configuration of the DD-WRT router
Some initial configuration tasks on the DD-WRT router are required before it can be added to the network. The tasks include:
- IP configuration.
- Switching off gateway services.
- Switching off wireless services.
- Switching off DHCP services.
- Setting up time services.
This step is required to make the router network accessible. Find the relevant settings on the DD-WRT console under the Setup > Basic Setup tab. Don’t forget to save your settings after making changes by scrolling down to the bottom of the screen and clicking Save.
As I was aiming to set up a backup service, the Fritz!Box DSL modem is the internet Gateway and the Local DNS points to the primary DHCP/DNS server on my network i.e. DNSMasq on FreeNAS. If DNSMasq on the DD-WRT router is your primary service, set the Local DNS to match the Local IP address.
Switch off gateway services
The DSL modem (the Fritz!Box in my case) rather than the DD-WRT router is hosting the internet. Switch the DD-WRT router to router mode. Find the relevant setting on the DD-WRT console under the Setup > Networking tab. Set the Operating Mode to Router (the default is Gateway). Don’t forget to save settings.
Next, turn off the WAN port and assign it to the switch. Find the relevant settings on the DD-WRT console under the Setup > Basic Setup tab. Set WAN Connection Type to Disabled (the default is Automatic Configuration – DHCP). Tick the Assign WAN Port to Switch check box (the default is unticked). This will give you an extra port on the switch. You can use this port to connect the router to the existing network. Don’t forget to save settings.
Switch off wireless services
The DSL modem (my Fritz!Box) provides wireless services to the local network. It should be disabled on the DD-WRT router. Find the relevant settings on the DD-WRT console under the Wireless > Basic Setup tab. Set Wireless mode to Disabled (the default is Mixed) for both the 2.4 GHz and 5 GHz wireless frequencies. Don’t forget to save settings.
Switch off DHCP services
DHCP services are on by default on the DD-WRT router. These need to be switched off to prevent interference with the active DHCP/DNS server when the DD-WRT router is added to the network. Switch off the local DHCP server as well as DNSMasq. Find the relevant settings on the DD-WRT console under the Setup > Basic Setup tab. Select the Disable radio button for DHCP Server (the default is Enable). Untick Use DNSMasq for DHCP (the default is ticked). Don’t forget to save settings.
Set up time services
Set this up so that logs show the correct time and other time-dependent features of DD-WRT work correctly. Find the relevant settings on the DD-WRT console under the Setup > Basic Setup tab. Choose a Time Zone appropriate to your location. Don’t forget to save settings.
You can now reboot the router and swing it into service on the network.
Step 4: Configure and start DNSMasq
Add configuration parameters to the section Additional DNSMasq Options, which can be found on the DD-WRT console under the Services> Services tab. Refer to steps 4 and 6 of the post DHCP/DNS Server on FreeNAS for the parameters used.
In my case, a few parameters needed to be tweaked.
Modify listen-address to include the address of the DD-WRT router.
Adjust the dhcp-range that the DD-WRT router should serve.
The DD-WRT router is the DNS server.
Don’t forget to save and apply settings.
We’re now ready to turn on DNSMasq. Refer to the screenshot below. Find the relevant settings on the DD-WRT console under the Setup > Basic Setup tab. Don’t forget to save and apply settings.
That’s pretty much it if the DD-WRT router is primarily providing an enhanced DHCP/DNS service to the network.
In a backup arrangement, like mine, DNSMasq has to be disabled on the DD-WRT router so that it doesn’t interfere with the operation of the primary DHCP/DNS server. It will be enabled only if the primary DHCP/DNS server fails. The switch that turns the backup DHCP/DNS service on and off can be found on the DD-WRT console under Services > Services.
In a backup arrangement, an essential housekeeping task is to keep the configuration parameters on the primary and backup DHCP/DNS in sync. This has to be done manually, but is as easy as copying and pasting from one system to the other.
- DHCP/DNS Server on FreeNAS
- DD-WRT Wiki
- TP-Link Archer C7
- DD-WRT Install Guide for the TP-Link Archer C7
- Secondary/tertiary dns servers in dhcp offers?
- DNSMasq as DHCP Server
- DD-WRT Network Device Interfaces
- Dynamic Host Configuration Protocol
- Dynamic Host Configuration Protocol (DHCP) and Bootstrap Protocol (BOOTP) Parameters