ACL是网络安全的配置和STP

1.ACL概述

随着大规模开放式网络的开发,网络面临的威胁也就越来越多。网络安全问题成为网络管理员必须面对的问题。

一方面,为了业务的发展,必须允许对网络资源的开放访问权限;

另一方面,又必须确保数据和资源的尽可能安全。网络安全采用的技术很多,而通过ACL可以对数据流进行过滤,是实现基本的网络安全手段之一。

本章只讨论基于IPv4和IPv6的ACL功能、工作原理、使用原则、标准ACL和扩展ACL 以及IPv4 ACL和 IPv6 ACL的配置。

访问控制列表(Access Control List,ACL)是控制网络访问的一种有利的工具。

所谓ACL就是一种路由器配置脚本,它根据从数据包包头中发现的信息(源地址、目的地址、源端口、目的端口和协议等)来控制路由器应该允许还是拒绝数据包通过,从而达到访问控制的目的。

ACL是Cisco IOS 软件中最常用的功能之一,其应用非常广泛,可以实现如下典型的功能:

①限制网络流量以提高网络性能。

②提供基本的网络访问安全。

③控制路由更新的内容。

④在QoS实施中对数据包进行分类。

⑤定义IPSec VPN的感兴趣流量。

⑥定义策略路由的匹配策略。

2.ACL-1综合实验-EVE-NG

2.1 某车企内网使用的ACL

2.2 利用在《思科网络技术(上)》学到的知识实现所有设备互通

2.3 配置过程

2.4 验证

VPC1 ping 通 VPC2

VPC1 ping 通 VPC3

VPC1 ping 通 FTP-Server

VPC2 ping通 VPC3

VPC2 ping通 FTP-Server

VPC3 ping通 FTP-Server

3. ACL-1综合实验-cisco packet tracer

3.1 拓扑图

3.2 脚本

4.ACL-2综合实验

4.1 实验拓扑

4.2 配置脚本-实现互通

4.3 配置脚本-ACL控制

enable

configure terminal

no ip domain-lookup

no logging on

hostname S1

vlan 80

name SheBeiGuanLi

vlan 105

name SheJiZhongXin

vlan 107

name GongChengZhongXin

vlan 109

name CheShiZhongXin

vlan 111

name YanJiuYuan

exit

interface vlan 80

description SheBeiGuanLi

ip address 172.16.80.1 255.255.255.0

no shutdown

exit

interface vlan 105

description SheJiZhongXin

ip address 172.16.105.1 255.255.255.0

no shutdown

exit

interface vlan 107

description GongChengZhongXin

ip address 172.16.107.1 255.255.255.0

no shutdown

exit

interface vlan 109

description CheShiZhongXin

ip address 172.16.109.1 255.255.255.0

no shutdown

exit

interface vlan 111

description YanJiuYuanFTP

ip address 172.16.111.1 255.255.255.0

no shutdown

exit

interface gigabitethernet 0/0

description SheJiZhongXin

switch trunk encapsulation dot1q  

switchport mode trunk

switchport trunk allowed vlan 80,105

exit

interface gigabitethernet 0/1

description GongChengZhongXin

switch trunk encapsulation dot1q

switchport mode trunk

switchport trunk allowed vlan 80,107

exit

interface gigabitethernet 0/2

description CheShiZhongXin

switch trunk encapsulation dot1q

switchport mode trunk

switchport trunk allowed vlan 80,109

exit

interface gigabitethernet 1/1

description YanJiuYuan

switchport mode access

switchport access vlan 111

exit

enable password 7 adminconsole

line console 0

logging synchronous

exec-timeout 3 0

exit

username admin password admin123

ip ssh version 2

ip domain-name lz.cn

crypto key generate rsa

1024

line vty 0 4

login local

transport input ssh

access-list 110 remark Only_Network_Admin_Access80

