配置端口安全

1.实验拓扑

(1)配置S1的G0/0/1接口的端口安全。

S1的配置

<Huawei>sys

[Huawei]undo info-center enable

[Huawei]sysname S1

[S1]interface g0/0/1

[S1-GigabitEthernet0/0/1]port-security enable

[S1-GigabitEthernet0/0/1]port-security max-mac-num 2

[S1-GigabitEthernet0/0/1]port-security protect-action shutdown

使用PC1,PC2访问PC4,查看S1的MAC地址表。

PC1访问PC4:

PC>ping 10.1.1.4

Ping 10.1.1.4: 32 data bytes, Press Ctrl_C to break

From 10.1.1.4: bytes=32 seq=1 ttl=128 time=47 ms

From 10.1.1.4: bytes=32 seq=2 ttl=128 time=63 ms

From 10.1.1.4: bytes=32 seq=3 ttl=128 time=94 ms

From 10.1.1.4: bytes=32 seq=4 ttl=128 time=47 ms

From 10.1.1.4: bytes=32 seq=5 ttl=128 time=93 ms

--- 10.1.1.4 ping statistics ---

  5 packet(s) transmitted

  5 packet(s) received

  0.00% packet loss

  round-trip min/avg/max = 47/68/94 ms

PC2访问PC4:

PC>ping 10.1.1.4

Ping 10.1.1.4: 32 data bytes, Press Ctrl_C to break

From 10.1.1.4: bytes=32 seq=1 ttl=128 time=78 ms

From 10.1.1.4: bytes=32 seq=2 ttl=128 time=94 ms

From 10.1.1.4: bytes=32 seq=3 ttl=128 time=62 ms

From 10.1.1.4: bytes=32 seq=4 ttl=128 time=62 ms

From 10.1.1.4: bytes=32 seq=5 ttl=128 time=62 ms

--- 10.1.1.4 ping statistics ---

  5 packet(s) transmitted

  5 packet(s) received

  0.00% packet loss

  round-trip min/avg/max = 62/71/94 ms

查看S1的MAC地址表:

[S1]display mac-address

MAC address table of slot 0:

-------------------------------------------------------------------------------

MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  

               VSI/SI                                              MAC-Tunnel  

-------------------------------------------------------------------------------

5489-9803-6228 1           -      -      GE0/0/1         security  -           

5489-982b-2f53 1           -      -      GE0/0/1         security  -           

-------------------------------------------------------------------------------

Total matching items on slot 0 displayed = 2

MAC address table of slot 0:

-------------------------------------------------------------------------------

MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  

               VSI/SI                                              MAC-Tunnel  

-------------------------------------------------------------------------------

5489-98fd-042c 1           -      -      GE0/0/3         dynamic   0/-         

-------------------------------------------------------------------------------

Total matching items on slot 0 displayed = 1

使用非法用户访问PC4:

PC>ping 10.1.1.4

Ping 10.1.1.4: 32 data bytes, Press Ctrl_C to break

From 10.1.1.6: Destination host unreachable

From 10.1.1.6: Destination host unreachable

From 10.1.1.6: Destination host unreachable

From 10.1.1.6: Destination host unreachable

From 10.1.1.6: Destination host unreachable

--- 10.1.1.4 ping statistics ---

  5 packet(s) transmitted

  0 packet(s) received

  100.00% packet loss

(2)配置S1的G0/0/2接口为安全静态MAC地址。

[S1]i g00/0/2

[S1-GigabitEthernet0/0/2]port-security enable

[S1-GigabitEthernet0/0/2]port-security mac-address sticky

[S1-GigabitEthernet0/0/2]port-security mac-address sticky 5489-9827-7795 vlan 1

[S1-GigabitEthernet0/0/2]port-security max-mac-num 1

查看S1的MAC地址表:

[S1]display mac-address

MAC address table of slot 0:

-------------------------------------------------------------------------------

MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  

               VSI/SI                                              MAC-Tunnel  

-------------------------------------------------------------------------------

5489-9827-7795 1           -      -      GE0/0/2         sticky    -           

-------------------------------------------------------------------------------

Total matching items on slot 0 displayed = 1

[S1]

  1. 配置S1的G0/0/3接口为Sticky MAC。

[S1]i g0/0/3

[S1-GigabitEthernet0/0/3]port-security enable

[S1-GigabitEthernet0/0/3]port-security mac-address sticky

[S1-GigabitEthernet0/0/3]port-security max-mac-num 1

在PC4没通信之前,交换机的MAC地址表并没有其MAC地址的对应关系。查看MAC地址表。

[S1]display mac-address

MAC address table of slot 0:

-------------------------------------------------------------------------------

MAC Address    VLAN/       PEVLAN CEVLAN Port            Type      LSP/LSR-ID  

               VSI/SI                                              MAC-Tunnel  

-------------------------------------------------------------------------------

5489-9827-7795 1           -      -      GE0/0/2         sticky    -           

-------------------------------------------------------------------------------

Total matching items on slot 0 displayed = 1

在PC4上访问PC3:

PC>ping 10.1.1.4

Ping 10.1.1.4: 32 data bytes, Press Ctrl_C to break

From 10.1.1.4: bytes=32 seq=1 ttl=128 time=47 ms

From 10.1.1.4: bytes=32 seq=2 ttl=128 time=31 ms

From 10.1.1.4: bytes=32 seq=3 ttl=128 time=31 ms

From 10.1.1.4: bytes=32 seq=4 ttl=128 time=47 ms

From 10.1.1.4: bytes=32 seq=5 ttl=128 time=47 ms

--- 10.1.1.4 ping statistics ---

  5 packet(s) transmitted

  5 packet(s) received

  0.00% packet loss

  round-trip min/avg/max = 31/40/47 ms

再次查看MAC地址表:

[S1]display mac-address

MAC address table of slot 0:

-------------------------------------------------------------------------------

MAC Address    VLAN/       PEVLAN CEVLAN Port

               VSI/SI                                              MAC-Tunnel  

-------------------------------------------------------------------------------

5489-9827-7795 1           -      -      GE0/0/2         sticky    -           

5489-98fd-042c 1           -      -      GE0/0/3         sticky    -           

-------------------------------------------------------------------------------

Total matching items on slot 0 displayed = 2

可以看到G0/0/3接口学习到的MAC地址为PC4的MAC地址,并且类型为sticky。

    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值