DHCP. Networking Computers would be difficult without it.

Nov 2024

DHCP – (Dynamic Host Control Protocol). DHCP is one of those things that basically enable us to network computers without much effort. Without DHCP, it would be a lot harder because we would need to do things manually.

You may have come across the term “IP Address“, this is simply a set of numbers that help identify “network devices”. All network devices need a Unique IP Address but this can change. All network devices also have a unique MAC (Media Access Control) address which is “hard coded” in to the device at the manufacturing stage and never changes (but can be spoofed). This also known as the “Hardware Address”.

Ignoring the MAC address. When you connect a device (Desktop / Laptop / Tablet) to a network, it needs a unique IP Address to identify it on the network it is connected to. You could give the network device a “Static IP” (address) but this would need to change if the device was used on a different network.

DHCP makes life easier. When you add / attach a new network device to a LAN (Local Area Network) (without a static IP), the device sends a broadcast message on the network and basically asks “Who am I”. If you have a DHCP server running, it will reply “you are xxx.xxx.xxx.xxx.” e.g. 192.168.0.5. An IPv4 IP Address uses 32 bits in a dotted quad notation so the 32 bits are split into 4 octets and each octet is a number between 0 and 255.

To set up a new network device on a LAN, it needs to know :-

  1. Its IP Address
  2. The Subnet Mask (SNM)
  3. Default Gateway.

In a typical Home or SOHO situation, the ISP supplied router acts as a DHCP server by default.

The router will usually have a “Dynamic” WAN IP Address, assigned by the ISP. This will be a “Public Routable” IP Address and may change occasionally or when you reboot the Router.

The supplied router will usually have a “Private non-routable” LAN IP Address, most often 192.168.0 or 1. x. The forth octet is often 1 or maybe 255. e.g. 192.168.0.1. This is a “Static IP Address”, in that it never changes but can be changed!

The LAN IP Address of the router is then the “Default Gateway“. If you connect a network device and omit the Default Gateway, you won’t get access to the Internet or other networks. Think of the Default Gateway as being like a Gate into and out of a park with several gates. Only one of the gates will allow you to leave the park.

The SNM is a bit of a game changer! We know the IP Address uses 32 bits (see binary) but this gives us the “Network Address” & the “Host Address” – a bit like a post code.

In the UK we use postcodes for our residential (and business) addresses, this is similar to a “Network Address”. A postcode of say S70 2NP would give an area of houses. If you add the house number (host address), in theory that is all you need. If someone asks for you home address you could just give them S70 2NP, 10 (house number) but it is usually written 10 (house number) S70 2NP

The SNM typically uses 24 bits, often IP Addresses are written as e.g. 192.168.1.1 /24. The SNM in this case uses 24 bits so the first 3 octets are the “Network Address” e.g. 192.168.x which leaves 8 bits for the “Host Address”.

192.168.1.1 in binary would be “1100 0000. 1010 1000. 0001. 0001”

A 24 bit SNM would give you 254 hosts or 254 network devices you can connect to the router and all be on the same network. Generally, it is good practice to not use 0 or 255 for the host address. 255 is usually reserved for the broadcast address.

The SNM is something you can play with – if you understand what it does! A /30 SNM would only give you 2 hosts but a /22 SNM would give you about 1022 hosts have a play with subnet calculator.

Once the DHCP server is set up, any device you connect to the router will recieve a unique IP Address Dynamically and will include the SNM and Default Gateway so you don’t need to get involved in issuing IP Addresses for each host.

If you have a “Network Printer” or “Network Scanner” etc, these will usually need to be issued with a Static IP Address, which would normally be outside of the DHCP Scope. The ISP may have configured the router to have up to say 30 devices, this is known as the DHCP scope and this would show in the DHCP settings as maybe Start Address 192.168.1.100 End Address 192.168.1.130 or it may just ask how hosts you want.

So any devices / printers etc needing a Static IP would normally be something like 192.168.1.20 or 192.168.1.200 but some routers expect any Static assignments to be within the DHCP Scope and then reserved so that the device always gets the same IP!

DHCP is basically a networking tool that makes setting up a LAN and attaching devices so much easier.

Bit of History.

IP Addresses used to be in classes, A, B, C etc. Each Class had a given SNM but this system was replaced many years ago to a system called CIDR (Classless Inter Domain Routing) which basically played with the SNM and the IP Address needed to be qualified by the number of bits used for the SNM so 192.168.1.2 /X became the standard “notation”. The X was the number of bits used by the SNM.

The advantage of CIDR is that is enables an ISP to create a larger number of hosts with their allocated “Public” IP Address block. This is referred to a sub or super netting.