access-list 110 permit ip 172.16.80.0 0.0.0.255 172.16.80.0 0.0.0.255

access-list 110 deny ip any any

interface gigabitethernet 0/0

ip access-group 110 in

interface gigabitethernet 0/1

ip access-group 110 in

interface gigabitethernet 0/2

ip access-group 110 in

interface gigabitethernet 1/1

ip access-group 110 in

end

write

copy running-config startup-config

5.exec-timeout

exec-timeout 0 0是Cisco路由器配置命令,用于设置用户会话的超时时间。

具体来说,exec-timeout 0 0表示禁用了用户会话的超时功能。这意味着用户在登录后可以无限期地保持连接,直到手动断开连接或系统重启。

这个命令通常用于需要长时间保持连接的场景,例如远程维护、网络监控等。通过禁用超时功能,可以避免因超时而意外断开连接,从而确保用户能够持续访问设备。

需要注意的是,禁用超时功能可能会增加安全风险,因为如果用户长时间保持连接,可能会被恶意攻击者利用。因此,在实际应用中,应根据实际需求和安全性要求来合理设置超时时间。

详见:https://blog.csdn.net/utopiaZH7/article/details/104004823

6.logging synchronous

logging synchronous的主要用途是同步输出日志消息,确保它们不会影响正在进行的配置操作。

在网络设备,尤其是Cisco路由器的配置中,当启用了logging synchronous时,它会将日志消息和调试输出与控制台、辅助(Aux)和虚拟终端(VTY)线路上的命令输入同步。这样做的好处是,当你正在配置设备时,突然出现的日志信息不会中断或分隔你正在输入的命令,从而避免了命令输入错误。

具体来说,logging synchronous的作用包括:

  • 防止命令输入中断:在没有启用logging synchronous的情况下,如果系统自动产生日志,可能会在你输入命令的过程中出现,导致命令被意外中断,影响配置的准确性。

  • 提高配置效率:通过同步日志输出,可以减少因日志信息导致的配置错误,从而提高配置效率和准确性。

需要注意的是,在某些情况下,如进行故障排查时,可能需要关闭logging synchronous以便更快地查看实时日志信息。因此,是否启用logging synchronous应根据实际需求和配置环境来决定。

enable password 7 admin

//7表示show running时不显示密码,这样可以确保安全。

line console 0

logging synchronous

exec-timeout 0 0

第1个0表示分钟,第2个0表示秒

7.STP

为了减少网络的故障时间,网络设计中经常会采用冗余拓扑,冗余是保持网络可靠性的关键设计。设备之间的多条物理链路能够提供冗余路径,当单个链路或端口发生故障时,网络可以继续运行,同时冗余链路可以增加网络容量,提供流量负载分担。为避免产生二层交换环路,可以通过STP来管理二层冗余,STP可以让具有冗余拓扑的网络在故障发生时自动调整网络的数据转发路径。Cisco的 PVST+可以解决STP 不能实现负载分担的问题。STP重新收敛时间较长,通常需要30~50秒,RSTP和MSTP可以解决该问题。本章主要介绍交换机上用于防止二层交换环路的STP、STP 防护RSTP 和 MSTP 技术的工作原理和配置,同时还讨论了交换机堆叠的问题。

7.1 配置Per VLAN STP ( PVST )

PVST,使用cisco专有的ISL中继协议,其它(如华为、H3C等)厂商的设备不支持。

PVST会为每一个VLAN构建一棵STP树,这样所有的口都会转发数据,实现负载分担不是负载均衡!

7.2 拓扑图 cisco packet tracer version  6.2.0.00

7.3 配置脚本

s1

enable

configure terminal

hostname S1

no ip domain-lookup

vlan 2

name vlan2

exit

interface range fastethernet 0/13-15

switchport trunk encapsulation dot1q

switchport trunk native vlan 99

switchport mode trunk

switchport nonegotiate

exit

interface range fastethernet 0/1-4

