SEARCH

How-To Geek

How To Set Up Static DHCP on Your DD-WRT Router

banner-01

DHCP makes it simple to configure network access for your home network, and port forwarding makes it easy to those computers from anywhere. By configuring static DHCP on your DD-WRT router, you can combine the best of both worlds.

The Problem with DHCP and Port Forwarding

DHCP is great. You configure your router to automatically assign IP addresses and the computers on your network just plain work. Port forwarding is useful because you can access your router from outside of your network and be redirected to the computer you need inside of your network. The problem is that these two wonderful things rely on one premise: your internal IP addresses don’t change. If your router changes the IP that is assigned to a machine by DHCP, then you have to reconfigure Port Forwarding. Many programs try to get around this fact by offering Universal Plug and Play (UPnP) port forwarding features, but not everything does.

sshot-3

Newer routers often have the ability to remember which IP address was assigned to which computer, so if they disconnect and reconnect their IP doesn’t change. Often, though, a router reset will wipe this cache and start assigning IPs on a first-come, first-served basis. Tons of older routers don’t even have this ability, and immediately assign new IP addresses. With IP addresses changing, you have to reconfigure your port forwarding settings often, otherwise you may lose the ability to connect to your home computers.

We’ve touted DD-WRT’s ability many times before, and it’s not for nothing. This amazing custom router firmware has a solution to this mess: static DHCP, also known as DHCP reservation. While configuring your router for DHCP, you have the ability to enter the MAC addresses of your computers’ network cards and enter which IP address to assign them. DD-WRT will automatically take care of the rest!

Finding Your MAC Address

The only real work you’ll have to do is find the MAC address of each computer’s attached networking card. If you’re using wireless then you should find the MAC of your wireless card, and if you’re wired then use the Ethernet card.

Just go down to the icon in your system tray for your connection and click it. Mine is wireless.

sshot-6

Right-click on your current active connection and click on Status.

sshot-7

Click on the “Details…” button.

sshot-8

Your MAC address for this device is listed as “Physical Address.”

OS X users can check under their System Settings and click on Network. If you click on the various tabs for your connection, you should find a “Physical ID,” “Ethernet ID,” or “MAC Address.” Ubuntu users can type “ifconfig” in Terminal. You’ll see various network adapters, each displaying its own hardware address. Do this for all of the computers in your network that you need port forwarding for. The others will just get their IPs assigned automatically by DHCP.

DD-WRT and Static DHCP

Now that you have a list of MAC addresses for each of your computers, open up a browser tab and head over to your router’s DD-WRT interface. Click on Setup, and under Basic Setup, make sure DHCP is turned on.

sshot-9

Scroll down to “Network Address Server Settings (DHCP)” and make a note of the starting IP address and the maximum number of users. The addresses you configure should fall within this range. Here, my range of IPs would be 192.168.1.100 – 192.168.1.114.

sshot-1

Now, click on the Services tab up top.

sshot-2

Under the DHCP Server section, you can see that there’s a list of “Static Leases” click on the Add button to add a new one.

sshot-10

Enter the MAC address of each computer, give each one a name so you know which is which, and then assign them an IP address. You won’t be able to add the same IP address to two different MAC address, so make sure each MAC has a unique IP. If your version of DD-WRT also has a space to enter the “Client Lease Time,” a safe setting would 24 hours, or 1440 minutes.

That’s it! Be sure to click on both the Save button and the Apply Settings button, and wait for the changes to take effect. The settings should automatically change when each computer’s lease expires, though you can reconnect from each computer if you want the changes to take effect immediately.

Now, whether your computer loses its connect, the router gets power cycled, or the DHCP lease expires, each computer you entered into the list will stick to its assigned IP. Furthermore, you won’t have to manually configure static IPs on each machine! Port forwarding won’t have to be a pain ever again.


Does your router support DHCP reservations? Do you have a more clever use for this system? Share your thoughts in the comments!

 

Yatri Trivedi is a monk-like geek. When he's not overdosing on meditation and geek news of all kinds, he's hacking and tweaking something, often while mumbling in 4 or 5 other languages.

  • Published 08/4/11

