一台路由器
一台交换机
两台PC机
路由器配置:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e0/0
R1(config-if)#no sh
R1(config-if)#int e0/0.1
R1(config-subif)#encapsulation dot1Q 2 //子接口封装VLAN
R1(config-subif)#ip address 192.168.10.1 255.255.255.0
R1(config-subif)#no sh
R1(config-subif)#int e0/0.
R1(config-subif)#int e0/0.2
R1(config-subif)#encapsulation dot1Q 3 //子接口封装VLAN
R1(config-subif)#ip address 192.168.20.1 255.255.255.0
R1(config-subif)#no sh
R1(config-subif)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES unset up up
Ethernet0/0.1 192.168.10.1 YES manual up up
Ethernet0/0.2 192.168.20.1 YES manual up up
Ethernet0/1 unassigned YES unset administratively down down
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
交换机配置:
SW1#
SW1#vlan database
SW1(vlan)#vlan 2 //创建VLAN2
VLAN 2 added:
Name: VLAN0002
SW1(vlan)#vlan 3 //创建VLAN3
VLAN 3 added:
Name: VLAN0003
ot half duplex), with R1 Ethernet0/0 (half duplex).
SW1(vlan)#exit
APPLY completed.
Exiting....
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#int f1/0
SW1(config-if)#switchport mode trunk //设置F1/0为中继
SW1(config-if)#no sh
SW1(config-if)#int f1/1
SW1(config-if)#switchport access vlan 2 //接口加入VLAN2
SW1(config-if)#int f1/2
SW1(config-if)#switchport access vlan 3 //接口加入VLAN3
SW1(config-if)#do sh vlan-s br
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa1/3, Fa1/4, Fa1/5,
Fa1/6,Fa1/7, Fa1/8,
Fa1/9, Fa1/10,Fa1/11,
Fa1/12, Fa1/13, Fa1/14
Fa1/15
2 VLAN0002 active Fa1/1
3 VLAN0003 active Fa1/2
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
SW1(config-if)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
FastEthernet1/0 unassigned YES unset up up
FastEthernet1/1 unassigned YES unset up up
FastEthernet1/2 unassigned YES unset up up
FastEthernet1/3 unassigned YES unset up down
FastEthernet1/4 unassigned YES unset up down
FastEthernet1/5 unassigned YES unset up down
FastEthernet1/6 unassigned YES unset up down
FastEthernet1/7 unassigned YES unset up down
FastEthernet1/8 unassigned YES unset up down
FastEthernet1/9 unassigned YES unset up down
FastEthernet1/10 unassigned YES unset up down
FastEthernet1/11 unassigned YES unset up down
FastEthernet1/12 unassigned YES unset up down
FastEthernet1/13 unassigned YES unset up down
FastEthernet1/14 unassigned YES unset up down
FastEthernet1/15 unassigned YES unset up down
Vlan1 unassigned YES unset up up
查看两台PC机的状况