<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

我们知道不同的vlan之间要相互的通行必须要借用第三层,也就是网络层,可以路由器也可以是三层的交换机。三层 拓扑图

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

1-6

创建Vlan并设置为服务端

Switch>en

Switch#vlan database

Switch(vlan)#vlan 2 name vlan2

VLAN 2 added:

Name:vlan2

Switch(vlan)#vlan 3 name vlan3

VLAN 3 added:

Name:vlan3

Switch(vlan)#vtp server

Switch(vlan)#vtp domain lcl

VTP domain lcl modified

Switch(vlan)#exit

APPLY completed.

Exiting....

f0/1为干道

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#int f0/1

Switch(config-if)#switchport trunk encapsulation dot1q

Switch(config-if)#switchport mode trunk

Switch(config-if)#end

进入vlan配置ip

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#ip routing

Switch(config)#int vlan 2

Switch(config-if)#ip address 192.168.2.1 255.255.255.0

Switch(config-if)#no shut

Switch(config-if)#exit

Switch(config)#int vlan 3

Switch(config-if)#ip address 192.168.3.1 255.255.255.0

Switch(config-if)#no shut

Switch(config-if)#exit

设置为客户端

Switch>en

Switch#vlan database

Switch(vlan)#vtp client

Switch(vlan)#vtp domain lcl

Changing VTP domain from NULL to lcl

Switch(vlan)#exit

APPLY completed.

Exiting....

f0/1为干道

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#int f0/1

Switch(config-if)#switchport trunk encapsulation dot1q

Switch(config-if)#switchport mode trunk

Switch(config-if)#end

端口加入Vlan

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#int f0/2

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 2

Switch(config-if)#exit

Switch(config)#int f0/2

Switch(config-if)#exit

Switch(config)#int f0/3

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 3

Switch(config-if)#end

结果两个不同vlan的两台PCping成功