0
点赞
收藏
分享

微信扫一扫

Redis-底层数据结构

编程练习生J 04-09 17:30 阅读 2

1、实验目的

通过本实验可以掌握:

  1. 交换机管理地址配置及接口配置。
  2. 查看交换机的MAC地址表。
  3. 配置静态端口安全、动态端口安全和粘滞端口安全的方法。

2、实验拓扑

配置交换机端口安全的实验拓扑如图所示。

                                                配置交换机端口安全的实验拓扑

3、实验步骤

(1)交换机基本配置

S1(config)#interface vlan 1
//配置交换机交换虚拟接口,用于交换机远程管理
S1(config-if)#ip address 172.16.1.100 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)#exit
S1(config)#ip default-gateway 172.16.1.1
//配置交换机默认网关
S1(config)#interface fastEthernet 0/11
S1(config-if)#duplex auto            //配置以太网接口双工模式,默认时双工状态是auto
S1(config-if)#speed auto             //配置以太网接口的速率,默认时速率是自适应即auto
S1(config-if)#mdix auto              //配置auito-MDIX
S1(config-if)#exit
S1(config)#interface range f0/5-9,f0/13-24,g0/1,g0/2
S1(config-if-range)#shutdown
//以上2行批量禁用未使用的端口

【技术要点】

在以太网接口上使用auto-MDIX(自动介质相关接口交叉)功能可以解决直通和交叉乡缆的自适应问题,该功能默认启用,但是接口的速率和双工模式必须是 auto,否则该功能生效

(2)查看交换机的MAC地址表

        首先在计算机 PCI、PC2和 Serverl上配置正确的IP地址,并且用 ipconfig /all命令查看各台计算机网卡的MAC地址,记下来,然后在计算机PCl上分别ping PC2和 Serverl,进行连通性测试,接下来查看交换机MAC地址表。

S1#show mac-address-table 
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
 
   1    0001.c95d.d021    DYNAMIC     Fa0/11  //计算机Server1网卡的MAC地址
   1    000c.cfda.ae96    DYNAMIC     Fa0/10  //计算机PC0网卡的MAC地址
   1    0060.3e28.8723    DYNAMIC     Fa0/12  //计算机PC1网卡的MAC地址
S1#

        以上显示了交换机S1上的MAC地址表,其中 vlan字段表示交换机端口所在的VLAN;Mac Address字段表示与端口相连的设备的MAC地址:Type字段表示填充MAC地址记录的类型,DYNAMIC表示MAC记录是交换机动态学习的,STATIC表示MAC记录是静态配置或系统保留的:Ports字段表示设备连接的交换机端口。

1、可以通过下面命令查看交换机动态学习的MAC地址表的超时时间或老化时间,默认为300秒。

S1#show mac address-table aging-time 
Global Aging Time:  300
Vlan    Aging Time
----    ----------
S1#

2、可以通过下面命令修改VLAN 1的 MAC地址表的超时时间为120秒。

S1(config)#mac address-table aging-time 120 vlan 1

3、可以通过下面命令配置静态填充交换机MAC地址表。

S1(config)#mac address-table static 0001.c95d.d021 vlan 1 interface fastEthernet 0/11

(3)配置交换机静态端口安全

        在交换机S1上配置端口安全,Fa0/10配置动态端口安全;FaO/11配置静态端口安全;FaO/12配置粘滞端口安全。因为交换机FaO/11端口连接Serverl服务器,服务器不会轻易更换,适合配置静态端口安全。

S1(config)#interface fastEthernet 0/11
S1(config-if)#switchport mode access 
//端口配置为接入模式,配置端口安全的端口不能是动态协商模式
S1(config-if)#switchport port-security     //打开交换机的端口安全功能
S1(config-if)#switchport port-security maximum 1
//配置端口允许接入设备的MAC地址最大数目,默认是1,即只允许一个设备接入
S1(config-if)#switchport port-security mac-address 0001.c95d.d021
//配置端口允许接入计算机的MAC地址
S1(config-if)#switchport port-security violation shutdown 
//配置端口安全违规惩罚模式,这也是默认的惩罚行为
S1(config-if)#exit
S1(config)#errdisable recovery cause psecure-violation 
//允许交换机自动恢复因端口安全而关闭的端口
S1(config)#errdisable recovery interval 30
//配置交换机自动恢复端口的周期,时间间隔单位为秒

