SW1# show cdp neighbours
SW1#int fa0/1
SW1#
SW1#switchport mode access
SW1#switchport mode trunk
What is trunk encapsulation
SW1#switchport trunk encapsulation dot1q
SW1# switchport mode trunk
THAT is SW's configure the switchport to connect to the router:
SW1#no switchport access vlan 2
R1#conf t
R1#int fa0/0
R1#no ip address
R1#int fa0/0.2
R1#encapsulation dot1q {vlan ID} 2
R1#int fa0/0.4
R1#encapsulation dot1q 4
FastEthernet fa0/0.2 and fa0/0.4 are SUBINTERFACES. And this subdivision is just from layer 2-layer 1 point of view.
R1#show ip run
R1#
We put 0.2 and 0.4 like different ports with dif ip addresses
R1#conf t
R1#int fa0/0.2
R1#ip address 192.168.1.1 255.255.255.0
R1#int fa0/0.4
R1#ip address 192.168.3.1 255.255.255.0
R1#show ip route
It shows DG is 192.168.1.254
R1#conf t
R1#int fa0/0
R1#no ip address
R1#conf t
R1#ip routing
R1#end
We see that as there are different physical ports.
At this point, workstations on VLAN 2 should be able to ping the 192.168.1.0 address, and workstations on VLAN 4 should be able to ping the 192.168.3.0 address.
If, for some reason, the native VLAN on the switchport is something other than 1, change the encapsulation statement on the router, or the trunk may not form.
Secondary addressing. We have a key interface
Connect a Cisco switch and router via 802.1q trunking. This configuration is known as a router-on-a-stick.
ROUTER ON A STICK
First, let’s start with the switch. VLAN 1 exists by default, so we’ll add a couple of other VLANs:
vlan 100 name data
state active
vlan 200 name data
state active
Now, let’s configure the switchport to connect to the router:
interface fastethernet 1/0/1 switchport trunk encapsulation dot1q
switchport mode trunk
Over to the router!
interface fastethernet 0/0 no ip address
interface fastethernet 0/0.1 encapsulation dot1q 1 native
interface fastethernet 0/0.100 encapsulation dot1q 100
ip address 192.168.100.1 255.255.255.0
interface fastethernet 0/0.200 encapsulation dot1q 200
ip address 192.168.200.1 255.255.255.0
At this point, workstations on VLAN 100 should be able to ping the 192.168.100.1 address, and workstations on VLAN 200 should be able to ping the 192.168.200.1 address.
If, for some reason, the native VLAN on the switchport is something other than 1, change the encapsulation statement on the router, or the trunk may not form.