레이블이 security인 게시물을 표시합니다. 모든 게시물 표시
레이블이 security인 게시물을 표시합니다. 모든 게시물 표시

2014년 1월 23일 목요일

GRE IPsec VPN을 이용한 원격지간 OSPF Area 연결 - 8. OSPF 보안 / Area 및 Neighbor 인증





크게 Area 단위로 하는 인증 보안이 있고, Neighbor 관계 성립에 필요한 인증이 있다.
먼저 Area 단위 인증을 확인한다. 해당 구성에서는 Area 0을 사용한다.

A00A(config)# router ospf 5730
A00A(config-router)# area 0 authentication message-digest

이 상태에서 routing table을 확인하면 아래처럼 모든 OSPF네이버가 끊겨있다.


이 명령어에서 0은 Area 넘버. 뒤의 message-digest는 MD5방식으로 신호를 주고받는 설정이고, 없을경우는 평문으로 신호를 주고 받는다. (설정이 없는 경우는 type 0, 평문인증은 type 1, MD5인증은 type 2) 이는 debug ip ospf adj 명령으로 확인하면 다음과 같은 메세지로 확인할 수 있다. 아래처럼 주변의 라우터들은 설정이 아직 안된상태라 type 0이고, 자신은 type 2를 사용해서 맞지 않는다는 메세지가 나온다. 당연히 Neighbor 관계 성립이 안되며, 설정전에 Neighbor 관계가 맺어진 상태라면 풀린다.


마찬가지로 설정되지 않은 주변 라우터에서는 아래와 같이 반대로 나온다.


동일한 설정을 하면, 다시 Neighbor 관계가 성립된다.

이 상태에서 연결된 인터페이스간에 아래와 같이 설정한다.

A00A(config)# int f2/0
A00A(config-if)# ip ospf message-digest-key 10 md5 testpw

여기서 10은 인터페이스간 Key ID. 1~255중 하나를 선택하면 된다. 당연히 연결된 Neighbor간에는 동일해야 한다. md5 뒤의 텍스트(testpw)는 인증시 사용할 키. 
Key ID와 Key값은 Area 전체가 같을 필요는 없고, Neighbor간에만 일치시키면 된다. 
(여기서는 편의상 전체를 통일시켰다.)

debug ip ospf packet 명령으로 확인해보면 아래처럼 인증 타입과 Key ID를 확인할 수 있다.



Area 전체가 아닌, 특정 OSPF Neighbor에 대한 인증설정을 할 경우, 아래와 같이 진행한다.
여기서는 Tunnel 인터페이스 12, 13, 22, 23에 대해서 적용한다.

A00A(config)# int t12
A00A(config-if)# ip ospf authentication message-digest
A00A(config-if)# ip ospf message-digest-key 12 md5 ntestpw

이 경우 따로 Area 설정을 해줄 필요는 없다.


외부 링크 - 설정방법 관련
OSPF Design Guide
Sample Configuration for Authentication in OSPF


P.S : 아래는 편의를 위해 저장해두는 명령들.
Area 0에 속한 라우터에 대한 Area 0 인증 설정은 아래 명령어를 사용하면 된다.
4개의 라우터 모두 공통이다.

conf t
router ospf 5730
area 0 authentication message-digest
exit
int f0/0
ip ospf message-digest-key 10 md5 testpw
exit
int f0/1
ip ospf message-digest-key 10 md5 testpw
exit
int f2/0
ip ospf message-digest-key 10 md5 testpw
exit

-마지막 f2/0은 A00A와 A00B만 해당.

아래는 Tunnel 인터페이스간 Neighbor 인증.

int t12
ip ospf authentication message-digest
ip ospf message-digest-key 12 md5 ntestpw
exit
int t13
ip ospf authentication message-digest
ip ospf message-digest-key 13 md5 ntestpw
exit 
int t22
ip ospf authentication message-digest
ip ospf message-digest-key 22 md5 ntestpw
exit
int t23
ip ospf authentication message-digest
ip ospf message-digest-key 23 md5 ntestpw
exit


P.S2 : 이제 하나 남았다... 

2014년 1월 21일 화요일

GRE IPsec VPN을 이용한 원격지간 OSPF Area 연결 - 7. Tunnel 보안 / IPSec VPN


GRE Tunnel만 사용할 경우, 네트워크간 연결 자체에는 문제가 없으나 Tunneling을 위해서 Encapsulation되었을 뿐인 원본데이타 그대로가 외부 경로(이 경우에는 BGP로 연결된 구간이 해당된다.)를 지나가게 된다. 이는 중간단계에서 얼마든지 내용을 확인할 수 있고, 이를 변조시킬 수도 있다. 즉, Encapsulation만 되어 있어서 그 내용에 대한 보안에 문제가 있을 뿐더러, 그렇게 받은 내용을 신뢰할 수도 없다. VPN이 필요한 이유는 이러한 신뢰성과 보안성을 위해서이다.

