Skip to content
Skip to main content

About this free course

Download this course

Share this free course

Discovering computer networks: hands on in the Open Networking Lab
Discovering computer networks: hands on in the Open Networking Lab

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

5.1 Dynamic Host Configuration Protocol (DHCP)

In this section you will see how networks can be configured so that new devices can join automatically and not have to be configured manually.

Mobile devices such as laptops and smartphones may leave and join different networks frequently: for example, you may use the same device at home and work, and also on the bus or in a café. A mobile device needs a different configuration for each network; it would be annoying and error-prone if the user had to do this manually. Other networked devices, such as security cameras or central heating thermostats, have no keyboard or screen, so they must connect automatically.

Dynamic Host Configuration Protocol (DHCP) is used to configure network devices automatically. DHCP is specifically designed for networks where the connected devices (hosts) change frequently, using a protocol to achieve a correct configuration.

Now watch the video below, which is about 5 minutes long. It shows how new devices are configured as they join a network.

Box _unit4.1.1 DHCP in action

Download this video clip.Video player: 27_dhcp_in_action.mp4
Copy this transcript to the clipboard
Print this transcript
Show transcript|Hide transcript
 
Interactive feature not available in single page view (see it in standard view).

Now watch the video below, which is about 3 minutes long. It shows how one device receives a new configuration when it moves from one network to another.

Box _unit4.1.2 DHCP continued

Download this video clip.Video player: 28_dhcp_continued.mp4
Copy this transcript to the clipboard
Print this transcript
Show transcript|Hide transcript
 
Interactive feature not available in single page view (see it in standard view).

In the video you saw that instead of manually setting up the IP address for every device on a LAN, you can use DHCP (Dynamic Host Configuration Protocol) to do it automatically. A new device joining the network – for example a PC plugged in to an Ethernet socket or a tablet connecting to Wi-Fi – will receive an IP address.

A DHCP server has a pool of IP addresses which it can issue to devices as they join the network. On a home network the router will act as the DHCP server, but a dedicated DHCP server may be used in a business network.

Besides the IP address, DHCP will configure other important network parameters such as the subnet mask and default gateway.

The IP address is granted only for a limited period of time (a lease) such as 24 hours. If the device stays connected or reconnects before this lease expires, it keeps the same IP address. If the lease expires, the server can reallocate the IP address to any new device that connects. If the original device reconnects, it will be given a different IP address.

Some host devices in a network may need a permanent static address rather than obtain an address from the DHCP pool which might change. For example, a home gateway is usually given a static address that never changes.

Activity _unit4.1.1 Activity 1 Think about

10 minutes

Could you set up a coffee shop Wi-Fi network?

Customers expect to have wireless access so they can use their tablets and laptops. What would you have to consider when you set up a Wi-Fi network?

Discussion

You will certainly want to set up DHCP on your network so customers don’t need to reconfigure their devices manually. Some specific issues to consider are:

  • The pool of addresses should be large enough for the number of customers you expect at any one time.

  • The lease time should be short, or you may run out of available addresses.

  • You may want to reserve some static addresses for the security cameras, tills or credit card terminals.

There are other considerations – for example making sure that your network is secure – which won’t be considered here.

Activity _unit4.1.2 Activity 2 Try it out

15 minutes

  1. Open PT Anywhere [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)] in a new tab or window so you can read these instructions.

    In this scenario, there is a home gateway router and one PC already connected.

  2. Add the laptop to the network.

  3. Check the laptop configuration – is DHCP turned on?

  4. Connect the laptop to the home gateway.

  5. What IP address is it assigned?

  6. What other configuration does it receive?

  7. Can you ping the laptop from the PC?

  8. Can you ping the PC from the laptop?

  9. Disconnect the laptop from the home gateway.

  10. Connect the second PC to the home gateway.

  11. What IP address is the new device assigned?

  12. Now reconnect the laptop to the home gateway.

  13. What IP address is it assigned now?

Discussion

When you add a new device to a network running DHCP, it will receive an IP address and subnet mask. The IP address will be different from other devices already on the network. (The new device will normally also receive the address of the home gateway but this is not simulated here.)

If you disconnect a device, its IP address won’t immediately be allocated to a different device. As long as the lease has not yet expired, you can reconnect the device and it will retain the same IP address.

Activity _unit4.1.3 Activity 3 Sort it out

15 minutes

  1. Open PT Anywhere in a new tab or window so you can read these instructions.

    In this scenario, there is a home gateway router and one PC already connected.

  2. Add the laptop to the network by connecting it to the gateway.

  3. Can you ping the laptop from the PC?

  4. Check the laptop and PC configuration – is DHCP turned on?

  5. Check the gateway configuration – is DHCP turned on and configured sensibly?

  6. If not, fix it and try again.

Discussion

In this network, DHCP wasn’t turned on and so a new device would not be configured correctly. Once DHCP is turned on at the gateway router, new devices will be granted a new IP address automatically.