DNSMasq as DHCP server
From DD-WRT Wiki
Revision as of 17:07, 6 December 2008 (edit) Interval (Talk | contribs) m (→Using Web-Admin - conf blurb) ← Previous diff |
Revision as of 10:17, 7 December 2008 (edit) (undo) Interval (Talk | contribs) (Added udhcpc blurb) Next diff → |
||
Line 1: | Line 1: | ||
DD-WRT supports using [http://www.linux.org/apps/AppId_6060.html DNSMasq] "as local DNS server" and also uses the DHCP service [http://udhcp.busybox.net/ "udhcpd"]. This is a waste of RAM (router has 16MB total and only 3MB free). | DD-WRT supports using [http://www.linux.org/apps/AppId_6060.html DNSMasq] "as local DNS server" and also uses the DHCP service [http://udhcp.busybox.net/ "udhcpd"]. This is a waste of RAM (router has 16MB total and only 3MB free). | ||
With DNSMasq as the sole DHCP server you can save 300kB (udhcpd deactivated!). With this savings you can create one more PPTP tunnel with the inserted PPTPD server. | With DNSMasq as the sole DHCP server you can save 300kB (udhcpd deactivated!). With this savings you can create one more PPTP tunnel with the inserted PPTPD server. | ||
+ | |||
+ | udhcpd, a DHCP server (daemon), is not to be confused with udhcpc, the DHCP client. Most setups require that the router run udhcpc to acquire DHCP leases for the WAN interface. | ||
There are two ways to accomplish this | There are two ways to accomplish this |
Revision as of 10:17, 7 December 2008
DD-WRT supports using DNSMasq "as local DNS server" and also uses the DHCP service "udhcpd". This is a waste of RAM (router has 16MB total and only 3MB free). With DNSMasq as the sole DHCP server you can save 300kB (udhcpd deactivated!). With this savings you can create one more PPTP tunnel with the inserted PPTPD server.
udhcpd, a DHCP server (daemon), is not to be confused with udhcpc, the DHCP client. Most setups require that the router run udhcpc to acquire DHCP leases for the WAN interface.
There are two ways to accomplish this
- Using the Web-Interface (for beginners who want to use the default options)
- Using DNSMasq parameters (for advanced users who can understand dnsmasq.conf file layout, and know where to find the manual page for it)
You can NOT use both
Contents |
Configuration
Using Web-Admin
This is the easiest way to setup DNSMasq as DHCP Server
- Go to your Web-Interface and log in
- Go to Setup->Basic Setup
- Make sure that
- DHCP Type = DHCP Server
- DHCP Server = enabled
- Use DNSMasq for DHCP = checked
- Make sure that
Make sure that the maximum number of DHCP leases that you set is appropriate for your netmask; otherwise, DNSMasq will not start.
- Go to Administration->Services
- Make sure that
- DHCP Daemon = enabled
- Make sure that
- You can add static allocations the same way as when you're using DHCPd. These settings should end up in /tmp/dnsmasq.conf.
DNSMasq parameters
This provides access to more functionality at the expense of not being able to use the structured web interface.
Following steps are necessary:
- Deactivate the DHCPD service on the "Setup" page.
[Comment: above step deactivated all DHCP for me and wasn't needed anyway - andmalc 4/2008]
- Under the "Administration" tab in the "Services" sub tab, you will find a "DNSMasq" section. Enable "DNSMasq", and "Local DNS", then under "Additional DNS Options", you need to set some parameters.
* To setup the default options for Dynamic IP Allocation, add: dhcp-range=192.168.1.100,192.168.1.150,255.255.255.0,24h
* To setup machines to have a Static IP assigned by the router, add either: dhcp-host=AB:CD:EF:11:22:33,192.168.1.10,24h or dhcp-host=computername,192.168.1.10,24h
AB:CD:EF:11:22:33 is the MAC of the network, computername is the NetBIOS name of the computer on the network, 192.168.1.10 indicates the desired IP, and finally 24h the DHCP lease of 24 hours, however if you wish to have the lease for the machine never expire, you may do so by changing 24h to infinite.
If it's not possible to assign an IP with DNSMasq and you want to identify devices via name resolution, you must add the following lines:
no-hosts addn-hosts=/tmp/hosts
You must also add this computer to /tmp/hosts:
192.168.0.5 printers drucker.lan
[Comment: In v23-SP2 (and possibly other versions) /etc/hosts is simply a softlink to /tmp/hosts. To get the last part to work you need to remove the no-hosts part and specify a separate hosts file for the static assignments. --Wishyou 22:57, 19 June 2008 (CEST) ]
Extra DNSMasq options
There are some extra options you can set by entering them in Additional DNS Options
If you are using the Web-Admin method then you can enter additional options in the Administration/Management tab under Additional DHCPD Options
ISP DNS-Servers
If you wish to pass through the DNS servers from your ISP, you can use the following parameters:
dhcp-option=6,x.x.x.x,y.y.y.y x.x.x.x = DNS1 y.y.y.y = DNS2
Assign an alternate Gateway
By default, dd-wrt will hand out via DHCP its own IP as the Gateway. You can specify an alternate one like so:
dhcp-option=3,x.y.z.w
Denying DHCP service to specific MAC addresses
You can ignore requests from specific MAC addresses, so that no IP address will be leased to those specific MAC addresses/machines
dhcp-host=11:22:33:44:55:66,ignore 11:22:33:44:55:66 = MAC address of the machine you wish to ignore
Enable TFTP server
You can start a tftp server serving files from "/opt/tftpboot"
enable-tftp tftp-root=/opt/tftpboot
Disable NetBIOS over TCP/IP
Since DNSMasq acting as a local DNS server suitably takes care of host name resolution, disabling NetBT on appropriately configured Microsoft DHCP clients, such as Windows 2000 and XP, can be accomplished with the following:
dhcp-option=43,01:04:00:00:00:02
Troubleshooting
It's possible to verify that the options you set in the web interface match those being passed to DNSMasq. telnet to your router's IP address and log in as root with your usual password. Then:
cat /tmp/dnsmasq.conf
The options should match the command-line format specified in the DNSMasq man page.
You should also make sure that DNSMasq is running at all. To do so, while in telnet issue
ps | grep dnsmasq
The output should look like:
144 root 772 S dnsmasq --conf-file=/tmp/dnsmasq.conf 2966 root 508 S grep masq
If the first line is missing, DNSMasq isn't running and may have been unable to start due to one of its options being set incorrectly.
External Links
http://www.faqs.org/rfcs/rfc2132.html Options on MAC addresses
References
http://blog.ptch.de/index.php?/archives/33-WRT54G-DNSMasq-als-DHCPD.html