A Guide to Understanding DHCP

Thumbnail image of Port Forward Staff
Port Forward Staff
July 18, 2017 (Last Updated: ) | Reading Time: 4 minutes

DHCP stands for Dynamic Host Control Protocol. It is a process that runs on your router that assigns an IP address, subnet, and gateway to each device on your local area network. For more about these terms visit our Networking Help Center. Let's look at what an IP address is first then we will get into how DHCP works.

Devices on a network
Devices on a network

An IP Address is a unique number given to every computer on a network. Each IP address is unique because two computers on the same network cannot have the same IP address. The IP address generally takes the form of four numbers (from 0 through 255) which are separated by periods. A common IP address is 192.168.1.2.

Example IP address
Example IP address

Every time a computer is turned on it contacts the DHCP server to request an IP address, subnet, and gateway. The DHCP server generally provides the next available IP address. This is more important than it sounds. The order in which the computers are turned on effect which computer gets which IP address.

A Problem With DHCP and Port Forwarding

For example, one day you turn computer A on and it gets 192.168.1.2 for an Ip address. The next day maybe computer A is turned on and it gets a different IP address, like 192.168.1.3.

Forwarding a port causes certain data to be sent to a specific IP address. If a port forward had been set up and then that IP address changes, the port forwarding configuration will no longer be set up properly for that computer.

So one day the port forwarding configuration works. The next day it does not. In order to avoid this problem, we need to set up a permanent IP address on the computer that the ports are going to be forwarded to.

A person setting up a router
A person setting up a router

DHCP Reservation vs Static IP

There are two ways to give a device a permanent IP address: DHCP reservations and static IPs.

Generally speaking, a DHCP reservation is a better choice if you want to give a device a permanent IP address. DHCP reservations are managed in your router which gives you centralized management of your network. Most routers will also help prevent you from making mistakes when reserving permanent IP addresses on your network. If your router offers DHCP reservations, then you should use that feature instead of setting up static IP addresses in each device.

A static IP address is an IP address that is not assigned by DHCP. A static IP address is an IP address that has been manually set up on that device. DHCP actually knows nothing about an IP address that has been assigned statically. It doesn't even know that an IP address has been assigned. So it can very easily hand out an IP address via DHCP that is the same as the one that has been assigned statically. Remember, an IP address needs to be unique. When two computers have the same IP address there is an IP address conflict and neither of them can connect to the internet.

Let's go back to computer A and computer B. Computer A has the static IP address 192.168.1.2, but it is currently shut down and not on the network. Computer B boots onto the network and DHCP then hands it the first available IP address, which it considers to be 192.168.1.2. Now, later on, you boot up computer A and it forcefully takes the same IP address that you have assigned it. Unfortunately, you now have two devices on your network with the same IP address. Even worse, computer B stopped working and you don't know why.

The easy way around this is to just assign an IP address that is far away from the range of IP addresses that are assigned by DHCP. If DHCP assigns 192.168.1.2 as its first assignable IP address, assign a static IP address that is something like 192.168.1.201 or more. An even better way to prevent this problem is to be aware of your router's DHCP pool.

Know Your DHCP Pool

The router's DHCP service has a list of available IP addresses that it can hand out. This list is called a pool. Many routers vend a pool of IP addresses from .100 to .200, but without logging in to your router and checking, you can not be sure.

Before assigning static IP addresses, you should log in to your router and make a note of your DHCP pool. Any IP addresses that you manage manually need to be outside of the router's DHCP pool. This should prevent accidental IP address conflicts from happening.

Just make sure you do not set up a static IP address that is one of the IP addresses that DHCP normally hands out. To always avoid IP address conflicts you need to know what your router's DHCP range is. You can find it by logging in to your router and going to the DHCP section. The range will be listed there. Simply choose an IP address outside the listed range when setting up a static IP and you will never have an IP address conflict.

For more information about managing your network, visit our Help Center.

More From Portforward