【思科】某小型企业网组网案例-三层交换机划多VLAN与路由器相连,ACL控制访问权限

本文详细介绍了如何在企业网络中使用H3C ER系列路由器和Cisco C3560交换机,通过划分VLAN10、VLAN20和VLAN30,并设置默认路由、DHCP和访问控制列表,实现VLAN间隔离与远程管理。关键步骤包括配置交换机VLAN、路由、DHCP和防火墙策略,确保PC间的通信及管理权限的控制。
摘要由CSDN通过智能技术生成

一、背景需求:

在一些带机量大的场景中,为避免网络中的广播风暴影响网络质量,某公司希望将内网进行广播域隔离,划分3个VLAN,同时需要 VLAN10 和 VLAN20 实现内网间互访,VLAN30 和 其他两个隔离,网管员能够远程管理内网设备。

这里,我会用GNS3复原当时的情形。

现有设备如下:
H3C ER系列路由器一台,
cisco C3560交换机一台,

可选方案:
1、采用单臂路由模式,vlan在三层交换机上划分,网关,DHCP均由路由器完成。(不推荐使用)这里不做演示,如有需求可看我另一篇文档:

2、将网关、dhcp地址池,架设在三层,三层交换机和路由器之间采用静态路由转发数据。ACL实现VLAN间隔离。

这里采用第二种方案。将网关、dhcp均由核心交换机完成。采用默认路由将流量转发给路由器。

二、网络拓扑

在这里插入图片描述

网络地址规划:

VLAN10: 10.0.10.0 /24 ,网关: 10.0.10.254
PC1:10.0.10.1 /24
PC2:10.0.10.2 /24

VLAN20: 10.0.20.0 /24,网关: 10.0.20.254
PC3:10.0.20.1 /24
PC4:10.0.20.2 /24

VLAN30: 10.0.30.0 /24,网关: 10.0.30.254
PC5:10.0.30.1 /24
PC6:10.0.30.2 /24

路由器 f0/0:172.16.2.1 /24
交换机 f1/15:172.16.2.2 /24

三、配置过程

1、若是旧机器,需要清空交换机原有配置。(如是全新设备,可以跳过此步骤)

这里不做演示,需要过程请看我另一篇文档:如何将思科交换机恢复出产设置?

2、初始化机器之后,重启交换机。

在路由器和交换机第一次启动或者刚初始化后启动会直接进入到会话模式,按Ctrl+c 命令跳过会话模式进入手工配置模式(命令模式)。另一种就是在特权命令状态使用Setup 命令也可通过交互方式对网络设备进行问话式配置。

         --- System Configuration Dialog ---

Enable secret warning
Would you like to enter the initial configuration dialog? [yes/no]: yes

At any point you may enter a question mark '?' for help.   // 任何时候可以打?取得帮助
Use ctrl-c to abort configuration dialog at any prompt.    // 按Ctrl-C 可以取消并退出
Default settings are in square brackets '[]'.              // 默认参数在[] 中

Basic management setup configures only enough connectivity
for management of the system, extended setup will ask you
to configure each interface on the system

Would you like to enter basic management setup? [yes/no]: yes   // 继续交互配置吗
Configuring global parameters:

Enter host name [Switch]: Cy10th3560     // 输入交换机名称

The enable secret is a password used to protect access to
privileged EXEC and configuration modes. This password, after
entered, becomes encrypted in the configuration.
Enter enable secret: test     // 输入EXEC 模式密码

The enable password is used when you do not specify an
enable secret password, with some older software versions, and
some boot images.
Enter enable password: test     // 输入enable 模式密码

The virtual terminal password is used to protect
access to the router over a network interface.
Enter virtual terminal password:  test    // 输入虚拟控制端登录密码
Configure SNMP Network Management? [no]: no    // 是否配置SNMP 管理
 
Enter interface name used to connect to the management network from the above interface summary:vlan1  
// 输入用户网络管理的接口
Configuring interface Vlan1:
Configure IP on this interface? [no]: yes // 是否为接口配置IP 地址
IP address for this interface: 172.16.1.1
Subnet mask for this interface [255.255.255.0] : 255.255.255.0
Class C network is 172.16.0.0, 24 subnet bits; mask is /24
Would you like to enable as a cluster command switch? [yes/no]: no //是使用集群模式
[0] Go to the IOS command prompt without saving this config.
[1] Return back to the setup without saving this config.
[2] Save this configuration to nvram and exit.
Enter your selection [2]: 2 // 保存配置

以上是设置了交换机对的管理VLAN1的管理VLAN:VLAN1的IP地址:172.16.1.1,没有上述步骤也可自行配置。如下:

C3560#conf t
C3560(config)#int vlan1
C3560(config-if)#ip add 172.16.1.1 255.255.255.0
C3560(config-if)#no shutdown 


