このページで解説している内容は、以下の YouTube 動画の解説で見ることができます。
演習ファイルのダウンロード
ネットワークの構成を Packet Tracer で一から設定していくのは大変かと思います。「ダウンロード」から演習で使用するファイルのダウンロードができます。ファイルは、McAfeeインターネットセキュリティでウイルスチェックをしておりますが、ダウンロードは自己責任でお願いいたします。
ポートセキュリティ(show port-security)
ポートセキュリティの確認を行うコマンドを解説していきます。
まず、下図のネットワークを構築してます。

ダイナミックポートセキュリティの設定を行います。
Switch(config)#interface fastEthernet 0/5
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security
show port-security interface {interface-id}
ポートセキュリティの設定を確認します。「show port-security interface {interface-id}」コマンドで、次の項目などが確認できます。
- インターフェイスのセキュアMAC アドレスの最大許容数
- インターフェイスのセキュアMAC アドレスの数
- セキュリティ違反の数
- 違反時の違反モード
次のコマンドを入力します。
Switch#show port-security interface fastEthernet 0/5
●Switchの「show port-security interface fastEthernet 0/5」の出力
Switch#show port-security interface fastEthernet 0/5
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
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
PC1からpingを行います。

もう一度、次のコマンドを入力します。
Switch#show port-security interface fastEthernet 0/5
●Switchの「show port-security interface fastEthernet 0/5」の出力
Switch#show port-security interface fastEthernet 0/5
Port Security : Enabled
Port Status : Secure-up
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 : 0
Sticky MAC Addresses : 0
Last Source Address:Vlan : 0003.E438.4224:1
Security Violation Count : 0
黄色の網掛けのようにPC1のMACアドレスが学習されていることが分かります。
このように、「show port-security interface {interface-id}」コマンドでは、ポートセキュリティのステータスが確認できます。
show port-security
「show port-security」コマンドは、ポートセキュリティの設定を確認することができます。
次のコマンドを実行します。
Switch#show port-security
●Switchの「show port-security」の出力
Switch#show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
--------------------------------------------------------------------
Fa0/5 1 1 0 Shutdown
----------------------------------------------------------------------
「f0/5」にポートセキュリティの設定が行われていることが確認できます。
show port-security address
全てのポートについて、セキュアなMAC アドレスを確認することができます。
次のコマンドを実行します。
Switch#show port-security address
●Switchの「show port-security address」の出力
Switch#show port-security address
Secure Mac Address Table
-----------------------------------------------------------------------------
Vlan Mac Address Type Ports Remaining Age
(mins)
---- ----------- ---- ----- -------------
1 0003.E438.4224 DynamicConfigured FastEthernet0/5 -
-----------------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 1024