How to Simulate DHCP Implementation with VLAN using only one PC, two Switch and one Router

Posted on

Introduction

Another article where the main focus is showing a simulation about how to implement DHCP with VLAN using only one PC, one switch and one router. The simulation will be an exercise and education purpose. Later on, it will be a useful reference for further real implementation. Just use any kinds of application simulator to create the simulation first. The application itself can be a Cisco Packet Tracer or any other application simulator such as GNS3. This article will show a scenario is to connect a PC retrieving an IP Address from the DHCP service. A router will provide it through a specific VLAN.  Just connect one PC to one switch running in V and then connect the switch to the router. So, it is obvious that there will be no direct connection from the PC to the router. Below is the actual network schema using a Cisco Packet Tracer :

 

How to Simulate DHCP Implementation with VLAN using only one PC, two Switch and one Router
How to Simulate DHCP Implementation with VLAN using only one PC, two Switch and one Router

In order to implement the above simulation, there are several steps to achieve it. Those steps are configuring the switches start from the switch running in an VTP server mode continue on to the switch running in an VTP client mode. After that just continue on configuring the router. Last but not least, configure the PC. Configuring those two switches are important steps in order to implement VLAN where the connections for providing DHCP IP Address from the router to the PC will be possible. The configuration process in router is also important in order to set the DHCP configuration. Furthermore, the process for configuring the PC in the last step is also important to be able to request for an IP via DHCP service provided by the router.

In the router configuration, actually, the configuration is using a sub-interface. Sub-interface is a virtual interface created by dividing one physical interface into multiple logical interfaces.  In the term of Cisco router device, a sub-interface uses the parent physical interface for sending and receiving data. Subinterfaces are used for a variety of purposes. If we have one router with one physical interface, but needed to have the router connected to two IP networks to route traffic between two routers, it is possible to create two sub-interfaces within the physical interface, assign each sub interface an IP address within each subnet and then route the data between two subnets.

In summary, sub-interface allows you to use a router interface as a trunk port to a switch. This is also known as “Router on a stick” because the switch uses the router to route between VLAN. Since it is only one network since it is only one VLAN, unfortunately it does not as effective as there are several VLANs with several different networks.

 

Configure the switches

In this part, there are two type of switches for configuration process. Those are configuring first switch running in an VTP server mode and the other one is configuring the second switch to run in an VTP client mode. In order to see the steps for configuring both of the switches, just read the article ‘How to Implement VTP Protocol using Two Switch’ in this link. In this article, there is only one VLAN with the name of VLAN 10 where it is the only VLAN allowed to be passed from the VTP server mode to the VTP client mode. But to make it compatible to run in the example of this article, below are the summary of those steps :

 

Configure the switch running as a VTP server mode

1. Access the switch. From the User EXEC Level mode just switch to Privileged EXEC Level mode.

Switch>ena
Switch#

2. Then, switch to the Global Configuration Command mode from the Privileged EXEC level mode by executing the following command :

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#

3. Continue on to the important step, set the switch to run in a VTP server mode :

Defining the vtp mode by executing the following command :

Switch(config)#vtp mode server
Device mode already VTP SERVER.
Switch(config)#

Defining the VTP domain where all the switches in that domain will receive these VTP updates by executing the command pattern below :

vtp domain vtp_domain_name

An example for defining the VTP domain name with a name of ‘cisco’ exist as follows :

Switch(config)#vtp domain cisco
Changing VTP domain name from NULL to cisco
Switch(config)#

Furthermore, defining the password to secure the VTP advertisements for the VTP domain definition with the following command pattern :

vtp password vtp_password

So, using the above pattern, for an example as an easy one, ‘cisco’ as the password chosen, just type into the command below :

Switch(config)#vtp password cisco
Setting device VLAN database password to cisco
Switch(config)#

3. Another important step is to create the VLAN. The following is the command to create it :

Switch#vlan database 
% Warning: It is recommended to configure VLAN from config mode, as VLAN database mode is being deprecated. 
Please consult user documentation for configuring VTP/VLAN in config mode. 
Switch(vlan)#vlan 10 
VLAN 10 added: Name: VLAN0010 
Switch(vlan)#

4. The next step, run the command for setting the connected port or interface of the switch running in a VTP server mode as a trunk mode. Not only the interface connected to the switch running in a VTP client mode but also the interface connected to the router. Don’t forget to allow the VLAN to be able to be implemented with that interface configured in the trunk mode.

The following are the steps to accomplish it :

In the Global Configuration Command mode, access the Interface Configuration Mode as follows :

Switch(config)#int fa0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10 
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Switch(config-if)#exit
Switch(config)#int fa1/1 
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10 
 

Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/1, changed state to up

Switch(config-if)#exit
Switch(config)#exit
Switch#

