DHCP is a program that helps your computer find and connect to network servers. It can also be used to set up static IP addresses for your computer. Static IP addresses are good for when you want to keep your computer’s address the same no matter where it is in the world. You can also use static IP addresses if you want to prevent your computer from being able to connect to other computers on the network if it changes its address. To set up static IP addresses on your computer, you first need to open a command prompt and type: ipconfig /flushdns This will clear out any cached DNS information on your computer and start looking for new DNS servers. You can then type: dhcpcd -i eth0 -f /etc/resolv.conf -p 8192 -s 192.168.1.1 -t 10
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 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.
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.
You can do this on plenty of modern routers, but we’re going to use DD-WRT for this guide. 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! If you have a different router, you can try following along using your router’s own admin page–the instructions should be somewhat similar.
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.
Right-click on your current active connection and click on Status.
Click on the “Details…” button.
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.
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.
Now, click on the Services tab up top.
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.
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!