Encapsulation Dot1Q Command on CISCO Router/Switch

Other Cisco Other Cisco Material Original source

Command

Encapsulation Dot1Q

Use

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 VLANs.

Syntax

Router(config-subif)#encapsulation dot1Q

Option

Sets the vlan on the subinterface to act as the native VLAN.

Example

In the below example we will configure a basic “router on a stick” configuration. First, we will configure the port connected to 2611XM’s Fa0/1 interface to be a trunk on the switch.
Routers only support Dot1Q encapsulation.

Copy

2950-XL#show cdp neighbor

Capability Codes: R – Router, T – Trans Bridge, B – Source Route Bridge

S – Switch, H – Host, I – IGMP, r – Repeater



Device ID Local Intrfce Holdtme Capability Platform Port ID

2611XM Fas 0/1 174 R S I Cisco 2611Fas 0/0

2611XM Fas 0/3 166 R S I Cisco 2611Fas 0/1



2950-XL#conf t

2950-XL(config)#int fa0/3

2950-XL(config-if)#switchport trunk encapsulation dot1q

2950-XL(config-if)#switchport mode trunk

Now we configure the router’s Fa0/1 interface to act as a trunk.
First, we remove the ip address on the physical interface.
Next, we configure a subinterface for each VLAN the link will be a trunk for. The interface number can be anything you want.
After that, we configure encapsulation dot1q for each subinterface. This command has to be entered before the IP address or you will get an error seen below.
Finally, configure an ip address for the VLAN. This is typically a default gateway.

Copy

2611XM(config-if)#int fa0/1

2611XM(config-if)#no ip add

2611XM(config-if)#no shut

2611XM(config-if)#int fa0/1

*Jul 25 02:40:49.523: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up



2611XM(config-if)#int fa0/1.70

2611XM(config-subif)#encapsulation dot1Q 70

2611XM(config-subif)#ip add 10.10.70.1 255.255.255.0



2611XM(config-subif)#int fa0/1.99

2611XM(config-subif)#ip add 10.10.99.1 255.255.255.0



% Configuring IP routing on a LAN subinterface is only allowed if that

subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q,

or ISL vLAN.



2611XM(config-subif)#encapsulation dot1Q 99

2611XM(config-subif)#ip add 10.10.99.1 255.255.255.0

For testing we will add a couple SVI interfaces so we can do some ping tests.

Copy

2950-XL(config)#int vlan 70

2950-XL(config-subif)#ip add 10.10.70.254 255.255.255.0

2950-XL(config-subif)#int vlan 99

2950-XL(config-subif)#ip add 10.10.99.254 255.255.255.0

2950-XL(config-subif)#end

2950-XL#ping 10.10.70.1



Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.70.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/6 ms

2950-XL#ping 10.10.99.1



Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.99.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/203/1006 ms

2950-XL#
← All Other Cisco articles Home