《VLAN配置实例.doc》由会员分享,可在线阅读,更多相关《VLAN配置实例.doc(9页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、-*VLAN配置实例网络拓扑如下图所示:这个网络有两台2950 交换机,连接到路由器LAB_B的叫2950B,连接到路由器LAB_C的叫2950C。为了管理VLAN,VLAN1使用172.16.10.0/24网络地址;路由器LAB_B的fa0/0接口用来配置VLAN间的路由,每个交换机必须有一个172.16.10.0网络中的Ip地址,子网间可以相互通信。计划创建两个子网:VLAN 2 拥有子网络地址172.16.20.0/24,VLAN 3拥有网络地址172.16.30.0/24。将fa0/2分配给VLAN2,将fa0/3分配给VLAN3。第一步:进行交换机的基本配置,包括名字、地址等2950
2、C交换机的配置:Switch(config)#hostname 2950C2950C(config)#enable secret todd2950C(config)#line con 02950C(config-line)#login2950C(config-line)#password console2950C(config-line)#line vty 0 152950C(config-line)#login2950C(config-line)#password telnet2950C(config-if)#interface f0/42950C(config-if)#descriptio
3、n Connection to 2950B2950C(config-if)#int f0/52950C(config-if)#description 2nd connection to 2950B2950C(config-if)#int vlan12950C(config-if)#ip address 172.16.10.2 255.255.255.0 /配置管理地址2950C(config-if)#no shut2950C(config-if)#exit2950C(config)#ip default-gateway 172.16.10.12950C(config)#Z 2950C#copy
4、 run startDestination filename startup-config? Press EnterBuilding configuration.OK2950C#2950B交换机的配置:Switch(config)#hostname 2950B2950B(config)#enable secret todd2950B(config)#line con 02950B(config-line)#login2950B(config-line)#password console2950B(config-line)#line vty 0 152950B(config-line)#logi
5、n2950B(config-line)#password telnet2950B(config)#int f0/12950B(config-if)#description Connection to router2950B(config)#int f0/42950B(config-if)#desc connection to 2950C2950B(config-if)#int f0/52950B(config-if)#desc 2nd connection to 2950C2950B(config-if)#int vlan 12950B(config-if)#ip address 172.16
6、.10.3 255.255.255.02950B(config-if)#no shut2950B(config-if)#exit2950B(config)#ip default-gateway 172.16.10.12950B(config)#exit2950B#copy run startDestination filename startup-config? Press EnterBuilding configuration.OK2950B#2950B#ping 172.16.10.2 /检查和2950C的连通情况.!到目前为止,两台交换机已经完成基本的信息配置,并且能够ping通。第二步
7、:将在互连的交换机上设置中继/主干2950B(config)#int f0/12950B(config-if)#switchport mode trunk2950B(config-if)#int f0/42950B(config-if)#switchport mode trunk2950B(config-if)#int fa0/52950B(config-if)#switchport mode trunk2950C(config)#int fa0/42950C(config-if)#switchport mode trunk2950C(config-if)#int fa0/52950C(con
8、fig-if)#switchport mode trunk使用show interface trunk命令查看配置是否正确:2950B#sh int trunk第三步:设置VTP,创建VLAN2950C(config)#vtp mode serverDevice mode already VTP SERVER.2950C(config)#vtp domain RouterSim2950C(config)#z2950C#vlan database2950C(vlan)#vlan 2 name SalesVLAN 2 added:Name: Sales2950C(vlan)#vlan 3 name
9、 MarketingVLAN 3 added:Name: Marketing2950C(vlan)#applyAPPLY completed.2950C(vlan)#注意:在创建VLAN之前,务必先配置VTP信息。可以使用命令检查刚才所作的配置是否正确: show vlan brief2950C#sh vlan brief接下来,就要为VLAN分配成员了,将接口fa0/2 分配给VLAN 2,将接口 fa0/3 分配给VLAN 3。注意:所有的端口缺省地属于 VLAN 1 ,除非另外指定。2950C#config t2950C(config)#int fa0/22950C(config-if)
10、#switchport access vlan 22950C(config-if)#int fa0/32950C(config-if)#switchport access vlan 3使用命令检查配置是否正确:show vlan brief至此,2950C的VTP信息、VLAN、成员信息配置完成了,接下来配置2950B。把2950B设置为一个VTP client,可从2950C上获取VLAN数据库的信息。2950B(config)#vtp domain RouterSimDevice mode set to VTP CLIENT.2950B(config)#vtp mode client295
11、0B(config)#z注意:1。首先要设置vtp域名,在将缺省的模式变为client模式之前;2。同步vtp域名后,client交换机从server处获取VLAN信息,可用show vlan brif验证:现在只需要把交换机的端口分配给VLAN:2950B(config)#int fa0/22950B(config-if)#switchport access vlan 22950B(config-if)#int fa0/32950B(config-if)#switchport access vlan 3第四步:VLAN间路由所有的配置几乎都完成了,现在VLAN内部可以通信,但是VLAN间还不
12、能通信,为了让VLAN间通信,必须让Lab_B 来参与:Router(config)#hostname TrunkrouterTrunkrouter(config)#int f0/0Trunkrouter(config-if)#no ip addressTrunkrouter(config-if)#no shutdownTrunkrouter(config-if)#int f0/0.1Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0Configuring IP routing on a LAN subinterface
13、 is only allowed if that subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q, or ISL VLAN.Trunkrouter(config-subif)#encapsulation dot1q 1Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0Trunkrouter(config-subif)#int f0/0.2Trunkrouter(config-subif)#encap dot1q 2Trun
14、krouter(config-subif)#ip address 172.16.20.1 255.255.255.0Trunkrouter(config-subif)#int f0/0.3Trunkrouter(config-subif)#encap dot1q 3Trunkrouter(config-subif)#ip address 172.16.30.1 255.255.255.0Trunkrouter(config-subif)#exit注意到,创建了三个子接口来容纳三个VLAN,可以使用show run来检查刚才做的配置:Trunkrouter#show run!interface
15、FastEthernet0/0no ip addressno ip directed-broadcast!interface FastEthernet0/0.1encapsulation dot1Q 1ip address 172.16.10.1 255.255.255.0no ip directed-broadcast!interface FastEthernet0/0.2encapsulation dot1Q 2ip address 172.16.20.1 255.255.255.0no ip directed-broadcast!interface FastEthernet0/0.3encapsulation dot1Q 3ip address 172.16.30.1 255.255.255.0no ip directed-broadcast!现在,所有的工作到做好了,应该可以正常工作了。
限制150内