Cisco packet tracer--VLAN&VLAN间路由

 

目录

一.VLAN

1.什么是VLAN?

2.为什么要划分VLAN?

二.数据在三层交换机或路由器中的转发原理

三.VLAN配置项目举例

1.VLAN配置

1.1假设企业甲的情况及要求:

1.2网络管理员或乙方进行网络规划:

1.3项目实施

1.4.配置脚本

1.5.总结

四.路由器实现VLAN间路由

1.  继续完成上一章 VLAN配置举例中的案例

1.1汇聚交换机上联口配置脚本

1.2路由器配置脚本

2.最终拓补图

3.故障分析

五.三层交换机实现VLAN间路由

1. 三层交换机实现VLAN间路由-拓扑图

​编辑

2. 三层交换机实现VLAN间路由-配置脚本

六.vlan中继(Trunk)&VLAN间路由

1. 拓扑

​编辑

2.配置脚本

3.结果验证


 

一.VLAN

1.什么是VLAN?

VLAN, Virtual LAN,虚拟局域网,是一个逻辑概念。在TCP/IP 5层模型中,VLAN属于数据链路层的概念。

2.为什么要划分VLAN?

  • vlan可以划分广播域,降低单个局域网内部的广播包的数量,从而减小网络中不必要的流量,特别是早期的局域网,带宽只有10Mbit/s,而且还是半双工的。

  • 通过划分vlan,可以提高网络安全性。

二.数据在三层交换机或路由器中的转发原理

  • 在二层交换机中转发的是数据帧(frame)。

  • 采用三层功能进行数据转发的的三层交换机和路由器中转发的是数据包(packet)。77034a4e13614931b240551fae4d4ae1.pngc26f0992cb4749b4b8742b330d6f315f.png

交换机的转发(二层转发)速率要比路由器(三层转发)快。交换机是通过硬件(MAC地址表)进行转发,而路由器器三层转发需要计算路由表,这更消耗资源。

国际互联网=A国国家内网(国家局域网)+B国国家内网(国家局域网)+.......+n国国家内网(国家局域网)构成。

对于国际互联网来说,任意一个国家的内网,都可以称作局域网。

国家内网=A省省域网+B省省域网+......+n省省域网

对于国家互联网来说,某省的省域网可以说就是一个大的局域网(LAN)。

广西省省域网=南宁城域网+柳州城域网+......+XX城域网。

这样一级级往下,无数个局域网构成了国际互联网(Internet)。

由于每一个设备都有一个MAC地址,MAC地址是全球唯一的,MAC地址是48位的二进制构成,MAC地址由70万亿个,因此在网互联网上不能直接的仅仅通过MAC地址寻目标主机,得用其它方式代替。MAC地址只适合与小型局域网中。大型网络就需要用到IP地址。

在设计Internet的时候,就考虑到大范围内的设备的互联问题,因此设计了IP地址,IP地址的一个特性是,它可以做路由汇聚,这样路由器中的路由条目就可以得到控制,举个例子,一些BGP路由器中其路由条目可以支持几十万条到数百万条。数百万条路由条目还是要比70万亿个MAC地址形成的MAC地址表要少。

三.VLAN配置项目举例

1.VLAN配置

1.1假设企业甲的情况及要求:

  甲企业现有3个部门,分别是综管部、行政部、财务部,公司每个人一台PC。

1.2网络管理员或乙方进行网络规划:

1.2.1.出口/核心层

  采购一台Cisco 2911路由器作为出口,并提供NAT转换,该路由器有两个千兆上联口,再采购HWIC-4ESW扩展卡作为下联各部门交换机,HWIC-4ESW扩展卡有4个Fast Ethernet Port(百兆口)。

1.2.2. 汇聚层

  使用一台cisco 3560 24口交换机作为汇聚层。

1.2.3. 接入层

采用3台cisco 3560 24口交换机,综管部、行政部、财务部各一台。

交换机、路由器、服务器设备网关:192.168.10.1/24, vlan 10

综管部网关:192.168.20.1/24,vlan 20

行政部网关:192.168.30.1/24, vlan 30

财务部网关:192.168.40.1/24, vlan 40

序号使用部门网段网关可用IP地址范围设备
1中心机房192.168.10.0/24192.168.10.1192.168.10.2-192.168.10.254Cisco2911
2综管部192.168.20.0/24192.168.20.1192.168.20.2-192.168.20.254Cisco 3560
3行政部192.168.30.0/24192.168.30.1192.168.30.2-192.168.30.254Cisco3560
4财务部192.168.40.0/24192.168.40.1192.168.40.2-192.168.40.254Cisco3560