spanning-tree portfast

exit

spanning-tree mode pvst

spanning-tree vlan 1 priority 4096

spanning-tree vlan 2 priority 8192

spanning-tree vlan 1 root primary

spanning-tree vlan 2 root secondary

exit

write

copy running-config startup-config

s2

enable

configure terminal

hostname S2

no ip domain-lookup

vlan 2

name vlan2

exit

interface range fastethernet 0/13-15

switchport trunk encapsulation dot1q

switchport trunk native vlan 99

switchport mode trunk

switchport nonegotiate

exit

interface range fastethernet 0/1-4

spanning-tree portfast

exit

spanning-tree mode pvst

spanning-tree vlan 1 priority 8192

spanning-tree vlan 2 priority 4096

spanning-tree vlan 2 root primary

spanning-tree vlan 1 root secondary

exit

write

copy running-config startup-config

s3

enable

configure terminal

hostname S3

no ip domain-lookup

vlan 2

name vlan2

exit

interface range fastethernet 0/1-2

switchport trunk encapsulation dot1q

switchport trunk native vlan 99

switchport mode trunk

switchport nonegotiate

exit

spanning-tree mode pvst

exit

write

copy running-config startup-confie

7.3 配置注释

  1. 基本配置
  1. 用户名和密码(略)
  2. NTP(略)
  3. 登录方式配置Telnet、SSH(略)
  4. 给设备起名

enable

configure terminal

hostname S1

  1. 终止当前的DNS解析

no ip domain-lookup

  1. 配置vlan和端口
  1. S1配置vlan和端口

vlan 2

name vlan 2   //给vlan起名字

exit

interface range fastethernet 0/13-15    //配置fastethernet 0/13-15口,配置多个连续的端口。

switchport trunk encapsulation dot1q   //使用dot1q协议进行封装。

switchport trunk native vlan 99        //本地vlan 99

switchport mode trunk              //允许多个vlan通过

switchport nonegotiate  //fastethernet 0/13-15口端口自适应,自适应包含全双工,半双工,10m, 100m, 1000m

exit

interface range fastethernet 0/1-4

spanning-tree portfast    //portfast表示配置边缘端口,边缘端口一般都直接接PC、打印机等终端设备。

exit

  1. S2配置vlan和端口

vlan 2

name vlan2

exit

interface range fastethernet 0/13-15

switchport trunk encapsulation dot1q

switchport trunk native vlan 99

switchport mode trunk

switchport nonegotiate

exit

interface range fastethernet 0/1-4

spanning-tree portfast

exit

vlan 2

name vlan2

exit

interface range fastethernet 0/13-15

switchport trunk encapsulation dot1q

switchport trunk native vlan 99

switchport mode trunk

switchport nonegotiate

exit



interface range fastethernet 0/1-4

spanning-tree portfast

exit

8.MSTP介绍

在PVST中, 交换机为每个VLAN都构建一棵STP 树不个仅会为CPU 带来很大负载(特别是低端的交换),也会占用大量的带宽。MSTP (Multiple Spanning Tree Protocol)则可把多个VLAN 映射到一个STP实例上,每个实例都运行RSTP,从而减少了资源的浪费。

MSTP 中引入了实例(Instance)和域(Region)的概念。

实例就是多个 VLAN的一个集合,这种通过将多个VLAN捆绑到一个实例中的方法可以节省通信开销和资源占用率。

MSP各个实例拓扑的计算是独立的,通过控制这些实例上STP选举,就可以实现负载均衡。

域名(Configuration Name)、修订级别(Revision Level)、格式选择器(Configuration ldentifier Format Selector)、VLAN 与实例的映射关系组成。

其中域名、格式选择器和修订级别在BPDU数据包中都有相关字段,而 VLAN 与实例的映射关系在 BPDU 数据包中以 MDS 摘要信息(Configuration Digest)的形式表现,该摘要信息是根据映射关系计算得到的一个 16字节签名。只有上述4者都一样且相互连接的交换机机才认为在同一个MSTP域内。