IPSec VPN (여기서는 GRE Tunnel 동반)은 VPN(Virtual Private Networks : 가상 사설 네트워크)의 한 종류로, IP기반의 3계층 보안형식이다.

여기서는 GRE Tunnel과 함께 사용한다. 볼드 처리한 부분은 변수/옵션/이름지정을 해야하는 부분들이다.

1. 먼저 ISAKMP정책을 설정한다.

A00A(config)# crypto isakmp policy 10  / 정책이 여러개면 숫자가 낮을 수록 우선시됨.
A00A(config-isakmp)# encryption aes  / 암호화 방식을 설정
A00A(config-isakmp)# authentication pre-share / 인증은 사전에 설정한 키로 함.
A00A(config-isakmp)# hash sha  
A00A(config-isakmp)# group 5  Diffie Hellman groups 중 몇번을 사용할지 설정.
A00A(config-isakmp)# exit

encryption에서 사용 가능한 옵션은 아래의 세가지중 하나.
  3des  Three key triple DES
  aes   AES - Advanced Encryption Standard.
  des   DES - Data Encryption Standard (56 bit keys).

자세한 내용은 대칭키 암호화 - AES/DES/3DES 를 참조. 가장 최근것이 AES다.

authentication 항목에서 사용가능한 옵션을 다음과 같다.
  pre-share  Pre-Shared Key
  rsa-encr   Rivest-Shamir-Adleman Encryption
  rsa-sig    Rivest-Shamir-Adleman Signature

아래의 두 항목 관련 자료는 RSA (Rivest-Shamir-Adleman)를 참조.

lifetime 항목은 기본값으로 진행하였기에 별도로 설정하지 않았다.
(짧게 설정하면 보안에 좋지만... router 부하가 커진다.=GNS기동중인 컴퓨터 부하가 크다.)

2. 각 대상(여기서는 해당 Peer IP)에 대한 key값(Pre-Shared Key : PSK)을 입력하고

A00A(config)# crypto isakmp key 6 pword address 204.172.100.161
A00A(config)# crypto isakmp key 6 pword address 206.172.100.161

연결상태 유지 확인용 DPD(Dead Peer Detection) 설정.

A00A(config)# crypto isakmp keepalive 30

3. IPsec으로 보호할 대상 트래픽 지정.
ACL에서 GRE 대신 IP로 변경해도 됨.

A00A(config)# ip access-list extended vpn12  / Tunnel 12와 연동할 ACL이라 12
A00A(config-ext-nacl)# permit gre host 203.172.100.129 host 204.172.100.161
A00A(config-ext-nacl)# exit

A00A(config)# ip access-list extended vpn13   / Tunnel 13과 연동할 ACL이라 13
A00A(config-ext-nacl)# permit gre host 203.172.100.129 host 206.172.100.161
A00A(config-ext-nacl)# exit

4. IPsec SA를 지정한다. (여기서는 ts10번으로)

A00A(config)# crypto ipsec transform-set ts10 esp-aes esp-md5-hmac
A00A(cfg-crypto-trans)# exit

뒤의 보라색과 파란색 부분에  지정 가능한 옵션은 아래와 같다.

  ah-md5-hmac   AH-HMAC-MD5 transform
  ah-sha-hmac   AH-HMAC-SHA transform
  comp-lzs      IP Compression using the LZS compression algorithm
  esp-3des      ESP transform using 3DES(EDE) cipher (168 bits)
  esp-aes       ESP transform using AES cipher
  esp-des       ESP transform using DES cipher (56 bits)
  esp-md5-hmac  ESP transform using HMAC-MD5 auth
  esp-null      ESP transform w/o cipher
  esp-seal      ESP transform using SEAL cipher (160 bits)
  esp-sha-hmac  ESP transform using HMAC-SHA auth

6. Cryto Map을 설정한다.

먼저 Cryto Map의 Peer 지정을 Loopback Interface로 하기 때문에 이를 선언.

A00A(config)# crypto map GREVPN local-address loopback 0

그리고 Cryto Map의 새부설정을 지정.

A00A(config)# crypto map GREVPN 10 ipsec-isakmp
A00A(config-crypto-map)# match address vpn12 
A00A(config-crypto-map)# set peer 204.172.100.161  / Tunnel 12의 Dst
A00A(config-crypto-map)# set transform-set ts10  / 연결할 IPsec SA를 지정
A00A(config-crypto-map)# exit

