2023年7月20日发(作者:)
跨交换机vlan间路由实验<单臂路由器
2009-05-05 00:47
拓扑图:(BOSIN NETSIMEX模拟器下命令:)
<——点击看大图
1)配置各交换机Hostname分别为SW_X(其中x为第几个交换机)
switch> 用户执行模式提示符
switch>enable 进入特权模式
switch# 特权模式提示符
switch#configure terminal 进入全局配置模式
switch(config)# 全局配置模式提示符
switch(config)#hostname SW_1/SW_2/SW_3 (设置主机名为SW_1/SW_2/SW_3)
2)按要求在各交换机上划分vlan:
SW_2#vlan database (进入vlan配置子模式)
SW_2(vlan)#vlan 2 (创建vlan 2,系统自动命名为:vlan0002)
sw_2(vlan)exit
sw_2#configure terminal
sw_2(config)#interface range fa 0/3 - 14 (进入端口fa0/3—fa0/14)
当使用interface range命令时有如下的规则:
有效的组范围:
vlan从1 到4094 fastethernet 槽位/{first port} - {last port}, 槽位为0
gigabitethernet槽位/{first port} - {last port},槽位为0
port-channel port-channel-number - port-channel-number, port-channel号从1到64
端口号之间需要加入空格,如:interface range fastethernet 0/1 – 5 是有效的,而interface range fastethernet 0/1-5 是无效的.
interface range 命令只能配置已经存在的interface vlan
所有在同一组的端口必须是相同类别的。
sw_2(config-range)#switchport access vlan 2 (将端口fa0/3—fa0/14划分到vlan 2)
sw_3#vlan database (进入vlan配置子模式)
sw_3(vlan)#vlan 3 (创建vlan 3,系统自动命名为:vlan0003)
sw_3(vlan)exit
sw_3#configure terminal
sw_3(config)#interface range fa 0/3 - 14 (进入端口fa0/3—fa0/14)
sw_3(config-range)#switchport access vlan 3 (将端口fa0/3—fa0/14划分到vlan 3)
在各交机上配置管理vlan 1并设定 ip地址:
sw_1#vlan database
sw_1(vlan)#vlan 1
sw_1(vlan)#exit
sw_1#config terminal
sw_1(config)#interface vlan 1 (进入VLAN 1接口子模式)
sw_1(config-if)ip address 10.0.0.1 255.255.255.0
sw_1(config-if)no shutdown (交换机,路由器,各接口默认状态是DOWN的,一定要开启!切记!)
sw_2#vlan database
sw_2(vlan)#vlan 1
sw_2(vlan)#exit
sw_2#config terminal
sw_2(config)#interface vlan 1
sw_2(config-if)ip address 10.0.0.2 255.255.255.0
sw_2(config-if)no shutdown
sw_3#vlan database
sw_3(vlan)#vlan 1
sw_3(vlan)#exit
sw_3#config terminal
sw_3(config)#interface vlan 1
sw_3(config-if)ip address 10.0.0.3 255.255.255.0
sw_3(config-if)no shutdown
3)按照配置设置各trunk端口:
sw_1(config)#interface range fa 0/1 - 4 sw_1(config-range)#switchport mode trunk (将fa0/1 -
fa0/4 端口模式设置为trunk)
sw_2(config)#interface range fa 0/1 - 2
sw_2(config-range)switchport mode trunk (将端口fa0/1,fa0/2配置成trunk模式)
sw_3(config)#interface range fa 0/1 - 2
sw_3(config-range)switchport mode trunk (将端口fa0/1,fa0/2配置成trunk模式)
注意:在思科模拟器上生成树协议(STP)是自动开启的,(手动开启命令为:spanning-tree rstp)
4)配置单臂路由器,并实现VLAN 2 与 VLAN 3之间的主机相互访问(跨交换机的不同vlan间要相互访问需要借助路由器或三层交换机)
sw_1(config)#interface fa 0/5
sw_1(config-if)#switchport mode trunk
sw_1(config-if)switchport trunk encapsulation
dot1q (在trunk 干路上封装基于vlan的802.3q协议)
r1(config)#interface fa
0/0.1 (在路由器fa0/0接口启用fa0/0.1接口模式)
r1(config-subif)#enacpsulation dot1q
1 (将vlan1封装802.1q协议)
r1(config-subif)#ip address 10.0.0.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config)#interface fa 0/0.2
r1(config-subif)#enacpsulation dot1q
2 (将vlan2封装802.1q协议)
r1(config-subif)#ip address 20.0.0.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config)#interface fa 0/0.3
r1(config-subif)#enacpsulation dot1q
3 (将vlan 3封装802.1q协议)
r1(config-subif)#ip address 30.0.0.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config)#interface fa 0/0
r1(config-if)#speed 100 (设置端口带宽为100Mbps)
r1(config-if)#duplex full (端口全双工模式)
根据要求设置,在默认情况下是不需要设置的。
r1(config-if)#no shutdown (激活fa0/0端口)
在PC命令行,输入:winipcfg,按要求配置IP地址后,vlan 2里的PC 是可以PING 通 vlan3里的PC 的!
5)设置登陆密码,和特权密码:
sw_1(config)#line vty 0 15
sw_1(config-line)#login
sw_1(config-line)#password cisco (交换机远程登陆line 密码)
sw_1(config-line)#exit
sw_1(config)#enable password benet (明文特权模式使能密码)
sw_1(config)#enable secret benet(密文特权模式使能密码)
sw_2与sw_3的配置与sw_1相同不再一一列出。交换机与路由器的特权模式使能密码配置相同,远程登陆密码配置略有区别,如下:
r1(config)#line vty 0 4
r1(config-line)#login
r1(config-line)#password cisco (路由器远程登陆line密码)
···
配置完成在任何一设备上telnet +ip 就可以远程登陆到该设备了!
发布者:admin,转转请注明出处:http://www.yc00.com/web/1689805127a287808.html
评论列表(0条)