默认时,所有的VLAN都映射到实例0上。

MSTP的实例0具有特殊作用,称为CIST( Common Internal and Spanning Tree),即公共和内部生成树。

其他的实例称为MSTI ( Multiple Spanning Tree instance ) ,即多生成树实例。

多生成树 (MST) 是从 Cisco 专用多实例生成树协议 (MISTP) 实施得到的 IEEE 标准。

下图显示了一种常用设计,其特征是接入交换机 A 带 1000 个 VLAN,这些 VLAN 冗余连接到两台分布式交换机 D1 和 D2。在此设置中,用户连接到交换机 A,而网络管理员通常根据偶数或奇数 VLAN 或认为适当的任何其他方案,寻求实现接入交换机上行链路的负载均衡。

具有1000个VLAN的接入交换机A冗余连接到交换机D1和D2

以下部分是对此设置使用各种类型的 STP 的案例示例:

在 Cisco 每 VLAN 生成树 (PVST+) 环境中,可以调整生成树参数,以便在每个上行链路中继上转发半数 VLAN。为轻松实现此目的,请选择网桥 D1 作为 VLAN 501 至 1000 的根网桥,选择网桥 D2 作为 VLAN 1 至 500 的根网桥。以下描述对于此配置是正确的:

  • 在此案例中,可以获得最佳负载均衡结果。

  • 为每个 VLAN 维护一个生成树实例,这意味着只为两个不同的最终逻辑拓扑维护 1000 个实例。这严重浪费了网络中所有交换机的 CPU 周期(除了每个实例发送各自的网桥协议数据单元 (BPDU) 所用的带宽以外)。

原始 IEEE 802.1q 标准不仅仅定义了中继,还定义了许多其他内容。此标准定义了通用生成树 (CST),后者仅假定整个桥接网络运行一个生成树实例,而不考虑 VLAN 的数量。如果将CST应用于下图拓扑,则结果类似于如下所示的图表:

Common Spanning Tree (CST) Applied to Network

应用于网络的通用生成树(CST)

在运行CST的网络中,以下陈述是正确的:

  • 无法进行负载均衡;一个上行链路需要阻塞所有VLAN。

  • CPU可备用;只需计算一个实例。

注意:思科实施增强了802.1q以支持一个PVST。此功能完全按照本示例中 PVST 的方式运行。Cisco 每 VLAN BPDU 通过纯 802.1q 网桥建立隧道。

MST (IEEE 802.1s) 组合了 PVST+ 和 802.1q 的最佳优势。其观点在于,可以将若干个 VLAN 映射到数量减少的生成树实例,因为大多数网络不需要太多逻辑拓扑。在第一个图描述的拓扑中,只有两种不同的最终逻辑拓扑,因此实际上只需要两个生成树实例。不需要运行 1000 个实例。如此图所示,如果将 1000 个 VLAN 中的一半映射到不同的生成树实例,则以下描述是正确的:

  • 由于一半的VLAN都连接到一个单独的实例,因此仍然可以实现所需的负载均衡方案。

  • 由于只计算两个实例,因此可以节省 CPU。

Map Half of the 1000 VLANs to a Different Spanning Tree Instance

将1000 VLAN的一半映射到不同的生成树实例

从技术观点来看,MST 是最佳解决方案。从最终用户的角度来看,迁移到MST的主要缺点是:

  • 该协议比常见的生成树更复杂,因此需要对员工进行额外培训


 

802.1Q—Only a single instance of STP is used for all VLANs. If there are 500 VLANs, only one instance of STP will be running. This is called the Common Spanning Tree (CST) and operates over the trunk’s native VLAN.

  • 13
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

M78NB666

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

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

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

打赏作者

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

抵扣说明:

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

余额充值