DD-WRT Tutorial 1: Static DHCP

By Aaron Weiss

August 02, 2006

Open source router firmware does things the factory-installed stuff never offers. For example, you can give a computer the same IP address every time so you'll always have remote access.

By now, you probably know that upgrading the near-legendary Linksys WRT54G series routers with free, often open-source firmware is one of the best bargains going. Replacement firmware typically offers a plethora of advanced router and firewall features rarely found on sub-$100 hardware.

DD-WRT, a free, open-source firmware coded and distributed by “BrainSlayer,” has emerged as one of the leading, most powerful and also user-friendly firmware replacements for the WRT54G series. DD-WRT is available for an increasingly wide range of routers besides the WRT54G, including models by Asus, Belkin, Buffalo Devices, Motorola and Siemens.

There are caveats to upgrading your router, and the process is not without risk, so beware. We'll assume you've got DD-WRT successfully installed, and forge ahead...

In this first detailed look at new features you can get from open source router firmware, prepare to be dazzled by the capabilities of... the Dynamic Host Configuration Protocol (DHCP) .

Static DHCP

Out of the box, most routers and PCs are designed to manage their IP addresses automatically. The PC, whether wired or wireless, requests an IP address and related network parameters from the router using the DHCP protocol. The router plucks an unused address from its pool of available addresses, hands it to the client, and everyone is smiling.

This process results in what is called a “dynamic IP address” – every time the PC connects to the router (on boot-up, for example, or wireless association), it is assigned a new IP address. The router may assign the same address it assigned in the previous session. Or it may not. You don’t know and, usually, you don’t care.

There are cases, though, when you want your client to receive a predictable, consistent IP address. The most common scenario is when you run a server on your client PC. Suppose you run a Web site on a PC at home, and you need access to this server from elsewhere – work, school, your laptop in the park. Your router “hides” your server from the outside world, which is normally a good thing for security. This is why a higher power invented Port Forwarding .

Your router will allow you to forward traffic destined for a specified port to a specific machine. In its simplest form, you can configure your router to forward incoming traffic destined for port 80 – the default port number for Web traffic – to the IP address of the PC running your Web server.

What is your Web server PC’s IP address? If it receives its address automatically from the router – you don’t know for sure. It could change, and your port forwarding would become unreliable.

One solution is to manually assign your Web server its IP address and network parameters, rather than use DHCP. However, this may limit your ability to easily connect that machine to other networks — a more likely problem for laptops. If your ISP changes name servers on occasion, this could also break your manual network configuration.

Ideally, if you continue using DHCP on your client yet can rely on always receiving the same IP address, you’re having your cake and eating it, too. Which begs the question – why would you have a cake if you weren’t going to eat it? Isn’t that the purpose of cake?

Step-By-Step

Fortunately, DD-WRT makes it easy to create static DHCP addresses for your network. Combining the best of both worlds, a static DHCP address allows your clients to continue receiving their network parameters automatically, yet you know exactly which IP address will be assigned.

  1. Open a browser and connect to your router’s administration page. The default address for DD-WRT is http://192.168.1.1, but may vary if you’ve reconfigured it.
  2. Go to the Setup/Basic Settings menu. The router may first ask you to log in with your administrator password. (The default is root/admin). Scroll down the page to “Network Address Server Settings (DHCP).”

dhcprange

  1. Make a note of the pool of addresses the router uses when assigning dynamic IPs. Here, we see a pool of 100 addresses, beginning at 192.168.0.100 and ending at 192.168.0.200. It will be important later that your static DHCP address assignments fall outside this pool. (If you make any changes here, be sure to save your settings.)
  2. Go to the page Administration/Services. Here’s where the action is. Below the “Static Leases” heading, click the “Add” button to create a new DHCP entry field.
  3. Enter three values: the MAC address of your client machine’s network adapter, a host name for the machine, and the IP address you want it to be assigned. Choose any host name you like, such as “webserver” or “gameserver”. Choose an IP address which follows the same pattern as those in your DHCP address pool (in our example, 192.168.0.x). Choose a number for x which is outside the address pool seen in step 3 (in our example, 201).

enterstaticdhcp_sm.gif

You can find the MAC address for your network adapter in either Windows XP or Mac OS X with a few clicks.

Windows XP
Click Start/Settings/Control Panel/Network Connections and click the name of your network connection. Wired connections are typically named “Local Area Connection,” while wireless connections are called “Wireless Connection”. In the Status window, click Support, and in that window, click Details. Your MAC address is the series of hexadecimal pairs labeled “Physical Address”. Use colons rather than dashes to separate the pairs in the DD-WRT interface.

winmacaddress_sm.gif

Mac OS X
Go to the Dock/System Preferences/Network. Click the Ethernet tab. Your MAC address is labeled “Ethernet ID”.

osxmacaddress_sm.gif

  1. With your MAC address, host name and chosen IP address entered into DD-WRT, be sure to click Save Settings at the bottom of the page. If you want to add another static DHCP entry, you must save your settings first, then click Add to create a new entry.
  2. If you like, add a port forwarding entry for your new static DHCP address. In our example, we set up a Web server on our client PC. Our Web server listens for traffic on the default port 80. But our ISP blocks incoming traffic to port 80, because they don’t want us running Web servers (ours is for private personal use, we totally swear). Go to Applications & Gaming/Port Forwarding in the DD-WRT menu. Click Add to create a new forwarding entry. We enter an identifier into the “Application” field, in this case, “webserver”. The router will listen for traffic on port 8088, so that we can connect from outside without being blocked by the ISP. Our destination IP address is the static DHCP entry created in step 5, and our destination port is where our Web server is actually listening, port 80. Be sure to check Enable for this definition to take effect. And, of course, Save Settings.

portforward_sm.gif

You are now, as they say in the new Taco Bell ads which are vastly inferior to the ones with the talking Chihuahua, “good to go.” Even if you don’t run Web, game or other servers on your local machines, you never know when a stable, predictable IP address will come in handy.

Add to del.icio.us | DiggThis

Originally published on .

Comment and Contribute
(Maximum characters: 1200). You have
characters left.