两层交换机上划分VLAN借三层交换机路由功能实现跨网段访问(Cisco Packer Tracer 模拟器)

来源:互联网 发布:人力资源管理 知乎 编辑:程序博客网 时间:2024/05/16 19:47


忙活了一下午 , 终于成功了  不容易啊!  

 还是 发一下 博文吧,  大笑


【简单拓扑图】:




【注释】

这里 划分了 两个vlan 3 和 4     vlan3 分布在交换机1 和 2 中

  

【注意】

ip 网关的 网段保持一致!!!!不要忘记设置主机网关  以及端口与命令保持一致!!!  this very important!!


【命令】:

交换机1:  配置 VALN 3

Switch#enSwitch#confConfiguring from terminal, memory, or network [terminal]? Enter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 3Switch(config-vlan)#exitSwitch(config)#int fa0/1   // fa0/1 与fa0/2 端口接在 vlan3 上Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3Switch(config-if)#exitSwitch(config)#int fa0/2Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3Switch(config)#int fa0/24  // fa0/4路线设置成trunk模式Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to upSwitch(config-if)#endSwitch#%SYS-5-CONFIG_I: Configured from console by console


交换机2:  含两个vlan  3 和 4

Switch#enSwitch#confConfiguring from terminal, memory, or network [terminal]? Enter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 3Switch(config-vlan)#vlan 4Switch(config-vlan)#exitSwitch(config)#int fa0/1    // fa0/1 与fa0/2 端口接在 vlan4 上Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 4Switch(config-if)#exitSwitch(config)#int fa0/2Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 4 Switch(config)#int fa0/3  // fa0/3 端口接在 vlan3 上Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3Switch(config-if)#exitSwitch(config)#int fa0/24  // fa0/4路线设置成trunk模式Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunkSwitch(config)#endSwitch#%SYS-5-CONFIG_I: Configured from console by console


三层交换机: 配置vlan 3和 4 并设置网关设置为routing模式


Switch>enSwitch#confConfiguring from terminal, memory, or network [terminal]? Enter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 3      // 创造 VLAN 3 和 4 Switch(config-vlan)#vlan 4Switch(config-vlan)#exitSwitch(config)#int vlan 3   // VLAN 3 设置网关地址Switch(config-if)#%LINK-5-CHANGED: Interface Vlan3, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to upSwitch(config-if)#ip address 192.168.3.69 255.255.255.0Switch(config-if)#no shutSwitch(config-if)#exitSwitch(config)#int vlan 4    // VLAN 4设置网关地址Switch(config-if)#%LINK-5-CHANGED: Interface Vlan4, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan4, changed state to upSwitch(config-if)#ip address 192.168.4.69 255.255.255.0Switch(config-if)#no shutSwitch(config-if)#int fa0/1    //fa0/1 和fa0/2 设置为trunk 模式Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to upSwitch(config-if)#exitSwitch(config)#int fa0/2   //fa0/1 和fa0/2 设置为trunk 模式Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to upSwitch(config-if)#ip routing  // 开启 路由功能!!!!!!!!!!!!! very important!!Switch(config)#endSwitch#%SYS-5-CONFIG_I: Configured from console by console



【测试】

PC –1  ping -----------à  others

ping  192.168.3.2 同一换机 同一vlan 



ping   


ping 192.168.4.3  不同交换机 不同vlan   



ping   第一次 存在丢包原因:ping第一个数据是ARP广播包,建立MAC地址IP地址对应表,因为一开始是不知道对方的MAC地址所以丢包
第二次就可以100%成功


ping 192.168.3.5  不同交换机 同一vlan 




同样 ping 同样  第一次存在丢包 第二次 100%成功



【完工 】


///////////////////////////////////////////////华丽分割线///////////////////////////////////////////////////////////////////////

                    各位客官老爷 若在实现过程中 出现问题,欢迎指正错误。

By sizaif     version: 1.01   

///////////////////////////////////////////////华丽分割线///////////////////////////////////////////////////////////////////////

阅读全文
0 0
原创粉丝点击