The previous experiment shows that cross-VLAN is not able to communicate even if the same network segment.
So how to solve this method, this is the focus of this experiment.
Experimental topology
Requirements
Use DHCP technology to get your PC to automatically obtain IP addresses and ensure that you can communicate with each other.
Solutions
You can see that this topology and the previous experiment is almost a small difference, is to add a router, but this router is the focus.
The switch configuration is the same as the previous experimental configuration
SW2 switch configuration Trunk on E1/1 interface
SW2 (config) #interface Ethernet 1/1
SW2 (config-if) #switchport trunk Encapsulation dot1q
SW2 (config-if) #switchport mode trunk
How does a router recognize the forwarding of two VLANs with only one line?
This involves the concept of sub-interfaces, which we can "change" into two lines and allow him to identify two different VLANs.
Configuration of the switch there's been an experiment.
Here is the configuration of the router
R1 (config) #interface Ethernet 1/1
R1 (config-if) #no shutdown
R1 (config-if) #ex
R1 (config) #int e1/1.10
R1 (config-subif) # encapsulation dot1q 10
R1 (config-subif) #ip address 192.168.1.254 255.255.255.0
R1 (config) #int e1/1.20
R1 (config-subif) # encapsulation dot1q 20
R1 (config-subif) #ip address 192.168.2.254 255.255.255.0
R1 (config) #ip DHCP pool 10
R1 (dhcp-config) #default-router 192.168.1.254
R1 (dhcp-config) #network 192.168.1.0 255.255.255.0
R1 (config) #ip DHCP pool 20
R1 (dhcp-config) #default-router 192.168.2.254
R1 (dhcp-config) #network 192.168.2.0 255.255.255.0
Verify
You can see that the IP of PC1 is automatically secured and can ping through PC2
And Ping PC4 is also available.
Experiment completed
Single-arm Routing and DHCP