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


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

 还是 发一下 博文吧,  大笑


【简单拓扑图】:




【注释】

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

  

【注意】

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


【命令】:

交换机1:  配置 VALN 3

Switch#en
Switch#conf
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#int fa0/1   // fa0/1 与fa0/2 端口接在 vlan3 上
Switch(config-if)#switchport mode access 
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config)#int fa0/2
Switch(config-if)#switchport mode access 
Switch(config-if)#switchport access vlan 3
Switch(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 up
Switch(config-if)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console


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

Switch#en
Switch#conf
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 3
Switch(config-vlan)#vlan 4
Switch(config-vlan)#exit
Switch(config)#int fa0/1    // fa0/1 与fa0/2 端口接在 vlan4 上
Switch(config-if)#switchport mode access 
Switch(config-if)#switchport access vlan 4
Switch(config-if)#exit
Switch(config)#int fa0/2
Switch(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 3
Switch(config-if)#exit
Switch(config)#int fa0/24  // fa0/4路线设置成trunk模式
Switch(config-if)#switchport mode access 
Switch(config-if)#switchport mode trunk
Switch(config)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console


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


Switch>en
Switch#conf
Configuring 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 4
Switch(config-vlan)#exit
Switch(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 up
Switch(config-if)#ip address 192.168.3.69 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#exit
Switch(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 up
Switch(config-if)#ip address 192.168.4.69 255.255.255.0
Switch(config-if)#no shut
Switch(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 up
Switch(config-if)#exit
Switch(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 up
Switch(config-if)#ip routing	  // 开启 路由功能!!!!!!!!!!!!! very important!!
Switch(config)#end
Switch#
%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   

///华丽分割线///

  • 5
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值