2014년 5월 30일 금요일

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