A00A(config)# crypto map GREVPN 20 ipsec-isakmp
A00A(config-crypto-map)# match address vpn13
A00A(config-crypto-map)# set peer 206.172.100.161  / Tunnel 13의 Dst
A00A(config-crypto-map)# set transform-set ts10
A00A(config-crypto-map)# exit

6. Cryto Map을 해당 인터페이스에 지정.

A00A(config)# int s1/0  / 외부에서 직접 오는 경로
A00A(config-if)# crypto map GREVPN

A00A(config)# int f2/0  / 네트워크 구조상 우회할 수 있는 경로
A00A(config-if)# crypto map GREVPN


작업을 마치고 상태 확인은 아래의 명령어로 진행하면 된다.

clear ip access-list counters   / ACL 기록 초기화
show ip access-list  / ACL 적용 내역 조회 (초기화 후 좀 기다렸다 하는게 좋음.)

clear crypto session  / VPN 세션 초기화
show crypto isakmp sa  / 현재 VPN 관련 SA(Security Association) 정보


show crypto ipsec sa  / IPsec SA상태 조회


show crypto session detail  / 세션의 암호화/복호화 내역






관련 링크

설정방법(단, 실제 설정 자체는 이 내용보다는 피터전의 책을 더 참고하였다.)
Configuring VPNs Using an IPSec Tunnel and Generic Routing Encapsulation


관련 이론이나 자료, 정보
rfc 2408 isakmp

실제 진행하다 문제생긴 경우 참고할 곳.
IPsec Troubleshooting: Understanding and Using debug Commands
Proposal with ESP is missing cipher



실제 설정에서 각 라우터별 공통 부분은 아래와 같다.

conf t
crypto isakmp policy 10
encryption aes
authentication pre-share
hash sha
group 5
exit

각 라우터별 변동되는 부분은 아래와 같다.

#A00A
crypto isakmp key 6 pword address 204.172.100.161
crypto isakmp key 6 pword address 206.172.100.161

crypto isakmp keepalive 30

ip access-list extended vpn12
permit gre host 203.172.100.129 host 204.172.100.161
exit

ip access-list extended vpn13
permit gre host 203.172.100.129 host 206.172.100.161
exit

crypto ipsec transform-set ts10 esp-aes esp-md5-hmac
exit

crypto map GREVPN local-address loopback 0

crypto map GREVPN 10 ipsec-isakmp
match address vpn12
set peer 204.172.100.161
set transform-set ts10
exit

crypto map GREVPN 20 ipsec-isakmp
match address vpn13
set peer 206.172.100.161
set transform-set ts10
exit

int s1/0
crypto map GREVPN
exit

int f2/0
crypto map GREVPN
exit


#A00B
crypto isakmp key 6 pword address 204.172.100.161
crypto isakmp key 6 pword address 206.172.100.161

crypto isakmp keepalive 30

ip access-list extended vpn22
permit gre host 205.172.100.129 host 204.172.100.161
exit

ip access-list extended vpn23
permit gre host 205.172.100.129 host 206.172.100.161
exit

crypto ipsec transform-set ts10 esp-aes esp-md5-hmac
exit

crypto map GREVPN local-address loopback 0

crypto map GREVPN 10 ipsec-isakmp
match address vpn22
set peer 204.172.100.161
set transform-set ts10

crypto map GREVPN 20 ipsec-isakmp
match address vpn23
set peer 206.172.100.161
set transform-set ts10

int s1/0
crypto map GREVPN
int f2/0
crypto map GREVPN


#A10A
crypto isakmp key 6 pword address 203.172.100.129
crypto isakmp key 6 pword address 205.172.100.129

crypto isakmp keepalive 30

ip access-list extended vpn12
permit gre host 204.172.100.161 host 203.172.100.129
exit

ip access-list extended vpn22
permit gre host 204.172.100.161 host 205.172.100.129
exit

crypto ipsec transform-set ts20 esp-aes esp-md5-hmac
exit

crypto map GREVPN local-address loopback 0

crypto map GREVPN 10 ipsec-isakmp
match address vpn12
set peer 203.172.100.129
set transform-set ts20

crypto map GREVPN 20 ipsec-isakmp
match address vpn22
set peer 205.172.100.129
set transform-set ts20

int s1/1
crypto map GREVPN



#A20A
crypto isakmp key 6 pword address 203.172.100.129
crypto isakmp key 6 pword address 205.172.100.129

crypto isakmp keepalive 30

ip access-list extended vpn13
permit gre host 206.172.100.161 host 203.172.100.129
exit

ip access-list extended vpn23
permit gre host 206.172.100.161 host 205.172.100.129
exit

