Lab time! Want to build a DHCP server? In this lab, I will show you how to build your own DHCP server on a router using Cisco Packet Tracer, as shown above. By the end of this post, you will be able to create your own DHCP server with a Cisco 2911 router, perhaps in a home lab setting, and prepare you to build your own on other hardware.
Why a Router?
A DHCP server is a centralized, automated service that assigns important network configuration details to devices on a network, such as IP addresses. Without it, we would have to create manual entries for our entire network, which can be time-consuming and lead to errors. Traditionally, there are dedicated servers to handle these functions. There are many ways to implement a DHCP server in your topology, including a dedicated physical server, a virtual machine, cloud-based gateways, and firewalls. However, there are specific benefits to using a router as your DHCP server:
- Reduced infrastructure: While having a dedicated server is useful, it adds an extra cost and complexity on your network. Using a router simplifies your setup.
- Optimizing Performance: Reduces the need for additional devices, minimizing network hops and potential latency.
- VLAN Compatibility: This lab will especially show the ease of routing between VLANs and providing DHCP services for each VLAN. Instead of having different servers for different floors or VLANs, the router can handle these services.
- High Availability and Reliability: Without the router, you cannot exit your local network, meaning the router always has to be operating. If it is always operating, then DHCP can be operating.
Things to Keep in Mind
- Using a router for a DHCP server can be most effective in small- to medium-sized networks. However, if your business or network begins to expand, that means using more powerful hardware or a dedicated server.
- A router's main objective is to route your packets. Implementing a DHCP server on a router can increase its workload.
- This lab utilizes a small topology, but you will see the commands and how you can implement it in a SOHO environment, whether it is a home lab or your business.
Let's Get Building
This topology uses:
- 4 VLANS: IT, Executives, HR, Research & Development
- 3 Cisco 2960 IOS15 Switches
- 1 Cisco 3650-24PS Multilayer switch
- 1 Cisco 2911 Router
Step-by-Step Configuration for Each Device
Switch Configuration
- Enable the switch
- To enter privileged exec mode type
enable
conf t
- To enter privileged exec mode type
- Create your VLANs
- There are four VLANs, but in this topology, two of the switches utilize data traffic among three departments: IT, Executives, and HR.
- On each switch and each VLAN:
vlan {number}
name {VLAN name}
- For example, to create the IT VLAN:
vlan 10
name IT
- Assign VLANs to access ports
- To assign VLANs to ports, you can use the
int range
command to configure multiple ports at once:int range {interface}
switchport mode access
switchport access vlan {VLAN_ID}
- To assign FastEthernet 0/1-0/5 to VLAN 10, use these commands:
int range fa0/1-5
switchport mode access
switchport access vlan 10
- To assign VLANs to ports, you can use the
- Configure trunking to the multilayer switch.
- Trunking is used to group and send all VLAN traffic over a single link. Without it, specific VLAN traffic or perhaps none at all can be transferred between devices.
- Choose the interface that will connect to the multilayer switch. This will serve as your trunk line.
- Use the command:
switchport mode trunk
exit
- If you have certain VLANs you want to add to a trunk, use the command:
switchport trunk allowed vlan add {VLAN number}
- If you want to remove VLANs from a trunk, use the command:
switchport trunk allowed vlan remove {VLAN number}
Multilayer Switch Configuration
- Enable the switch
- To enter privileged exec mode, type:
enable
conf t
- To enter privileged exec mode, type:
- Create your VLANs
- This will be the same VLANs you put on your switches. After being put into a VLAN, devices on any of the two switches will go through the multilayer switch to reach the router and get an IP address. The multilayer switch also has the VLANs and will forward the information.
- On each switch and each VLAN:
vlan {number}
name {VLAN name}
- Assign ports as trunked ports
- To assign trunk ports, use the following command:
int range {interface}
- To assign trunk ports, use the following command:
- Configure trunks on the multilayer switch
- Choose the interface that will connect to the multilayer switch. These will serve as your trunk lines.
- Use the following commands:
switchport mode trunk
exit
- If you have certain VLANs you want to add to a trunk, use the command:
switchport trunk allowed vlan add {VLAN number}
Router Configuration
- Enable the router
- To enter privileged exec mode, type:
enable
conf t
- To enter privileged exec mode, type:
- Create subinterfaces
- A subinterface, configured on a router interface, allows you to create mini-doors to reach individual networks or subnets. The trunk line from the multilayer switch to the router is connected to an interface. On that port, you create subinterfaces for each VLAN created. To create subinterfaces, type:
For example to create a subinterface for VLAN 10 on GigabitEthernet 0/0, use these commands:int {interface}.{VLAN_ID number}
int gig0/0.10
- Configure encapsulation
- Encapsulation (802.1q) ensures that VLAN-tagged traffic is properly identified and routed between different VLANs over trunk links.
- Imagine being at a convention. There are so many people, but your nametag identifies who you are, such as which group you are affiliated with. In this scenario, everyone in that convention center would represent all the data transferred over a trunk line. Your name tag represents the VLAN tag, which ensures data is correctly delivered to the right department (VLAN) without confusion.
- To configure encapsulation, use these commands:
encapsulation dot1q {VLAN_ID number}
ip address {IP Address}
exit
- The IP address used for subinterfaces will be used as the default gateway for the VLANs.
- DHCP Configuration
- To configure DHCP on a router,
service dhcp
ip dhcp pool {title}
network {IP_ADDR} {SUBNET MASK}
- The
ip dhcp pool
command allows you to create an IP address range that the router will use to distribute IP addresses to devices on a VLAN. - The
network
identifies the network ID and subnet mask, which identifies the IP address range - the scope of possible IP addresses that can be given to devices on a subnet. - Configure a default router
- You can configure your default router IP address to the subinterface IP address. To configure the default router,
default-router {IP_ADDR}
Comments
Post a Comment