此时,从Server1 上 ping交换机的管理地址,可以 ping通。

(4)验证交换机静态端口安全

S1#show mac-address-table 
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
 
   1    0001.c95d.d021    STATIC      Fa0/11  //Server1的网卡MAC地址静态加入MAC地址表

在S1端口Fa0/11接入另一台计算机,模拟非法服务器接入,交换机显示的信息如下:

*Apr  3 07:43:43.080: %PM-4-ERR_DISABLE: psecure-violation error detected on Et0/1, putting Et0/1 in err-disable state
S1#
*Apr  3 07:43:43.080: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address aabb.cc00.0200 on port Ethernet0/1.
*Apr  3 07:43:44.084: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down
S1#
*Apr  3 07:43:45.080: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to down

  以上输出显示了交换机启用端口安全的端口、允许连接最大MAC地址的数量、目前连接MAC地址的数量、惩罚计数和惩罚模式。

S1#show port-security interface fastEthernet 0/11
Port Security              : Disabled
Port Status                : Secure-down
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 1
Configured MAC Addresses   : 1
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 0000.0000.0000:0
Security Violation Count   : 0

        移除非法设备后,重新连接Serverl到该接口,由于已经配置了端口 errdisable自动恢复所以交换机显示自动恢复的消息如下:

【提示】

如果没有配置由于端口安全惩罚而关闭的端口自动恢复,则需要管理员在交换机的Fa0/11端口下执行 shutdown和 no shutdown命令来重新开启该端口,如果还是非法主机尝试连接,则继续惩罚,端口再次变为err-disable状态。

(5)配置交换机动态端口安全

        很多公司员工使用笔记本电脑办公,而且位置不固定(如会议室),因此适合配置动态端口安全,限制每个端口只能连接1台计算机,避免用户私自连接AP或者其他的交换机而带来安全隐患。交换机 Fa0/10端口连接计算机不固定,适合配置动态端口安全,安全惩罚模式为restrict。

S1(config)#interface fastEthernet 0/10
S1(config-if)#switchport mode access 
S1(config-if)#switchport port-security 
S1(config-if)#switchport port-security maximum 1
S1(config-if)#switchport port-security violation restrict 
S1(config-if)#exit

(6)验证动态端口安全

S1#show port-security interface fastEthernet 0/10
Port Security              : Enabled
Port Status                : Secure-up
Violation Mode             : Restrict
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 0
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 0000.0000.0000:0
Security Violation Count   : 0

(7)配置粘滞端口安全

        很多公司员工使用台式电脑办公,位置固定,如果配置静态端口安全,需要网管员到员工的计算机上查看MAC地址,工作量巨大。为了减轻工作量,适合配置粘滞端口安全,限制每个端口只能连接Ⅰ台计算机,避免其他用户的计算机使用交换机端口而带来安全隐患。交换机FaO/12端口连接计算机位置固定,适合配置粘滞端口安全,安全惩罚模式为restrict。

S1(config)#interface fastEthernet 0/12
S1(config-if)#switchport mode access 
S1(config-if)#switchport port-security 
S1(config-if)#switchport port-security maximum 1
S1(config-if)#switchport port-security violation restrict 
S1(config-if)#switchport port-security mac-address sticky
//配置交换机端口自动粘滞访问该端口计算机的 MAC地址
S1(config-if)#exit

(8)验证粘滞端口安全

从PC2 上 ping交换机172.16.1.100,然后验证。

S1#show port-security interface fastEthernet 0/12
Port Security              : Enabled
Port Status                : Secure-up
Violation Mode             : Restrict
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 1
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 1
Last Source Address:Vlan   : 0060.3E28.8723:1
Security Violation Count   : 0

至此实验结束。

举报

相关推荐

0 条评论