CBROJIN 2025. 6. 22. 15:01

🔐 switchport port-security

switchport port-securityAccess Layer 포트에 연결 가능한 MAC 주소 수를 제한하고, 위반 시 동작 방식을 제어하는 기능입니다. 주로 무단 단말 연결 차단, 허브/스위치 확장 방지, 또는 보안 위협 차단 목적 등으로 활용됩니다.


🧩 aging

switchport port-security aging time [분]
switchport port-security aging type [inactivity | absolute]
  • static : 학습된 MAC이 aging 안 됨 (영구 저장)
  • inactivity : 지정 시간 동안 트래픽 없으면 삭제
  • absolute : 학습 후 지정 시간이 지나면 무조건 삭제
*예시
switchport port-security aging time 10
switchport port-security aging type inactivity
  • 10분간 트래픽 없으면 sticky MAC 자동 제거

 

🧩  mac-address

switchport port-security mac-address [sticky | H.H.H | forbidden]
  • 포트에 허용할 MAC 주소를 수동으로 등록하거나 자동 저장

1. sticky (자동 저장)

switchport port-security mac-address sticky
  • 최초 연결된 MAC 주소를 자동으로 등록 (동적 보안)
  • show port-security로 확인 가능
  • 스위치 재시작 후 유지하려면 write memory 필요

2. 수동 등록

switchport port-security mac-address 0001.2345.abcd
  • 지정된 MAC 주소만 허용하고 나머지는 차단

3. forbidden (금지 주소 지정)

switchport port-security mac-address forbidden 0001.2345.abcd
  • 해당 MAC 주소는 절대 접속 불가
  • 매우 제한적인 정책 환경에서 사용

 

🧩  maximum

switchport port-security maximum [숫자]

 

  • 해당 포트에서 허용할 최대 MAC 주소 수를 지정

 

🧩 violation

switchport port-security violation [protect | restrict | shutdown]

 

  • 설정된 MAC 수를 초과하거나 허용되지 않은 MAC 접속 시 동작 방식 지정
  • protect : 허용되지 않은 MAC 무시
  • restrict : 패킷 드롭 + 로깅
  • shutdown : 포트를 err-disable로 전환
 

🧩 확인 명령어

show port-security interface [interface-id]
show port-security address
  • 현재 포트 상태, 학습된 MAC 주소, 위반 횟수 등을 확인 가능

 

 

Q. 지금 상태에서 종단 장비 3개 이상을 접속하려 하면 어떻게 되나

A. 처음 2개 MAC 주소까지만 통신 가능하고, 나머지(3번째부터)는 통신 차단됩니다.

  • maximum 2 설정 → 포트는 2개의 MAC 주소까지만 허용
  • violation restrict 설정 → 3번째 MAC의 프레임은 드롭되고, syslog/log 메시지만 남음
  • 포트 자체는 err-disable(비활성) 상태가 되지 않고 계속 up 상태 유지

즉, 현재 1개가 등록되었기 때문에 추가로 1개까지 접속 가능, 그 이상은 차단됩니다.

프레임은 드롭되고, show port-security에서는 Violation Count가 증가