A Guide to Understanding DHCP

Thumbnail image of Port Forward Staff
Port Forward Staff
July 18, 2017 (Last Updated: ) | Reading Time: 3 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 guides page. 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 first and it gets the 192.168.1.2 IP address. The next day maybe computer A is turned on second and it gets a 192.168.1.3 IP address. 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 back to our previous example, one day the port forwarding configuration works. The next day it may not. In order to avoid this problem, we need to set up a static 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

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. 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.

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.50 or more. (It's pretty unlikely that you will have 50 computers on your network, so there will never be an IP address conflict.) If the first IP address handed out by DHCP is something like 192.168.1.253, assign an IP address that is 192.168.1.150 or less.

Know Your DHCP Pool

The only thing that matters is that there are no IP address conflicts. 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.

More From Port Forward