The experimental topology is as follows:
First, understand the principle of single arm routing
1. LINK Type
The connection between the PC and the switch is the access layer, so the access link is used, but VLAN10 and VLAN20 need to communicate and all need to go through the router, so the link between the switch and the router is trunk.
2, the router's sub-interface
The physical interface of a router can be divided into multiple logical interfaces, which are known as sub-interfaces, which cannot be individually turned on or off, and all sub-interfaces are turned on or off when the physical interface is turned on or off.
3, the VLAN label conversion
In addition to encapsulating the MAC address of the data, the router will need to convert the label of the VLAN during the process of forwarding data. When PC1 sends a data frame to the gateway router, the label of the data frame belongs to the VLAN10, and when the data is forwarded from the router, the VLAN's label is converted to VLAN20.
Two, the single arm routing configuration process
1, the router to create a sub-interface, and configure the VLAN tag packaging structure
R1 (config) #int f0/0.1
R1 (config-subif) #encapsulaton dot1q 10
R1 (config-subif) #ip add 192.168.1.1 255.255.255.0
R1 (config-subif) #exit
R1 (config) #int f0/0.2
R1 (config-subif) #encapsulaton dot1q 20
R1 (config-subif) #ip add 192.168.2.1 255.255.255.0
R1 (config-subif) #exit
R1 (config) #int f0/0
R1 (config-if) #no sh
R1 (config-if) #exit
Note: The above "Encapsulaton dot1q 10" After 10 refers to VLAN 10,20 also refers to VLAN 20.