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

Posted on

Introduction

This is another article where the main focus is showing a simulation about how to implement DHCP with VLAN using two PCs, two switches and one router. The simulation itself is 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 two PCs where both of them will retrieve IP Address from the router through a DHCP service. The router will provide it through a specific VLAN. Connect those two PCs to one switch running in VTP client mode.  Then, connect that switch with another switch running in a VTP server mode. For the last one, connect that switch running in VTP server mode to the router. The network schema scenario in this article is actually is the modification from the other scenario exist in the other article in this link. That article has a title of ‘How to Simulate DHCP Implementation using only one PC, one Switch and one Router’. So, how about the actual network schema in this article?, just take look at the following image :

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

There are several steps to achieve the simulation. Those steps are configuring one switch to running in an VTP server mode. Continue on to the configuration proces of the switch running in an VTP client mode. The next step is to continue on configuring the router. The final step is to configure both of the PCs so that they can acquire or request an IP Address from the router. Configuring those two switches are important steps in order to implement VLAN where the connections for providing DHCP IP Address from the router to both of the PCs will be possible. The configuration process in the router is also important in order to set the DHCP configuration. Furthermore, the process for configuring both of 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. Actually, subinterfaces are useful for a variety of purposes. If we have one router with one physical interface, but need to connect to two IP networks, subinterface can be useful to route traffic between two different network. Consequently, it is possible to create two subinterfaces within the physical interface. Each subinterface will have an IP address within each subnet and then route the data between two subnets.

In summary, sub-interface allows 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 because there is only one VLAN, unfortunately it does not as effective as there are several VLANs with several different networks. So, there will be two subinterfaces that will represent different network. Each network will represent a different VLAN. In the end, each PC will have a different IP Address since both of them will be in a different member of VLAN.

 

Configure the switches

So, this part will consist of the configuration process of both of the switches. First of all, configure the switch connected directly to the PC. It will run in a VTP client mode. Following the configuration, configure the switch connected directly to the router to run in a VTP server mode. For more information about  the steps for configuring both of the switches, just read the article ‘How to Implement VTP Protocol using Two Switch’ in this link. The VLAN in this article is only one VLAN. The name of the VLAN is VLAN 10 where it is the only VLAN allowed to be passed from the VTP server mode to the VTP client mode. Execute the following steps to configure all the switches :

 

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)#vlan 20 
VLAN 20 added: Name: VLAN0020
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#

There are two VLANs above for each of the PC.

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    
20   VLAN0020                         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

After configuring the switch connected with the router. The next step is to configure the switch connected with the PC. Below are the steps :

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’. It is an interface where it is directly connected with the first PC which is the PC with the label of ‘PC0’. 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)#exit
Switch(config)#

Consequently, do it with the other interface according to the image above which is ‘fa2/1’. It is an interface where it is directly connected with the second PC which is the PC with the label of ‘PC1’. So, the execution of those commands consists of these following steps :

Switch(config)#int fa2/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20 
Switch(config-if)#exit

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    Fa1/1
20   VLAN0020                         active    Fa2/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, there is an output indicating the existence of VLAN 10 and VLAN 20. It appears without having to create it because of the implementation of VTP protocol where the VLAN information pass from the switch running as a VTP server mode to the switch running in VTP client mode. But the main different of the output is that there is each port assigned to each VLAN. So, port fa1/1 will permit any access for VLAN 10 and port fa2/1 will permit any access for VLAN 20.


Configure the router

After finishing to configure the switch, don’t forget to configure the router. 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’. The first subinterface is for VLAN 10 configuration. 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

The second subinterface is for VLAN 20 configuration. Don’t forget to assign an IP Address to the interface for an example it is ‘192.168.2.1’ with a netmask of ‘255.255.255.0’. This second subinterface is for VLAN 20 configuration. Just type the following command :

Router(config)#int fa0/0.20
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.2.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. Since there is two VLANs, there will be a need to define two networks or two dhcp pools. Define the first dhcp pool as follows :

Router(config)#ip dhcp pool vlan10
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#

Don’t forget to exclude the IP Address of ‘192.168.1.1’ since it is already assigned for the subinterface IP Address for the default gateway of the VLAN 10. Then continue on to define the second dhcp pool as follows :

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

As in the above output command execution, after declaring the second dhcp pool, don’t forget to exclude the IP Address of ‘192.168.21’ for the default gateway of VLAN 20 in the associated subinterface. Last but not least, check the dhcp pool by executing the following command :

Router#sh ip dhcp pool

Pool vlan10 :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0 
 Total addresses                : 254
 Leased addresses               : 1
 Excluded addresses             : 0
 Pending event                  : none

 1 subnet is currently in the pool
 Current index        IP address range                    Leased/Excluded/Total
 192.168.1.1          192.168.1.1      - 192.168.1.254     1    / 0     / 254

Pool vlan20 :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0 
 Total addresses                : 254
 Leased addresses               : 1
 Excluded addresses             : 0
 Pending event                  : none

 1 subnet is currently in the pool
 Current index        IP address range                    Leased/Excluded/Total
 192.168.2.1          192.168.2.1      - 192.168.2.254     1    / 0     / 254
Router#

So, after checking the dhcp pool list, the configuration process on the router is done.

 

Configure the PC

The last part, it is the part to configure the PC so that it will set into a DHCP mode. The following is the first PC with the label of ‘PC0’ :

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

As in the above image, PC 0 succeed on retrieving an IP Address. The IP Address is ‘192.168.1.2’. The result is obvious since ‘PC0’ is directly connected with the switch running in VTP client mode through the inteface fa1/1. That interface will permit for VLAN 10 access including the assignment of DHCP IP Address of VLAN 10 where the network of it is ‘192.168.1.0’.  Don’t forget to configure or to switch the radio button IP Configuration from Static to DHCP for the second PC with the label of ‘PC1’ as follows :

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

Leave a Reply