一, 实验要求:
交换机 f0/1 只能连接两台 pc, 多了就自动断线
配置命令
- Switch(config)#int fa0/1
- Switch(config-if)#switchport mode access // 使用 acces 模式
- Switch(config-if)#switchport port-security // 先开启安全
- Switch(config-if)#switchport port-security maximum 2 // 设置最大连接数为 2
- Switch(config-if)#switchport port-security violation shutdown // 超过连接数就断线
二, 验证
新加一台 PC 后, 没有进行通信, 交换机的 Mac 表就不会有新加的 PC 的信息, 也就是不知道有加计算机, 用右边 ping 左边, 还能 ping 通, 当 ping 第三台 PC 是, 交换机会发现自己多加了一个 Mac 表, 就会自动断线, 交换机和集线器的线会变红
三, 重启交换机
拆掉多余的 PC, 重启交换机, 可以恢复通信
- Switch(config)#int fa0/1
- Switch(config-if)#shut
- %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down
- %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
- Switch(config-if)#no shut
- %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
- %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
- Switch(config-if)#
来源: http://www.bubuko.com/infodetail-3169095.html