crypto ipsec transform-set ts30 esp-aes esp-md5-hmac
exit

crypto map GREVPN local-address loopback 0

crypto map GREVPN 10 ipsec-isakmp
match address vpn13
set peer 203.172.100.129
set transform-set ts30

crypto map GREVPN 20 ipsec-isakmp
match address vpn23
set peer 205.172.100.129
set transform-set ts30

int s1/1
crypto map GREVPN

2013년 10월 8일 화요일

SNMP(Simple Network Management Protocol) 및 SNMP Get/Get Next/Trap

SNMP(Simple Network Management Protocol)

네트워크 장비 관리 및 감시를 목적으로 개발되어 사용되는 UDP기반 응용계층 표준 프로토콜. 네트워크 구성관리/네트워크 사용량이나 에러, 처리속도, 응답시간등의 성능관리/네트워크 장비의 시스템 정보를 통한 장비 관리/정보의 제어 및 보호 등이 주요 기능이다.


SNMP Get

동기상태인 대상 기기에 대한 단일 정보를 요청하는 경우 사용.


SNMP Get Next

동기상태인 대상 및 그 하위 기기에 대한 정보를 요청하는 경우 사용.


SNMP Trap

비동기적 상황(즉, 갑작스럽게 전달해야 하는 내용)에서 전달해야 할 정보가 있을 경우 사용. 돌발상황이나 정해진 임계치 이상의 시스템 자원 사용같은 바로 전달해야 할 내용이 있는 경우에 사용된다.


참고자료
http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/SNMP_%B0%B3%BF%E4
http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/SNMP

2013년 8월 19일 월요일

ARP/ARP Spoofing Attacks

- ARP(Address Resolution Protocol)

동일한 broadcast Domain에서 IP와 MAC 주소를 맵핑시켜 사용하는 Layer 2 기반의 통신 방법. 특정 IP의 MAC 주소를 아는 경우는 그 MAC주소로, 모를 경우는 broadcast로 MAC주소를 요청하며 해당 IP를 가진 Host에서 자신의 MAC주소를 알려주면 그걸 기억해뒀다가 사용하게 된다. 즉, 실제 통신은 MAC주소 기반으로 하게 됨.

- ARP Spoofing Attacks

ARP는 특정 IP에 대한 MAC주소를 모를 경우, 확인하기 위한 broadcast frame을 발생시킨다. 이때 다른 Host에서 대신 자신의 MAC 주소를 알려주게 되면 그 MAC주소로 맵핑시킨다. 이로서, 다른 Host에게 가야할 정보를 중간에서 가로채는게 가능해진다. 이게 가능한 이유는 ARP에서 사용하는 맵핑 과정 자체에는 검증과정이 포함되지 않기 때문이다.



관련문서

ARP Poisoning Attack and Mitigation Techniques

2013년 8월 15일 목요일

VLAN Hopping 공격

전제조건

- 인터페이스에 직접 억세스 모드 지정(switchport mode access)을 하지 않은 상태.
- 해당 장치가 DTP 지원.

직접 억세스포트로 지정하지 않고 VLAN지정만 하는 경우가 간혹 있고, 많은 경우(대부분의 스위치는 기본값이 Access Mode지만, DTP는 허용된 상태.) 이 상태로도 별다른 문제 없이 동작한다. 하지만 연결된 장치에서 의도적으로 DTP 프레임을 보내서 Trunk 모드로 동작시키는 경우, L3라우팅 없이도 지정된 VLAN이 아닌 다른 VLAN으로 신호를 보낼 수 있게 된다. 결과적으로 접근할 수 없는 영역으로 접근을 할 수 있게 되는 문제가 생긴다.

이를 방지하기 위해서는 두가지를 지키면 된다.

1. Access Port

반드시 아래와 같이 명시적으로 Access Port로 설정해서 DTP프레임을 받아도 Trunk Port로 전환되지 않도록 한다.

SW(config-if)# switchport mode access

2. Trunk Port (802.1Q)

802.1Q Trunk Port 간 연결은 native VLAN 설정이 일치해야 한다. 따라서 기본값인 1에서, 외부인이 알 수 없는 임의의 값으로 변경해서 사용한다. (당연하지만 이 임의의 값은 양쪽이 동일해야 통신이 된다. 즉, VLAN Hopping을 시도하는 상대가 Native Vlan 번호를 모른다면 설정 불일치 문제로 해당 포트가 shutdown 된다.)

SW(config-if)# switchport trunk encapsulation dot1q
SW(config-if)# switchport mode trunk
SW(config-if)# switchport trunk native vlan [임의의 값]


참고문서

Dynamic Trunking Protocol (DTP) - CISCO
VLAN Security White Paper