5. Don’t forget to check the VTP status of the switch and also the VLAN database. Just type the following command as follows :

Switch#sh vtp status
VTP Version                     : 2
Configuration Revision          : 2
Maximum VLANs supported locally : 255
Number of existing VLANs        : 7
VTP Operating Mode              : Server
VTP Domain Name                 : cisco
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0x26 0xF5 0x7B 0xD6 0x54 0xFD 0xC7 0xD6 
Configuration last modified by 0.0.0.0 at 3-1-93 00:02:00
Local updater ID is 0.0.0.0 (no valid interface found)
Switch#sh vlan br

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa2/1, Fa3/1, Fa4/1, Fa5/1
10   VLAN0010                         active    
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
Switch#

By far, as the above output command shows, the execution process for configuring the switch into an VTP server mode is finished.

 

Configure the switch running as a VTP client mode

1. Access the switch. Similarly with the switch running in a VTP server mode, switch from the User EXEC mode to the Privileged EXEC mode :

Switch>ena
Switch#

2. Continue on similarly with the switch running in a VTP server mode, execute the following command to switch to the Global Configuration Command mode :

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#

3. Since this switch is going to run in a VTP client mode, set the switch to run in a VTP client mode. The execution of those commands consists of these following steps :

Defining the vtp mode by executing the following command :

Switch(config)#vtp mode client
Setting device to VTP CLIENT mode.
Switch(config)#

Set the domain name of the switch running in VTP client mode with the same name of the switch running in VTP server mode. In this context, the domain name is ‘cisco’. So, define it also as the domain name definition above as follows :

Switch(config)#vtp domain cisco
Changing VTP domain name from NULL to cisco
Switch(config)#

As in the previous part for configuring the switch running in VTP server mode, do not forget to set the password as follows using the same password which in this context is ‘cisco’ :

Switch(config)#vtp password cisco
Setting device VLAN database password to cisco
Switch(config)#

4. Don’t forget to configure the interface connected to the PC. Set it into an access mode and allow VLAN 10 to be able to use the interface.The interface according to the image above is ‘fa1/1’. So, the execution of those commands consists of these following steps :

Switch(config)#int fa1/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10 
Switch(config-if)#

5. Last but not least, don’t ever forget to check the VTP status of the switch and also the VLAN database. Just type the following command as follows :

Switch#sh vtp status
VTP Version                     : 2
Configuration Revision          : 2
Maximum VLANs supported locally : 255
Number of existing VLANs        : 7
VTP Operating Mode              : Client
VTP Domain Name                 : cisco
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0x26 0xF5 0x7B 0xD6 0x54 0xFD 0xC7 0xD6 
Configuration last modified by 0.0.0.0 at 3-1-93 00:02:00
Switch#sh vlan br

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa3/1, Fa4/1, Fa5/1
10   VLAN0010                         active    Fa0/1
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
Switch#

By executing the last command above, since there is VLAN 10 without having to create it because of the implementation of VTP protocol, it ends the configuration process of switch running in VTP client mode.


Configure the router

In this part, there are several steps for configuring the router. The following are those steps :

1. Access the router.

Router>

2. As also in the switch device, do similar thing in router. Change from the User Level Mode into a Privileged Level Mode by typing the following command :

Router>ena
Router#

3. Next step where it is also similar with the switch device. Change it to the Global Configuration Command Mode by typing the following line :

Router# conf t
Router(config)#

4. Continue on by getting into the Interface Configuration Command Mode. Choose the sub-interface where it connects to the switch where in this context it is the ‘fa0/0’. Don’t forget to assign an IP Address to the interface for an example it is ‘192.168.1.1’ with a netmask of ‘255.255.255.0’. Just type the following command :

Router(config)#int fa0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#exit

5. Set the DHCP Pool in order to define the IP Address that will be distributed to the client which in this example is the PC. The following is the set of the command to do it :

Router(config)#ip dhcp pool dhcp
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#exit
Router(config)#ip dhcp excluded-address 192.168.1.1
Building configuration...
[OK]
Router(config)#exit
Router#

The last step above is defining a DHCP Pool with the name of ‘dhcp’. Those DHCP pool is having a network of ‘192.168.1.0’ with the netmask of ‘255.255.255.0’. The router IP Address is ‘192.168.1.1’. Last but not least, define ‘192.168.1.1’ to be an IP that will never be distributed to the other device which in this context it is a PC. And the configuration process on the router is done.

 

Configure the PC

Finally, the last thing to do is do not ever forget to configure the PC so that it will set into a DHCP mode. It exist as in the following image :

How to Simulate DHCP Implementation using only one PC, one Switch and one Router
How to Simulate DHCP Implementation using only one PC, one Switch and one Router

Leave a Reply