How to Configure VLAN VTP DTP STP and Router on Stick Tutorial
In this article we will configure VLAN, VTP, STP, DTP and Router on Stick. We prepared this article for CCNA practice, but you can use it for other exam practice as well. We have already explained these topics with examples in previous articles. For this article we assume that you are familiar with these terms and know how they function. We will use Packet Tracer network simulator software for demonstration purpose. You can download packet tracer from our site free of cost.
Scenario
You are a network administrator at ComputerNetworkingNotes.com. Company has three offices. Offices are connected with each other via layer 2 links. For redundancy purpose each office has one more layer 2 link. Company has two department sales and management. In each office we have one PC from each department. Company has one router. You can use router's Ethernet port for inter VLAN communication.
LAB Setup
To replicate given scenario create a topology in packet tracer, as shown in following image.
Configurations used in this topology are following
PCs Configuration
Device | IP Address | Subnet Mask | Gateway | VLAN | Connected With |
PC0 | 10.0.0.2 | 255.0.0.0 | 10.0.0.1 | VLAN 10 | Office 1 Switch on F0/1 |
PC1 | 20.0.0.2 | 255.0.0.0 | 20.0.0.1 | VLAN 20 | Office 1 Switch on F0/2 |
PC2 | 10.0.0.3 | 255.0.0.0 | 10.0.0.1 | VLAN 10 | Office 2 Switch on F0/1 |
PC3 | 20.0.0.3 | 255.0.0.0 | 20.0.0.1 | VLAN 20 | Office 2 Switch on F0/2 |
PC4 | 10.0.0.4 | 255.0.0.0 | 10.0.0.1 | VLAN 10 | Office 3 Switch on F0/1 |
PC5 | 20.0.0.4 | 255.0.0.0 | 20.0.0.1 | VLAN 20 | Office 3 Switch on F0/2 |
Office 1 Switch Configuration
Port | Connected To | VLAN | Link | Status |
F0/1 | With PC0 | VLAN 10 | Access | OK |
F0/2 | With PC1 | VLAN 20 | Access | OK |
Gig1/1 | With Router | VLAN 10,20 | Trunk | OK |
Gig 1/2 | With Switch2 | VLAN 10,20 | Trunk | OK |
F0/24 | Witch Switch2 | VLAN 10,20 | Trunk | STP - Blocked |
Office 2 Switch Configuration
Port | Connected To | VLAN | Link | Status |
F0/1 | With PC0 | VLAN 10 | Access | OK |
F0/2 | With PC1 | VLAN 20 | Access | OK |
Gig 1/2 | With Switch1 | VLAN 10,20 | Trunk | OK |
Gig 1/1 | With Switch3 | VLAN 10,20 | Trunk | OK |
F0/24 | Witch Switch1 | VLAN 10,20 | Trunk | STP - Blocked |
F0/23 | Witch Switch3 | VLAN 10,20 | Trunk | STP - Blocked |
Office 3 Switch Configuration
Port | Connected To | VLAN | Link | Status |
F0/1 | With PC0 | VLAN 10 | Access | OK |
F0/2 | With PC1 | VLAN 20 | Access | OK |
Gig 1/1 | With Switch2 | VLAN 10,20 | Trunk | OK |
F0/24 | Witch Switch1 | VLAN 10,20 | Trunk | STP - Blocked |
Router Configuration
Port | Connected To | VLAN | Link | Status |
Fa0/0 | with Office 1 Switch Gig 1/2 | VLAN 10, 20 | Trunk | Ok |
VLAN Configuration
VLAN Number | VLAN Name | Gateway IP | PCs |
10 | Sales | 10.0.0.1 | PC0,PC2,PC4 |
20 | Management | 20.0.0.1 | PC1,PC3,PC5 |
Assign IP Addresses to PCs
Assigning IP addresses is bit easy task in packet tracer. Just double Click on PC-PT and Click Desktop menu item and Click IP Configuration Select Static from radio option and fill IP address, subnet mask and default gateway IP in given input boxes. Use PC Configuration table to assign correct IP address.
That's all information we need to complete this exercise. In next section of this article we will configure VLAN, VTP, STP, DTP and Router on Stick in this topology. Before you jump in next section make sure you have above topology with IP addresses configured on all PCs. You can download this initial topology with IP addresses configured on all PCs from following link.
Configure VTP
VLAN Trunk Protocol (VTP) is a Cisco proprietary protocol used to share VLAN configuration across the network. Cisco created this protocol to share and synchronize their VLAN information throughout the network. Main goal of VTP is to manage all configured VLANs across the network.
In our network we only have three switches. We can easily add or remove VLAN manually on all three switches. However this process could be more tedious and difficult if we have 50 switches. In a large network, we might make a mistake in VLAN configuration. We might forget to add VLAN on one of the switch, or we may assign wrong VLAN number. Vice versa we may forget to remove VLAN on one of the switch, while removing VLANs.
VTP is a life saver protocol in this situation. With VTP we can add or remove VLANs on one switch and this switch will propagate VLAN information to all other switches in network.
VTP Messages
VTP share VLANs information via VTP messages. VTP messages can only be propagate through the trunk connections. So we need to set up trunk connection between switches. VTP messages are propagated as layer 2 multicast frames.
VTP Domain
VTP domain is a group of switches that share same VLAN information. A switch can have a single domain. VTP messages include domain name. Switch only update VLAN information if it receive VTP message from same domain.
VTP Mode
VTP can be configured in three different modes.
- Server
- Transparent
- Client
VTP Server Mode
VTP Server can add, modify, and delete VLANs. It will propagate a VTP message containing all the changes from all of its trunk ports. If server receives a VTP message, it will incorporate the change and forward the message from all remaining trunk ports.
VTP Transparent Mode
VTP Transparent switch can also make change in VLANs but it will not propagate these changes to other switches. If transparent switch receives a VTP message, it will not incorporate the change and forward the message as it receives, from all remaining trunk ports.
VTP Client Mode
VTP client switch cannot change the VLAN configurations itself. It can only update its VLAN configuration through the VTP messages that it receive from VTP server. When it receives a VTP message, it incorporates with the change and then forwards it from remaining trunk ports.
Configure VTP Server
We will configure Office 1 Switch as VTP Server. Double click on Office 1 Switch and Click CLI menu item and press Enter key to start CLI session.
By default all switches work as VTP server so we only need few commands to configure it. In following commands we will
- Set hostname to S1
- Set domain name to example
- Set password to vinita. (Password is case sensitive)
Switch>enable Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname S1 S1(config)#vtp mode server Device mode already VTP SERVER. S1(config)#vtp domain example Changing VTP domain name from NULL to example S1(config)#vtp password vinita Setting device VLAN database password to vinita
Configure VTP Client
We will configure Office 2 Switch and Office 3 Switch as VTP client switch. Access CLI prompts of Office 2 Switch and execute following commands
Switch>enable Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname S2 S2(config)#vtp mode client Setting device to VTP CLIENT mode. S2(config)#vtp domain example Changing VTP domain name from NULL to example S2(config)#vtp password vinita Setting device VLAN database password to vinita S2(config)#
Switch>enable Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname S3 S3(config)#vtp mode client Setting device to VTP CLIENT mode. S3(config)#vtp domain example Changing VTP domain name from NULL to example S3(config)#vtp password vinita Setting device VLAN database password to vinita S3(config)#
We have configured VTP server and VTP client. At this moment VTP client will not receive VTP messages from server. We need to configure DTP between switches.
Configure DTP
Dynamic Trunk Protocol (DTP) is again a Cisco proprietary protocol that is used on trunk connections to setup trunk dynamically. DTP supports five trunking modes.
DTP Mode ON
In ON mode interface is set to trunk, regardless remote end supports trunking or not. On mode cause interface to generate DTP messages and tag frames based on trunk type.
DTP Mode Desirable
In Desirable mode interface will generate the DTP messages and send them to other end. Interface will work as access link until it get replies from remote end. If reply messages indicate that remote device is trunking capable, DTP will change connection link in trunk from access link. If other end does not respond to DTP message, the interface will work as access link connection.
DTP Mode Auto
In auto mode interface works as access link and passively listen for DTP messages. Interface will change connection link to trunk, if it receives a DTP message from remote end.
DTP Mode No-Negotiate
In No-Negotiate mode interface is set as trunk connection. Interface will tag frames but it will not generate DTP messages. DTP is a Cisco's proprietary protocol, thus a non Cisco device will not understand it. This mode is used to trunk connection between Cisco device and a non Cisco device.
DTP Mode OFF
In off mode interface is configured as access-link. No DTP message will be generated nor frames will be tagged.
In our topology we need to configure trunk on following interfaces
Switch | Interfaces |
Office 1 | Gig1/1, Gig1/2, F0/24 |
Office 2 | Gig1/1, Gig1/2, F0/23, F0/24 |
Office 3 | Gig1/1, Gig1/2 |
By default all interface on switch starts as access link. switchport mode trunk command is used to change connection link in trunk. Run this command from interface mode. In next section we will change all necessary interfaces [given in above table] connection link in trunk.
Office 1 Switch
S1(config)#interface fastEthernet 0/24 S1(config-if)#switchport mode trunk %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up S1(config-if)#exit S1(config)#interface gigabitEthernet 1/1 S1(config-if)#switchport mode trunk S1(config-if)#exit S1(config)#interface gigabitEthernet 1/2 S1(config-if)#switchport mode trunk %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/2, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/2, changed state to up S1(config-if)#exit S1(config)#
Office 2 Switch
S2(config)#interface gigabitEthernet 1/1 S2(config-if)#switchport mode trunk %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/1, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/1, changed state to up S2(config-if)#exit S2(config)#interface gigabitEthernet 1/2 S2(config-if)#switchport mode trunk S2(config-if)#exit S2(config)#interface fastEthernet 0/23 S2(config-if)#switchport mode trunk %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to up S2(config-if)#exit S2(config)#interface fastEthernet 0/24 S2(config-if)#switchport mode trunk S2(config-if)#exit
Office 3 Switch
S3(config)#interface fastEthernet 0/24 S3(config-if)#switchport mode trunk S3(config-if)#exit S3(config)#interface gigabitEthernet 1/1 S3(config-if)#switchport mode trunk S3(config-if)#exit
So far in this article we have configured VTP server and VTP clients. We have also changed necessary links in trunk. Now we will configure VLANs on VTP server and that will automatically propagate VLANs in network.
Configure VLAN
In previous article we have explained VLANs in detail. So in this article we will only cover configuration part of VLANs.
How to create VLAN
vlan vlan number command is used to create the VLAN. VLANs are created on VTP Server. In our network, Office 1 Switch is working as VTP Server; thus we will create VLANs on it.
Office 1 Switch
S1(config)#vlan 10 S1(config-vlan)#exit S1(config)#vlan 20 S1(config-vlan)#exit S1(config)#
How to assign VLAN Membership
VLAN can be assigned statically or dynamically. CCNA exam only includes static method; therefore we will also use static method to assign VLAN membership.switchport access vlan [vlan number] command is used to assign VLAN to the interface. Following commands will assign VLANs to the interfaces.
Office 1 Switch
S1(config)#interface fastEthernet 0/1 S1(config-if)#switchport access vlan 10 S1(config-if)#interface fastEthernet 0/2 S1(config-if)#switchport access vlan 20
Office 2 Switch
S2(config)#interface fastEthernet 0/1 S2(config-if)#switchport access vlan 10 S2(config-if)#interface fastEthernet 0/2 S2(config-if)#switchport access vlan 20
Office 3 Switch
S3(config)#interface fastEthernet 0/1 S3(config-if)#switchport access vlan 10 S3(config-if)#interface fastEthernet 0/2 S3(config-if)#switchport access vlan 20
We have successfully assigned VLAN membership. It's time to test our configuration. To test this configuration, we will use ping command. ping command is used to test connectivity between two devices. As per our configuration, devices from same VLAN can communicate. Devices from different VLANs must not be able to communicate with each other without router.
Test VLAN configuration
Access PC's command prompt to test VLAN configuration. Double click PC-PT and click Command Prompt
We have two VLAN configurations VLAN 10 and VLAN 20. Let's test VLAN 10 first. In VLAN 10 we have three PCs with IP addresses 10.0.0.2, 10.0.0.3 and 10.0.0.4. These PCs must be able to communicate with each other's. At this point PCs from VLAN 10 should not be allowed to access PCs from VLAN 20. VLAN 20 also has three PCs 20.0.0.2, 20.0.0.3 and 20.0.0.4.
We have successfully implemented VLAN 10 now test VLAN 20.
Same as VLAN 10, PCs from VLAN 20 must be able to communicate with other PCs of same VLAN while they should not be able to access VLAN 10.
Congratulations we have successfully achieved one more mile stones of this article.
Configure Router on Stick
Typically routers are configured to receive data on one physical interface and forward that data from another physical interface based on its configuration. Each VLAN has a layer 3 address that should be configured as default gateway address on all its devices. In our scenario we reserved IP address 10.0.0.1 for VLAN 10 and 20.0.0.1 for VLAN 20.
With default configuration we need two physical interfaces on router to make this intra VLAN communication. Due to price of router, it’s not a cost effective solution to use a physical interface of router for each VLAN. Usually a router has one or two Ethernet interface. For example if we have 50 VLANs, we would need nearly 25 routers in order to make intra VLANs communications. To deal with situation we use Router on Stick.
Router on Stick is router that supports trunk connection and has an ability to switch frames between the VLANs on this trunk connection. On this router, single physical interface is sufficient to make communication between our both VLANs.
Access command prompt of Router
To configure Router on Stick we have to access CLI prompt of Router. Click Router and Click CLI from menu items and Press Enter key to access the CLI
Run following commands in same sequence to configure Router on Stick
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fastEthernet 0/0 Router(config-if)#no ip address Router(config-if)#no shutdown Router(config-if)#exit Router(config)#interface fastEthernet 0/0.10 Router(config-subif)#encapsulation dot1Q 10 Router(config-subif)#ip address 10.0.0.1 255.0.0.0 Router(config-subif)#exit Router(config)#interface fastEthernet 0/0.20 Router(config-subif)#encapsulation dot1Q 20 Router(config-subif)#ip address 20.0.0.1 255.0.0.0 Router(config-subif)#exit
- In above configuration we broke up single physical interface [FastEthernet 0/0] into two logical interfaces, known as sub-interfaces. Router supports up to 1000 interfaces including both physical and logical.
- By default interface link works as access link. We need to change it into trunk link. encapsulation commands specify the trunk type and associate VLAN with sub-interface.
- In next step we assigned IP address to our sub-interface.
That's all configuration we need to switch VLANs. Now we can test different VLAN communications. To test intra VLANs communication open command prompt of PC and ping the PC of other VLAN.
PC [10.0.0.3] from VLAN 10 can now access PC [20.0.0.2] from VLAN 20.
Spanning Tree Protocol (STP)
STP is a layer 2 protocol, used for removing loops. For backup purpose we typically create backup links for important resources. In our scenario, all offices have backup links that create loops in topology. STP automatically removes layer 2 loops. STP multicasts frame that contain information about switch interfaces. These frames are called BPDU (Bridge Protocol Data Units). Switch use BPDUs to learn network topology. If it found any loop, it will automatically remove that. To remove loop, STP disables port or ports that are causing it.
Due to length of this article we will explain STP with examples in next article.
How to configure VLAN VTP DTP cheat sheet
Command | Descriptions |
Switch(config)#vtp mode server | Configure Switch as VTP Server |
Switch(config)#vtp mode client | Configure Switch as VTP Client |
Switch(config)#vtp mode transparent | Configure Switch as VTP Transparent |
Switch(config)#no vtp mode Configure | Switch to default VTP Server Mode |
Switch(config)#vtp domain domain-name | Set VTP Domain name. |
Switch(config)#vtp password password | Set VTP password. Password is case sensitive |
Switch#show vtp status | Display VTP status including general information |
Switch#show vtp counters | Show VTP counters of switch |
Switch(config-if) #switchport mode trunk | Change interface mode in Trunk |
Switch(config)#vlan 10 | Create VLAN and associate number ID 10 with it |
Switch(config-vlan)#name Sales | Assign name to VLAN |
Switch(config-vlan)#exit | Return in Global configuration mode from VLAN configuration mode |
Switch(config)#interface fastethernet 0/1 | Enter in interface configuration mode |
Switch(config-if)#switchport mode access | Set interface link type to access link |
Switch(config-if)#switchport access vlan 10 | Assign this interface to VLAN 10 |
Switch#show vlan | Displays VLAN information |
Switch#show vlan brief | Displays VLAN information in short |
Switch#show vlan id 10 | Displays information VLAN ID 10 only |
Switch#show vlan name sales | Displays information about VLAN named sales only |
Switch(config)#interface fastethernet 0/8 | Enter in Interface configuration mode |
Switch(config-if)#no switchport access vlan 10 | Removes interface from VLAN 10 and reassigns it to the default VLAN - VLAN 1 |
Switch(config-if)#exit | Move back to Global configuration mode |
Switch(config)#no vlan 10 | Delete VLAN 10 from VLAN database |
Switch#copy running-config startup-config | Saves the running configuration in NVRAM |
Tidak ada komentar:
Posting Komentar