Comments (12)

  1. theitguy

    Thank you for this great article !

  2. Sphynx

    Thanks for this informative and useful article. I was having this exact problem because I am forced to shut down my router due to the current heat situation in Texas. I may switch back to DD-WRT if this function is not available in the default firmware if Linksys router.

  3. jasray

    Just wondering why one would make-create the static IP on the router rather than assigning a static IP on the adapter(s) for each computer. Security? Ease? Don’t know, but would like to.

  4. YatriTrivedi

    @jasray: Ease of use, mostly. I often run multiple operating systems and reinstall and reconfigure, and having to put it in all the time is a pain. On more complicated network configurations, it’s even more of a pain. Doing it once on the router makes things easy on the client-end of things. Hope that helps!

  5. KeithLM

    jasray, as YatriTrivedi said, it’s about ease of use, and also keeping track of things. On the client side it’s still DHCP, so all the fields, including DNS, are filled in automatically, which makes things a lot easier. When setting up new equipment, if you have the list of static IPs in your router, then you know which have been used and which haven’t. Also if you are dealing with a network device for which the network settings are difficult to access or just annoying to deal with, static DHCP can allow you to enter a static IP without doing anything to the device.

    On my home network any device that I might want to connect to remotely gets a fixed IP assigned via static DHCP.

  6. jasray

    I guess I’ll have to see what happens. Thanks!

  7. g725s

    Would love to see the Tomato version of this…. ;-)

  8. TG2

    First @Jasray .. the biggest reason *not* to setup a static IP on your laptop and many other devices, is because if you take that device with you, and want to get it into another network, you must then manually go back in and take *your* configuration out, to connect to that other network.

    This is particularly an issue with Laptops … ipads, any device that you wouldn’t want to “tie” to one network ip setup.

    Now, to the article .. as to DHCP Reserves I am with the group that advises *not* to overlap your regions. Assign your static dhcp addresses outside of your “dynamic” lease range so that there is no confusion over what device ip’s are or are not supposed to be there..

    Its just like developing a working general network layout .. gateways, routers, vpn devicesa are .1 , .2, .3 … if you have multiple gateways and routers, or other networking devices.. if you have printers.. you might start them at 250 and come down (.249, .248, .247, etc) multi media devices, I’ve an onkyo networked A/V receiver, a bluray player, my TV, my Dish Receiver, all of them get ips from 240 on down.

    For Reference…
    http://www.dd-wrt.com/wiki/index.php/Static_DHCP
    [i]Note: [b]It is recommended[/b] but not necessary to set your static leases outside of your automatic DHCP address range. This range is 192.168.1.100-192.168.1.149 by default and can be configured under Setup -> Basic Setup : Network Address Server Settings (DHCP). [/i]

  9. Eytan

    Perfect timing with this article! I just installed FreeNAS on an old machine, and I was looking for a way to set an IP without using static on the machine itself, since FreeNAS has some issues with that. Thanks!

  10. Doug

    I have DD-WRT installed on a linksys WRT300N router. I tried using the method above as well as following a similar tutorial on DD-WRT.com Wiki. It didn’t work; every time I tried, my router choked until I deleted the static address(es) and rebooted.
    When I read the DD-WRT tutorial closer, I noticed this statement:
    Note: It is recommended but not necessary to set your static leases outside of your automatic DHCP address range. This range is 192.168.1.100-192.168.1.149 by default and can be configured under Setup -> Basic Setup : Network Address Server Settings (DHCP).
    When I changed my static address(es) outside the auto range, it worked as advertised.
    Maybe it’s just my router or my build of DD-WRT, but it’s a note that could save some folks some headaches if added to this fine HTG tutorial.

  11. xavier

    i think how to geek needs to do a tutorial on
    “how to limit specific users bandwidth using a wireless connection”
    that way when i am uploading youtube videos, my 2 sisters, my mom, will have slower internet,
    allowing me to upload my videos faster.
    i have REALLY slow internet, and an amazing custom built computer.
    its just not fair..

  12. arg3ntum

    Not only DD-WRT but almost all routers have “Address or DHCP Reservation” feature or similar on LAN Setup page. If your router missing it , you’re using shit.

Enter Your Email Here to Get Access for Free:

Go check your email!