1.2.4. 各设备间端口连接情况

中心机房汇聚交换机fa0/1 综管部交换机fa0/24
中心机房汇聚交换机fa0/2 行政部交换机fa0/24
中心机房汇聚交换机fa0/3 财务部交换机fa0/24
中心机房汇聚交换机fa0/23 中心机房Cisco2911 gi0/0/0
中心机房汇聚交换机fa0/24 中心机房Cisco2911 gi0/0/1

1.3项目实施

1.3.1在cisco packet tracer上绘制拓扑

1d22f0a28d74485b918b4f808a8c7654.png

1.3.2.给PC配置静态IP地址(含子网掩码、网关)

  略

 

 1.3.3.给汇聚交换机CISCO 3560配置VLAN

  综管部的交换机只有他们自己部门用,而该部门又只有1个VLAN因此综管部交换机不需要配置VLAN。同理,行政部、财务部的cisco 3560交换机也不需要配置vlan。

 中心机房汇聚交换机Cisco 3560需要配置vlan。因为综管部、行政部、财务部的交换机都汇聚到该设备上,而每一个部门的VLAN都不相同,因此,需要在中心机房的cisco 3560交换机上配置vlan。

1.4.配置脚本

enable

configure terminal

no logging on

no ip domain-lookup

hostname HuiJuCisco3560

vlan 10

name SheBeiGuanLi

vlan 20

name ZongGuanBu

vlan 30

name XingZhengBu

vlan 40

name CaiWuBu

exit

interface fastEthernet 0/1

description ZGBSwitchFa0/24

switchport mode access

switchport access vlan 20

no shutdown

exit

interface fastEthernet 0/2

description XZBSwitchFa0/24

switchport mode access

switchport access vlan 30

no shutdown

exit

interface fastEthernet 0/3

description CWBSwitchFa0/24

switchport mode access

switchport access vlan 40

no shutdown

exit

exit

write

copy running-config startup-config

1.5.总结

  VLAN已经配置完毕,此时,部门内部的PC是可以相互ping通,但部门间不能ping通。因为VLAN是Virtual LAN=Virtual Local Area Network=虚拟本地局域网,在本实验中VLAN通过虚拟的方式把一台物理的汇聚交换机分为了4台虚拟交换机,而这4台虚拟的交换机并没有连接,因此不同部门的PC不能通讯。下一章我们会通过配置路由器,将这4台虚拟的交换机连在一起。

四.路由器实现VLAN间路由

1.  继续完成上一章 VLAN配置举例中的案例

(在上一章中 VLAN已经配置完了,不用修改)

1.1汇聚交换机上联口配置脚本

enable

configure terminal

no logging on

no ip domain-lookup

 

interface fastEthernet 0/24

switch trunk encapsulation dot1q

switchport mode trunk

switchport trunk allowed vlan 20,30

no shutdown

 

interface fastEthernet 0/23

switchport mode access

switchport access vlan 40

no shutdown

exit

 

write

copy running-config startup-config

1.2路由器配置脚本

enable

configure terminal

no logging on

no ip domain-lookup

hostname RouterCisco2911

 

interface gigabitEthernet 0/1

description ToHuijuCisco3560Fa0/24

no shutdown

interface gigabitEthernet 0/1.1

encapsulation dot1Q 20

ip address 192.168.20.1 255.255.255.0

interface gigabitEthernet 0/1.2

encapsulation dot1Q 30

ip address 192.168.30.1 255.255.255.0

exit

 

interface gigabitEthernet 0/2

description ToHuijuCisco3560Fa0/23

no shutdown

ip address 192.168.40.1 255.255.255.0

exit

 

end

write

copy running-config startup-config

2.最终拓补图

f9bd8f3e1d0d402d9c9fc53ebb24e4e5.png

3.故障分析

  检查后发现gigabitEthernet只能配置为三层接口,也就是使用gigabitEthernet的时候只能配ip地址,不能将其配置成二层的trunk口。

  现在路由器的gigabitEthernet0/1和汇聚交换机的gigabitEthernet 0/1互联,要想通,那么两个口都必须配置IP地址。但这不是本实验的目的,为了要实现通讯,路由器和交换机互联时,路由器继续使用gigabitEthernet口,而交换机使用FastEthernet口,FastEthernet口配置为trunk口,trunk口允许多个vlan 通过。

