/Sw1#configure terminal
Sw1(config)#vlan 10
Sw1(config-vlan)#name Sales
Sw1(config-vlan)#exit
Sw1(config)#vlan 20
Sw1(config-vlan)#name HR
Sw1(config-vlan)#exit
Sw1(config)#interface ethernet 0/1
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 10
Sw1(config-if)#exit
Sw1(config)#interface ethernet 0/2
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 20
Sw1(config-if)#exit
Sw1(config)#interface ethernet 0/0
Sw1(config-if)#switchport trunk encapsulation dot1q
Sw1(config-if)#switchport mode trunk 0, changed state to up
Sw1(config-if)#exit
Sw1(config)#exit
Sw1#write memory
Warning: Attempting to overwrite an NVRAM configuration previously written
by a different version of the system image.
Overwrite the previous NVRAM configuration?[confirm]
Building configuration...
Compressed configuration from 1513 bytes to 904 bytes[OK]
Sw1#
R1#configure terminal
R1(config)#interface fastEthernet 0/0.10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 192.168.10.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface fastEthernet 0/0.20
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip address 192.168.20.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if)#no shutdown et0/0, changed state to up
R1(config-if)#^Z
R1#write memory
Warning: Attempting to overwrite an NVRAM configuration previously written
by a different version of the system image.
Overwrite the previous NVRAM configuration?[confirm]
Building configuration...
[OK]
R1#
PC1> ip 192.168.10.100/24 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.100 255.255.255.0 gateway 192.168.10.1
PC1> show ip
NAME : PC1[1]
IP/MASK : 192.168.10.100/24
GATEWAY : 192.168.10.1
DNS :
MAC : 00:50:79:66:68:00
LPORT : 20008
RHOST:PORT : 127.0.0.1:20009
MTU : 1500
PC1> save
Saving startup configuration to startup.vpc
. done
PC1>
PC2> ip 192.168.20.100/24 192.168.20.1
Checking for duplicate address...
PC2 : 192.168.20.100 255.255.255.0 gateway 192.168.20.1
PC2> show ip
NAME : PC2[1]
IP/MASK : 192.168.20.100/24
GATEWAY : 192.168.20.1
DNS :
MAC : 00:50:79:66:68:05
LPORT : 20010
RHOST:PORT : 127.0.0.1:20011
MTU : 1500
PC2> save
Saving startup configuration to startup.vpc
. done
PC2>
PC1> ping 192.168.10.1
84 bytes from 192.168.10.1 icmp_seq=1 ttl=255 time=60.945 ms
84 bytes from 192.168.10.1 icmp_seq=2 ttl=255 time=13.229 ms
^C
PC1>
PC1> ping 192.168.20.1
84 bytes from 192.168.20.1 icmp_seq=1 ttl=255 time=4.773 ms
84 bytes from 192.168.20.1 icmp_seq=2 ttl=255 time=4.761 ms
^C
PC1>
PC1> ping 192.168.20.100
84 bytes from 192.168.20.100 icmp_seq=1 ttl=63 time=32.970 ms
84 bytes from 192.168.20.100 icmp_seq=2 ttl=63 time=19.624 ms
^C
PC1>