반응형
스위치에 포트 보안을 거는 방식은 크게 두가지로 나눕니다.
Static(정적)설정과 Dynamic(동적)설정으로 구분합니다.
네트웍을 공부하시다보시면 Static이다 Dynamic이라는 얘기가 많이 나오는데요
정적이란 얘긴 관리자가 직접 명령어로 설정한다는 의미이며 동적이란 얘기는 해당프로토콜이
자동으로 동작하게 만드는것을 일컽습니다.
백문이 불여일견!! 테스트하면서 자세히 살펴보겠습니다.
그림1)
![]()
현재 SW1에 f0/2포트에 R2이 물려져있습니다.
show interface 명령어로 각자의 MAC주소를 알아보겠습니다.
SW1#sh int f0/2
FastEthernet0/2 is up, line protocol is up (connected) Hardware is Fast Ethernet, address is 000d.2880.f082 (bia 000d.2880.f082) MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255
R2#sh int f0/0
FastEthernet0/0 is up, line protocol is up Hardware is AmdFE, address is 0002.b971.7c60 (bia 0002.b971.7c60) MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255
현재는 아무런 포트보안이 걸리지 않은상태라서 SW1번의 MAC-Address-Table에 R2의 MAC주소가 등록되어있습니다.
확인해보겠습니다.
sw1#sh mac-address-table dynamic
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- ----- 1 0002.16f3.9f00 DYNAMIC Fa0/6 1 0002.b971.7c60 DYNAMIC Fa0/2 1 0006.285c.2020 DYNAMIC Fa0/5 1 0008.a3d4.d418 DYNAMIC Fa0/24 1 000d.2881.2c17 DYNAMIC Fa0/23 10 0008.a3d4.d418 DYNAMIC Fa0/24 20 0008.a3d4.d418 DYNAMIC Fa0/24 Total Mac Addresses for this criterion: 7
자...이제 본격적으로 Port 보안을 걸어보겠습니다.
먼저 정적으로 포트보안을 거는법을 알아보겠습니다.
sw1(config)#interface fastEthernet 0/2
sw1(config-if)#switchport port-security
sw1(config-if)#switchport port-security mac-address 0002.b971.7c60
포트보안을 적용시킬 포트로가서 switchport port-security를 먼저 선언 해줍니다.
그담에 switchport port-security mac-address 명령어로 포트보안을 걸 MAC어드레스를 직접 지정해주는 방법이
Static 포트보안 설정입니다.
해당 포트가 포트보안 설정이 적용되고 있는지 살펴보겠습니다.
sw1#sh port-security
1)Secure Port 2)MaxSecureAddr 3)CurrentAddr 4)SecurityViolation 5)Security Action (Count) (Count) (Count) --------------------------------------------------------------------------- Fa0/2 1 1 0 Shutdown --------------------------------------------------------------------------- Total Addresses in System (excluding one mac per port) : 0 Max Addresses limit in System (excluding one mac per port) : 5120
1)포트보안이 동작중인 포트표시
2)최대등록가능하 맥주소(기본값 1)
별다른 설정값을 주지않으면 포트보안용 맥주소가 하나밖에 등록이 안됩니다.
3)현재등록중인 맥주소
4)보안침해횟수
5)위반시 동작모드(기본값 shutdown)
protect , restrict , shutdown 세가지 옵션이 있습니다.
다른 명령어로 좀더 자세히 살펴보겠습니다.
sw1#sh port-security address
Secure Mac Address Table ------------------------------------------------------------------------ Vlan Mac Address Type Ports Remaining Age (mins) ---- ----------- ---- ----- ------------- 1 0002.b971.7c60 SecureConfigured Fa0/2 - ------------------------------------------------------------------------ Total Addresses in System (excluding one mac per port) : 0 Max Addresses limit in System (excluding one mac per port) : 5120
sw1#show port-security interface f0/2
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 <----------- 최대 등록가능 포트보안용 MAC주소의 개수 Total MAC Addresses : 1 <----------- 현재 포트보안용 MAC주소로 등록된 개수를 표시해줍니다. Configured MAC Addresses : 1 <-----------static으로 등록한 보안용 MAC주소의 개수(직접 보안용 MAC주소를
Sticky MAC Addresses : 0 직접등록했다는걸 알수있습니다.)
Last Source Address:Vlan : 0002.b971.7c60:1 Security Violation Count : 0
저장후 재부팅후에도 설정값이 남아있는지 확인해보겠습니다.
sw1#wr
Building configuration... [OK] sw1#rel Proceed with reload? [confirm]
<이하 생략>
sw1>en
Password:
sw1#sh run int f0/2
Building configuration...
Current configuration : 136 bytes
! interface FastEthernet0/2 switchport mode access switchport port-security switchport port-security mac-address 0002.b971.7c60 end
설정 값이 남아있죠 ^^ 이처럼 정적포트보안의 장점은 관리자가 보안용 맥주소를 직접 지정해줄수있다는 점과
재부팅을 하더라도 설정값이 NVRAM에 저장되어 계속등록되어있다는 점입니다.
하지만 등록해야할 포트보안용 MAC주소가 많아진다면 관리자가 일일이 등록하기 번거러울겁니다.
그땐 동적으로 설정하면 편리합니다.
이번엔 동적 포트보안 실습을 해보겠습니다.
먼저 앞서 정적 포트보안 설정을 지우겠습니다.
sw1(config-if)#no switchport port-security
sw1(config-if)#no switchport port-security mac-address 0002.b971.7c60
실습에 앞서 다음 그림2)와 같은 상황을 살펴보겠습니다.
그림2)
![]()
그림2)에서 SW2에서 F0/23에 포트 보안을 걸 경우를 생각해 보겠습니다.
SW2는 SW1과 트렁크 링크로 연결되어있고 DATA서버와도 연결되어있습니다.
즉.SW1에 허브로 연결되어있는 많은 PC들이 DATA서버로 접근하기위해 반드시 SW2를 거쳐야하는데
보안상 SW2의 F0/23포트보안을 걸어 보안용 MAC주소에 등록되어있는 USER만 허용할려고 합니다.
앞서 배운 Static설정을 해도 무관하겠지만 관리자가 지정해야할 맥주소가 그림에서 보는것처럼
많다면 번거러울 겁니다.
이때 사용하는게 Dynamic 포트보안 입니다.
각 SW들의 MAC 테이블을 확인해보겠습니다.
sw1#sh mac-address-table d
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- ----- 1 0002.163d.c1e0 DYNAMIC Fa0/1 1 0002.1648.4801 DYNAMIC Fa0/1 1 0002.16f3.9f00 DYNAMIC Fa0/1 1 0002.b971.7c60 DYNAMIC Fa0/1 1 0004.4dba.b6c0 DYNAMIC Fa0/2 1 0004.c059.f720 DYNAMIC Fa0/2 1 0006.285c.2020 DYNAMIC Fa0/2 1 0006.289f.99e0 DYNAMIC Fa0/2
.
.
.
SW2#sh mac-address-table dynamic
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- ----- 1 0002.163d.c1e0 DYNAMIC Fa0/23 1 0002.1648.4801 DYNAMIC Fa0/23 1 0002.16f3.9f00 DYNAMIC Fa0/23 1 0002.b971.7c60 DYNAMIC Fa0/23 1 0004.4dba.b6c0 DYNAMIC Fa0/23 1 0004.c059.f720 DYNAMIC Fa0/23 1 0006.285c.2020 DYNAMIC Fa0/23 1 0006.289f.99e0 DYNAMIC Fa0/23
.
.
SW2의 F0/23에 동적 포트보안을 걸어보겠습니다.
SW2(config)#int f0/23
SW2(config-if)#switchport trunk encapsulation dot1q
SW2(config-if)#switchport mode trunk
SW2(config-if)#switchport port-security maximum ?
<1-5120> Maximum addresses
SW2(config-if)#switchport port-security maximum 8
SW2(config-if)#switchport port-security violation ?
protect Security violation protect mode restrict Security violation restrict mode shutdown Security violation shutdown mode SW2(config-if)#switchport port-security violation restrict
SW2(config-if)#switchport port-security
앞서 정적설정과 달라진게 머가 있죠?? 찾으셨나요? ^^
우선 switchport port-security maximum 명령어로 최대등록 보안용맥주소 허용수를 8로 지정했습니다.
앞서 기본값이 1이라고 언급했었죠^^ 동적 포트보안을 설정하실때 가장중요한게 바로 이 설정입니다.
만약 이설정을 안하면 어떤현상이 나타날까요?
기본으로 1개 만 등록되고 나머지는 모두 등록이 되지않습니다.그리고 보안용 맥주소로 등록되지 못한 호스트가
서버로 접근시 위배 사항에 따라 동작하게되므로 반드시 등록할 보안용맥주소의 개수를 지정해주셔야 합니다.
앞서 Static설정도 마찮가지입니다 ^^
그리고 보안침해시 동작모드(Violation option)를 지정해줬습니다.
위처럼 3가지 옵션이 있고 기본값이 shutdown으로 동작합니다.
저는 violation옵션을 restrict로 설정하였습니다.
violation option에 대해 좀 자세히 잘펴보도록 하겠습니다. ^^
protect:보안 침해 발생시 해당 장비에 접속을 차단.허용된(보안용맥주소로 등록된)호스트들에 대해서는 허용
restrict:기본적으로 protect 옵션과 동일하지만 차이점이 보안 침해 호스트들의 대한 로그메시지를 남겨준다(권장 !!)
shutdown:보안 침해 발생시 해당 포트를 닫아버린다. 3옵션중 기본값이며 가장 강경대응이죠 ^^;;
shutdown으로 violation option을 사용하면 주의해야 될것이 보안침해 발생시 잘동작(보안용MAC주소가 등록된)
하고 있던 호스트들도 해당 포트가 막혀버려서 통신이 불가능해집니다.
그땐 해당 포트를 강제로 shutdown 시킨후 다시 no shutdown을 쳐줘야 해당 포트가 살아납니다.
이상설정 값들을 확인해보겠습니다.
SW2#sh port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action (Count) (Count) (Count) --------------------------------------------------------------------------- Fa0/23 8 7 0 Restrict --------------------------------------------------------------------------- Total Addresses in System (excluding one mac per port) : 6 Max Addresses limit in System (excluding one mac per port) : 5120
SW2#sh port-security address
Secure Mac Address Table ------------------------------------------------------------------------ Vlan Mac Address Type Ports Remaining Age (mins) ---- ----------- ---- ----- ------------- 1 0002.163d.c1e0 SecureDynamic Fa0/23 - 1 0002.16f3.9f00 SecureDynamic Fa0/23 - 1 0002.b971.7c60 SecureDynamic Fa0/23 - 1 0004.4dba.b6c0 SecureDynamic Fa0/23 - 1 0004.c059.f720 SecureDynamic Fa0/23 - 1 0006.285c.2020 SecureDynamic Fa0/23 - 1 0006.52c2.3017 SecureDynamic Fa0/23 - 1 000d.2880.f097 SecureDynamic Fa0/23 - ------------------------------------------------------------------------ Total Addresses in System (excluding one mac per port) : 7 Max Addresses limit in System (excluding one mac per port) : 5120
SW2#sh port-security int f0/23
Port Security : Enabled Port Status : Secure-up Violation Mode : Restrict <---침해 옵션이 restrict입니다. Aging Time : 0 mins Aging Type : Absolute SecureStatic Address Aging : Disabled Maximum MAC Addresses : 8 <---- 보안용 맥주소로 허용할 최대 맥주소입니다. Total MAC Addresses : 7 Configured MAC Addresses : 0 <---- Dynamic 포트보안을 설정해놨으니 값이 0입니다. Sticky MAC Addresses : 0 Last Source Address:Vlan : 0006.285c.2020:1 Security Violation Count : 0
이처럼 Dynamic 포트 보안은 직접 보안용 MAC주소를 지정해주지 않아되서 편리합니다.
하지만 다음과 같이 설정값 저장후 재부팅하면 설정값은 남아있지만 등록된 보안용 MAC주소가 사라지므로
스위치가 보안용 MAC주소를 다시 Dynamic하게 배울때 까지 기다려야 합니다.
SW2#wr
Building configuration...
[OK]
SW2#rel
Proceed with reload? [confirm]
<이하 생략>
SW2>en
Password:
SW2#sh run int f0/23
Building configuration...
Current configuration : 202 bytes
! interface FastEthernet0/23 switchport trunk encapsulation dot1q switchport mode trunk switchport port-security maximum 8 switchport port-security switchport port-security violation restrict
SW2#sh port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
--------------------------------------------------------------------------- Fa0/23 8 0 0 Restrict --------------------------------------------------------------------------- Total Addresses in System (excluding one mac per port) : 0 Max Addresses limit in System (excluding one mac per port) : 5120
현재 등록된 보안용 MAC주소가 없습니다.
즉 SW2가 보안용 MAC주소를 배우기위한 시간이 걸린다.
3~4분 경과후
SW2#sh port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action (Count) (Count) (Count) --------------------------------------------------------------------------- Fa0/23 8 7 0 Restrict ---------------------------------------------------------------------------
7개의 보안용MAC주소가 다 등록되기까지 스위치가 재부팅된 후로 3~4정도 경과했습니다.
이유인 즉은 Dynamic 포트보안 설정값을 스위치가 별도로 NVRAM에 저장해두지 않기 때문입니다.
이처럼 Dynamic 포트보안은 편리한반면 장비 재부팅후 컨버젼시 문제 때문에 Dynamic 포트보안의 다른 방법인
Sticky방식을 더 많이 사용합니다.
이번엔 Sticky 방식에 대해서 알아보겠습니다.
Sticky의 사전적인 의미가 끈적 끈적한 이라는 뜻입니다.
포트보안을 적용시킬 포트에서 Sticky설정을 해놓으면 포트보안용 MAC주소를 가진 호스트들이
해당포트로 들어와 자동으로 맥주소를 등록 시키는 방식입니다.
앞서 살펴본 Static과 Dynamic을 합쳐놓은 방식이라고 보시면 됩니다.
Sticky설정에 앞서 설정값을 바꿉니다.
SW2(config)#int f0/23
SW2(config-if)#no switchport port-security
SW2#sh run int f0/23
Building configuration...
Current configuration : 176 bytes
! interface FastEthernet0/23 switchport trunk encapsulation dot1q switchport mode trunk switchport port-security maximum 8 switchport port-security violation restrict
나머지 설정은 그대로 사용합니다.
SW2(config-if)#switchport port-security mac-address sticky
SW2(config-if)#switchport port-security
다음처럼 sticky설정을 한후 보안용MAC주소로 등록할 호스트들에게 한번씩 서버로 접근하라는 연락을 취합니다.
그럼 잠시후 다음과 같이 자동으로 포트 보안용 MAC주소가 SW2의 F0/23포트에 달라붙습니다.
SW2#sh port-security address
Secure Mac Address Table ------------------------------------------------------------------------ Vlan Mac Address Type Ports Remaining Age (mins) ---- ----------- ---- ----- ------------- 1 0002.16f3.9f00 SecureSticky Fa0/23 - 1 0002.b971.7c60 SecureSticky Fa0/23 - 1 0004.c059.f720 SecureSticky Fa0/23 - 1 0006.285c.2020 SecureSticky Fa0/23 - 1 000d.2880.f097 SecureSticky Fa0/23 - ------------------------------------------------------------------------
SW2#sh port-security interface f0/23
Port Security : Enabled Port Status : Secure-up Violation Mode : Restrict Aging Time : 0 mins Aging Type : Absolute SecureStatic Address Aging : Disabled Maximum MAC Addresses : 8 total MAC Addresses : 5 configured MAC Addresses : 0 Sticky MAC Addresses : 5 <-------- Sticky로 배운 포트보안용 MAC개수가 표시됩니다. Last Source Address:Vlan : 0002.163d.c1e0:1 Security Violation Count : 0
SW2#sh run int f0/23
Building configuration...
Current configuration : 547 bytes
! interface FastEthernet0/23 switchport trunk encapsulation dot1q switchport mode trunk switchport port-security maximum 8 switchport port-security switchport port-security violation restrict switchport port-security mac-address sticky switchport port-security mac-address sticky 0002.16f3.9f00 switchport port-security mac-address sticky 0002.b971.7c60 switchport port-security mac-address sticky 0004.c059.f720 switchport port-security mac-address sticky 0006.285c.2020 switchport port-security mac-address sticky 000d.2880.f097
다음처럼 맥주소가 Running-config에도 등록 됩니다. 저장한후 재부팅 시켜보겠습니다.
SW2#wr
Building configuration... [OK] SW2#rel Proceed with reload? [confirm]
<이하 생략>
SW2>en
password:
SW2#sh running-config int f0/23
Building configuration...
Current configuration : 547 bytes
! interface FastEthernet0/23 switchport trunk encapsulation dot1q switchport mode trunk switchport port-security maximum 8 switchport port-security switchport port-security violation restrict switchport port-security mac-address sticky switchport port-security mac-address sticky 0002.16f3.9f00 switchport port-security mac-address sticky 0002.b971.7c60 switchport port-security mac-address sticky 0004.c059.f720 switchport port-security mac-address sticky 0006.285c.2020 switchport port-security mac-address sticky 000d.2880.f097 end
재부팅후에도 포트보안용 MAC주소가 여전히 등록되어있습니다.
이처럼 Sticky방식은 Static의 설정의 번거러움이나 Dynamic의 컨버젼시 문제를 동시에 해결해줌으로
현업에서 가장많이 사용하는 방식입니다.
다음 테스트는 보안침해시 어떻케 동작하는지 알아보겠습니다.
먼저 SW1에서 Violation모드를 protect로 설정하였습니다.
sw1#int f0/2
sw1(config-if)#switchport port-security violation protect
이후 보안 침해를 발생시키기 위해 sw1의 f0/2에 다른 호스트를 접속시켜보았습니다.
현재 sw1 f0/2의 설정값은 다음과 같다.
sw1#sh run int f0/2
Building configuration...
Current configuration : 180 bytes
! interface FastEthernet0/2 switchport mode access switchport port-security switchport port-security violation protect switchport port-security mac-address 0002.b971.7c60 end
즉 0002.b971.7c60과 다른 MAC주소를 가진 호스트에 대해서는 접근을 차단하고 0002.b971.7c60으 호스트는 여전히
접근을 허용할것입니다.
보안 위배를 시켰음에도 불구하고 별다른 로그메시지 남기지 않치만 sw1의 맥주소테이블을 보면 다른호스트의 맥주소
를 배우지 않을것으로 보아 제대로 동작중임을 알수있다
sw1#sh mac-address-table d
Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- ----- 1 0002.163d.c1e0 DYNAMIC Fa0/7 1 0002.1648.4801 DYNAMIC Fa0/8 1 0002.16f3.9f00 DYNAMIC Fa0/6 1 0002.b971.7c60 DYNAMIC Fa0/2 1 0004.4dba.b6c0 DYNAMIC Fa0/3 1 0006.285c.2020 DYNAMIC Fa0/5 1 0006.289f.99e0 DYNAMIC Fa0/4 1 0008.a3d4.d418 DYNAMIC Fa0/24 1 000d.2881.2c17 DYNAMIC Fa0/23
다른 호스트를 연결시켰음에도 불구하고 여전히 0002.b971.7b60 주소를 가지고 있습니다.
즉 새로 연결시킨 호스트의 맥주소를 차단하고있음을 알수있습니다.
하지만 다름처럼 보안침해 카운터를 증가 시키지 않고 있습니다.
sw1#sh port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action (Count) (Count) (Count) --------------------------------------------------------------------------- Fa0/2 1 1 0 Protect --------------------------------------------------------------------------- Total Addresses in System (excluding one mac per port) : 0 Max Addresses limit in System (excluding one mac per port) : 5120
이번엔 violation옵션을 restrict로 설정해보겠습니다.
sw1(config-if)#switchport port-security violation restrict
적용시키자 마자 다음과 같은 로그 메시지를 계속해서 띄웁니다.
sw1(config-if)#
02:20:55: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address 0004.c059.f720 on port FastEthernet0/2. sw1(config-if)# 02:21:05: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address 0004.c059.f720 on port FastEthernet0/2.
0004.c059.f720이라는 MAC주소를 가진 호스트가 포트보안이 걸린 f0/2로 접근중이여서 보안 침해가 발생했다고 로그메시지를
발생시켜서 관리자에게 알려주고 있으며 다음과 같이 보안침해 카운터도 증가시켰습니다.
sw1#sh port-security interface f0/2
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 : 1 Sticky MAC Addresses : 0 Last Source Address:Vlan : 0004.c059.f720:1 Security Violation Count : 24
sw1#sh port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action (Count) (Count) (Count) --------------------------------------------------------------------------- Fa0/2 1 1 24 Restrict --------------------------------------------------------------------------- Total Addresses in System (excluding one mac per port) : 0 Max Addresses limit in System (excluding one mac per port) : 5120
이처럼 restric옵션은 로그메시지와 침해 카운터를 표시해줍니다.
실제 포트보안 적용시 가장 많이 사용하는 Violation옵션이죠.
이번엔 별다른 설정을 안해주면 기본값으로 동작하는 Shutdown을 적용해보겠습니다.
sw1(config-if)#switchport port-security violation shutdown
sw1(config-if)#end
sw1#
02:27:55: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address 0004.c059.f720 on port FastEthernet0/2. sw1# 02:27:56: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down sw1# 02:27:57: %LINK-3-UPDOWN: Interface FastEthernet0/2, changed state to down
0004.c059.f720이라는 포트보안침해 호스트 MAC주소때문에 보안침해가 발생했다는 로그메시지와 함께
해당 포트를 강제로 shutdown시켜버렸습니다. ^^;;
sw1#sh int f0/2
FastEthernet0/2 is down, line protocol is down (err-disabled)
sw1의 f0/2포트가 err-disabled상태가 되어있습니다.
이처럼 shutdown옵션은 강경대응이므로 많이 사용안하지만 주의해서 사용해야합니다.
죽은포트는 다음처럼 shutdown 시킨후 다시 no shutdown을 해야살아납니다.
sw1(config)#int f0/2
sw1(config-if)#shutdown
sw1(config-if)#no shutdown sw1(config-if)# 02:33:25: %LINK-3-UPDOWN: Interface FastEthernet0/2, changed state to up 02:33:26: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
하지만 violation상태가 shutdown상태로 지속된다면 보안침해 발생시 계속 해당 포트를
disabled상태로 만들어 버리겠죠 ^^;;
|
반응형