五.三层交换机实现VLAN间路由

1. 三层交换机实现VLAN间路由-拓扑图

9ec98452307241d5b66d1e300ee909ea.png

2. 三层交换机实现VLAN间路由-配置脚本

本案例中,只需要在汇聚交换机(顶部中心机房SW)上进行配置

enable

configure terminal

no logging on

no ip domain-lookup

hostname HuiJuCisco3560

 

vlan 20

name ZongGuanBu

vlan 30

name XingZhengBu

vlan 40

name CaiWuBu

exit

 

interface vlan 20

ip address 192.168.20.1 255.255.255.0

description ZongGuanBu

no shutdown

exit

 

interface vlan 30

ip address 192.168.30.1 255.255.255.0

description XingZhengBu

no shutdown

exit

 

interface vlan 40

ip address 192.168.50.1 255.255.255.0

description CaiWuBu

no shutdown

exit

 

interface fastEthernet 0/1

description ToZGBSwitchFa0/24

switchport mode access

switchport access vlan 20

no shutdown

exit

 

interface fastEthernet 0/2

description ToXZBSwitchFa0/24

switchport mode access

switchport access vlan 30

no shutdown

exit

 

interface fastEthernet 0/3

description ToCWBSwitchFa0/24

switchport mode access

switchport access vlan 40

no shutdown

exit

 

ip routing

 

exit

write

copy running-config startup-config

六.vlan中继(Trunk)&VLAN间路由

1. 拓扑

c3b174bbeec94fdd83e75f75bbe05e11.png

edec2adad25244fe943488c920cbd3bf.png

2.配置脚本

 市场部SW不需要配置

中心机房SW和3楼SW配置脚本

 

中心机房SW

enable

configure terminal

no logging on

no ip domain-lookup

hostname ZhongXinJiFangSW

 

vlan 20

name ZongHeGuanliBu

vlan 30

name FaWuBu

vlan 50

name CaiWuBu

vlan 60

name ShiChangBu

exit

 

interface vlan 20

ip address 192.168.20.1 255.255.255.0

description ZongHeGuanliBu

no shutdown

exit

 

interface vlan 30

ip address 192.168.30.1 255.255.255.0

description FaWuBu

no shutdown

exit

 

interface vlan 50

ip address 192.168.50.1 255.255.255.0

description CaiWuBu

no shutdown

exit

 

interface vlan 60

ip address 192.168.60.1 255.255.255.0

description ShiChangBu

no shutdown

exit

 

 

interface fastEthernet 0/1

description To3LouSWFa0/24

switchport trunk encapsulation dot1q

switchport mode trunk

switchport trunk allow vlan 20,30,50

no shutdown

exit

 

interface fastEthernet 0/2

description ToSCBSwitchFa0/24

switchport mode access

switchport access vlan 60

no shutdown

exit

 

ip routing

 

exit

write

copy running-config startup-config

 

 

 

3楼SW

enable

configure terminal

no logging on

no ip domain-lookup

hostname 3LouSW

 

vlan 20

name ZongHeGuanliBu

vlan 30

name FaWuBu

vlan 50

name CaiWuBu

exit

 

interface fastEthernet 0/1

description ZGBVlan20

switchport mode access

switchport access vlan 20

no shutdown

exit

 

interface fastEthernet 0/6

description ZGBVlan20

switchport mode access

switchport access vlan 20

no shutdown

exit

 

interface fastEthernet 0/7

description FaWuBuVlan30

switchport mode access

switchport access vlan 30

no shutdown

exit

 

interface fastEthernet 0/10

description FaWuBuVlan30

switchport mode access

switchport access vlan 30

no shutdown

exit

 

interface fastEthernet 0/11

description CaiWuBuVlan50

switchport mode access

switchport access vlan 50

no shutdown

exit

 

interface fastEthernet 0/15

description CaiWuBuVlan50

switchport mode access

switchport access vlan 50

no shutdown

exit

 

interface fastEthernet 0/24

description ToZhongXinJiFangSWFa0/24

switchport mode trunk

switchport trunk encapsulation dot1q

switchport trunk allow vlan 20,30,50

no shutdown

exit

 

exit

write

copy running-config startup-config

3.结果验证

pc间互ping

 

  • 10
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

peng_2580

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值