Static DHCP

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:04, 24 December 2009 (edit)
Kmcgrego (Talk | contribs)
m (How to add static leases into dhcp by command)
← Previous diff
Revision as of 19:49, 11 February 2010 (edit) (undo)
M00nman (Talk | contribs)
(How to add static leases into dhcp by command)
Next diff →
Line 56: Line 56:
redhawk redhawk
 +'''NOTE: Starting with build ''13832'' the format has changed to the following:'''
 +nvram set static_leasenum=X (total number of static leases)
 +nvram set static_leases="00:11:22:33:44:55=name1=IP-Address1= 00:11:22:33:44:55=name2=IP-Address2="
 +Note the '=' sign at the end of each lease. If you want to set static lease time then put a number after the last '=' to set time in seconds.
==Troubleshooting== ==Troubleshooting==

Revision as of 19:49, 11 February 2010

Static DHCP is a useful feature which makes the DHCP server on your router always assign the same IP address to a specific computer on your LAN. To be more specific, the DHCP server assigns this static IP to the network card of your computer. Every network card has its unique address - the so called MAC address (MAC = media access control), that is used to identify it on the LAN. Your computer boots and requests its IP from the router's DHCP server. The DHCP server recognizes the MAC address of your PC's network card and assigns the static IP address to it.

Static DHCP will be needed if you want your computer to always have the same IP address. Sometimes required for certain programs, this feature is useful if other people on your LAN know your IP and access your PC using this IP. Static DHCP should be used in conjuction with Port Forwarding. If you forward an external WAN TCP/UDP port to a port on a server running inside your LAN, you have to give that server a static IP, and this can be achieved easily through Static DHCP.

v23 Port Forwarding section in the Web GUI



  1. Log into the DD-WRT Web GUI
  2. Go to the Services tab
  3. DHCP Daemon should be enabled
  4. If there is no blank slot under "Static Leases", click Add
  5. Enter the MAC address of the client interface, the hostname of the machine, and the desired internal IP for this machine.
  6. Scroll to the bottom of the page and save your changes.
  • If you don't save these fields before clicking the Add button, your Static DHCP settings will be lost, and you'll have to enter the information again.

I don't know how to upload a picture, but the corrected screenshot is at

v23 DHCP Services section in the Web GUI

DHCP Options

The DHCP system assigns IP addresses to your local devices. While the main configuration is on the setup page you can program some nifty special functions here.

DHCP Daemon: Disabling here will disable DHCP on this router irrespective of the settings on the Setup screen.

Used domain: You can select here which domain the DHCP clients should get as their local domain. This can be the WAN domain set on the Setup screen or the LAN domain which can be set here.

LAN Domain: You can define here your local LAN domain which is used as local domain for DNSmasq and DHCP service if chosen above.

Static Leases: Assign certain hosts specific addresses here.

  • This is also the way to add hosts with a fixed address to the router's local DNS service (DNS masq).

The format for static allocations is:

<IP Address>  <##:##:##:##:##:##>  <Hostname>

Warning: Be sure to set your static IPs outside of your automatic DHCP address range. This range is by default and can be configured under Setup -> Basic Setup : Network Address Server Settings (DHCP). [An address within the automatic DHCP address range seems to work normally when configured as a static IP address on DD-WRT v24 (05/20/08) vpn. Edited on 10/3/09.]

NOTE: Make sure you do not have a blank set of fields (MAC, HOST, & IP). This will cause the error "Not a valid MAC address" because you left a MAC address field empty.


To assign the IP address and the hostname "mypc" to a PC with a network card having the MAC address 00:AE:0D:FF:BE:56 you should press Add then enter 00:AE:0D:FF:BE:56 into the MAC field, mypc into the HOST field and into the IP field.

Remember: If you press the 'Add' button before saving the entries you just made, they will be cleared. This is normal behavior in v24.

How to add static leases into dhcp by command

nvram set static_leasenum=X (total number of static leases)
nvram set static_leases="00:11:22:33:44:55=name1=IP-Address1 00:11:22:33:44:55=name2=IP-Address2"

If more than two...just keep adding them to the static_leases variable with a space between each.

Don't forget the double quotes...if you have any spaces (more than one lease) you must include the quotes to the variable.


NOTE: Starting with build 13832 the format has changed to the following:

nvram set static_leasenum=X (total number of static leases)
nvram set static_leases="00:11:22:33:44:55=name1=IP-Address1= 00:11:22:33:44:55=name2=IP-Address2="

Note the '=' sign at the end of each lease. If you want to set static lease time then put a number after the last '=' to set time in seconds.


If you cannot ping a hostname, append a period to the end. I.e. instead of "ping server" try "ping server."