C3560(config)#line vty 0 4
C3560(config-line)#password test
C3560(config-line)#login
C3560(config)#enable password test
C3560(config)#line console 0
C3560(config-line)#password test

C3560(config)#ip default-gateway 172.16.1.254 \\设置交换机的默认网关(全局配置模式下)

二层交换机配置了管理IP地址后,在管理地址的同网段内,设备可通过管理IP地址来远程访问交换机。
但若要跨网段去登录连接到另一个网段的二层交换机,则必须给二层交换机配置指定默认网关,双方的二层交换机都要配置指定默认网关地址。
企业局域网中一般会用到多个VLAN和网段,一般不同地址段的路由都是在上层设备上做通了的,而一般二层交换机只要将网关指向汇聚/核心层的三层设备的网管IP就可以了。
3、下面正式开始配置:

R1:

R1#conf t
R1(config)#int f0/0 
R1(config-if)#ip add 172.16.2.1 255.255.255.0
R1(config-if)#no shut

R1(config)#ip route 10.0.10.0 255.255.255.0 172.16.2.2   \\去往VLAN的默认路由
R1(config)#ip route 10.0.20.0 255.255.255.0 172.16.2.2
R1(config)#ip route 10.0.30.0 255.255.255.0 172.16.2.2

SW:

C3560#vlan database 
C3560(vlan)#vlan 10 name \\vlan10_PC
C3560(vlan)#vlan 20 name \\vlan20_shebei
C3560(vlan)#vlan 30 name \\vlan30_AP

C3560(config)#int vlan 10
C3560(config-if)#ip add 10.0.10.254 255.255.255.0
C3560(config-if)#no shutdown 
C3560(config-if)#int vlan 20
C3560(config-if)#ip add 10.0.20.254 255.255.255.0
C3560(config-if)#no shutdown 
C3560(config-if)#int vlan 30                     
C3560(config-if)#ip add 10.0.30.254 255.255.255.0
C3560(config-if)#no shutdown 

C3560(config-if)#int f1/15
C3560(config-if)#no switchport     \\转换为3层接口
C3560(config-if)#ip add 172.16.2.2 255.255.255.0
C3560(config-if)#ip route 0.0.0.0 0.0.0.0 172.16.2.1  \\指向路由器的默认路由
C3560(config)#ip routing   \\开启IPV4的路由功能

C3560(config)#int f1/1     //真机可以使用范围配置更快,模拟器好像不支持  int f1/1-2
C3560(config-if)#switchport access vlan 10  
C3560(config-if)#int f1/2
C3560(config-if)#switchport access vlan 10
C3560(config-if)#int f1/3
C3560(config-if)#switchport access vlan 20
C3560(config-if)#int f1/4
C3560(config-if)#switchport access vlan 20
C3560(config-if)#int f1/5
C3560(config-if)#switchport access vlan 30
C3560(config-if)#int f1/
C3560(config-if)#switchport access vlan 30

C3560(config-if)#do show vlan-switch  //查看vlan信息,真机中:do show vlan brief

在这里插入图片描述
可以看到,接口都以划入VLAN中了。

4、接下来配置DHCP地址池、网关、DNS、保留地址等。

SW:

C3560(dhcp-config)#ip dhcp pool vlan10  
C3560(dhcp-config)#network 10.0.10.0 /24
C3560(dhcp-config)#default-router 10.0.10.254
C3560(dhcp-config)#dns-server 8.8.8.8
C3560(config)#ip dhcp excluded-address 10.0.10.200 10.0.10.254

C3560(dhcp-config)#ip dhcp pool vlan20 
C3560(dhcp-config)#network 10.0.20.0 /24
C3560(dhcp-config)#default-router 10.0.20.254
C3560(dhcp-config)#dns-server 8.8.8.8
C3560(config)#ip dhcp excluded-address 10.0.20.200 10.0.20.254

C3560(dhcp-config)#ip dhcp pool vlan30 
C3560(dhcp-config)#network 10.0.30.0 /24
C3560(dhcp-config)#default-router 10.0.30.254
C3560(dhcp-config)#dns-server 8.8.8.8
C3560(config)#ip dhcp excluded-address 10.0.30.200 10.0.30.254
5、因为是用路由器模拟的PC,所以每个PC都需要关闭路由功能。这里只演示PC1,其余自行完成。
PC1#conf t
PC1(config)#ip routing

PC2#
……
PC3#
……

在这里插入图片描述

6、设置PC在接口下,通过dhcp自动获取ip地址
PC1(config)#ip address
PC1(config)#int f0/0        
PC1(config-if)#ip address dhcp 
PC1(config-if)#no shutdown


PC2(config)#ip address
PC2(config)#int f0/0        
PC2(config-if)#ip address dhcp 
PC2(config-if)#no shutdown
………………
自行配置其余PC

检查PC是否获取到地址,发现接口状态已经up,且获得了dhcp分配的地址

在这里插入图片描述
测试VLAN下的所有主机能否正常通信。
在这里插入图片描述

7、最后就需要隔离VLAN30了,使其不能与VLAN10和VLAN20通信。
C3560(config)#access-list 100 deny ip 10.0.30.0 0.0.0.255 10.0.10.0 0.0.0.255
C3560(config)#access-list 100 deny ip 10.0.30.0 0.0.0.255 10.0.20.0 0.0.0.255
C3560(config)#access-list 100 permit ip any any
C3560(config)#int vlan 30
C3560(config-if)#ip access-group 100
C3560(config-if)#ip access-group 100 in

C3560(config)#access-list 101 deny ip 10.0.20.0 0.0.0.255 10.0.30.0 0.0.0.255
C3560(config)#access-list 101 permit ip any any
C3560(config)#int vlan 20
C3560(config-if)#ip access-group 101
C3560(config-if)#ip access-group 101 in

C3560(config)#access-list 102 deny ip 10.0.10.0 0.0.0.255 10.0.30.0 0.0.0.255
C3560(config)#access-list 102 permit ip any any
C3560(config)#int vlan 10
C3560(config-if)#ip access-group 102
C3560(config-if)#ip access-group 102 in
8、测试VLAN10与VLAN30的通信

在这里插入图片描述
在这里插入图片描述
可以看到vlan10与vlan30互相不能通信

9、下面测试VLAN20与VLAN30之间的通信

在这里插入图片描述
在这里插入图片描述

10、最后,查看VLAN10与VLAN20之间的通信。

在这里插入图片描述
在这里插入图片描述
结论:VLAN10与VALN20可以通信,与VLAN30不能通信!!

拓扑图下载:gns3安装包+路由器镜像+拓扑图
(使用GNS3打开,路由器为:镜像C3660路由器)

目录: 01 H3C S5500与思科3750对接二层链路聚合的典型组网配置案例 02 H3C S5500与思科2960对接二层链路聚合的典型组网配置案例 03 H3C S6800与思科3560对接二层链路聚合典型组网配置案例 04 H3C S6800与思科2960对接二层链路聚合典型组网配置案例 05 H3C S5820与思科2960对接二层链路聚合典型组网配置案例 06 S12508与思科3560对接NTP典型组网配置案例 07 S6520与思科3560对接NTP典型组网配置案例 08 S5820与思科3560对接NTP典型组网配置案例 09 S6800与思科3560对接NTP典型组网配置案例 10 S12508与思科2960对接NTP典型组网配置案例 11 S5500与思科3750对接EBGP典型组网配置案例 12 S6520与思科3925对接NTP典型组网配置案例 13 S5820与思科3925对接NTP典型组网配置案例 14 S6800与思科3925对接NTP典型组网配置案例 15 S6520与思科3750对接NTP典型组网配置案例 16 S6520与思科2960对接NTP典型组网配置案例 17 S5820与思科3750对接NTP典型组网配置案例 18 S5820与思科2960对接NTP典型组网配置案例 19 S6800与思科2960对接NTP典型组网配置案例 20 S6800与思科3750对接NTP典型组网配置案例 21 S5500与思科3750对接RIP典型组网配置案例 22 S5500与思科3750对接IBGP典型组网配置案例 23 H3C ME5000和思科语音系统融合典型配置 24 S6800与思科2960对接PVST典型组网配置案例 25 S6800与思科3560对接PVST典型组网配置案例 26 H3C设备与思科做BFD配置案例 27 S5820与思科2960对接PVST典型组网配置案例 28 S12508与思科3750对接PVST典型组网配置案例 29 S12508与思科2960对接PVST典型组网配置案例 30 S5500与思科3750对接多VPN实例OSPF典型组网配置案例 31 思科语音关3662语音命令对应的MSR翻译 32 MSR系列路由器FR IPv6和思科互通典型配置 33 H3C VG1040使用SIPLINE方式与思科CallManager5.0.4互通典型配置 34 S5820-52QF-U与思科N5548 FC(NPV方式)互通配置 35 V7防火墙和思科ACS 实现radius认证 36 S9500E配置远程镜像导致网络中断问题解决方法 37 iMC设备定义功能介绍 38 MSR路由器与Cisco36 72系列路由器MPLS VPN跨标签对接案例 39 CE3000-EI与Cisco 4948 PIM-SSM对接配置案例 40 S12500&S9500E&CR16000 CoPP应用案例 41 配合EIA进行iNode批量升级的典型配置 42 H3C XE2000和AVAYA S85对接典型配置案例 43 CAMS设备无关功能特性配置
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值