Header

  1. View current page

    adioshun님의 노트

Profile_img_60x60_01
0

[구현] IPSec_Linux

 

*수정시 코멘트를 꼭 추가 합시다.

 

 

목표

각 호스트 간의 IPSec통신

 

[1] http://www.ipsec-howto.org/ipsec-howto.pdf
[2] http://www.linuxjournal.com/article/7840
[3] http://ipsec-tools.sourceforge.net/

 

설치 (데비안 기준)

  • 커널 2.6이상 (IPSec이 기본 설치), [2] 참고
    • 2.6에 들어 있는 IPSec은 KAME project를 기반으로 함[2], 그러므로 [1]을 참고 하는 것도 좋음
  • 관리 툴 설치 : apt-get install ipsec-tools [3]

 

설정파일

 

Node_A의 설정 파일 [2]

 

1: #!/usr/local/sbin/setkey -f
 2: flush;            // setkey 명령어
 3: spdflush;      //Security Asociation 과 Security Polies 초기화
 4:# <SA 설정>

 5: # AH <Node_A> to <Node_B>
 6: add <Node_A> <Node_B> ah 1000
 7:         -A hmac-md5 "1234567890123456";
 8: add <Node_B> <Node_A> ah 2000
 9:         -A hmac-md5 "1234567890123456";
10:
11: # ESP <Node_A> to <Node_B>
12: add <Node_A> <Node_B> esp 1001
13:         -E 3des-cbc "123456789012345678901234"    //암호화에 3DES 사용 , 뒤는 키값
14:         -A hmac-sha1 "12345678901234567890";      //인증에 SHA1 사용 , 뒤는 키값
15: add <Node_B> <Node_A> esp 2001
16:         -E 3des-cbc "123456789012345678901234"    //키값의 생성시 아래 명령어 프롤프트에서 실행[1]
17:         -A hmac-sha1 "12345678901234567890";     // dd if=/dev/random count=16 bs=1| xxd -ps
18:#<SP 설정>
19: spdadd <Node_A> <Node_B> any -P out IPsec  // (Node_B에서는 in으로 변경)
20:         esp/transport//require                             // <Node_A>에서  <Node_B>로 가는 모든(any)패킷은
21:         ah/transport//require;                             // Transport/ESP 와 Transport/AH 적용함
22:                                                                     // 하단 [SP설정] 참고  
23: spdadd <Node_B> <Node_A> any -P in IPsec// (Node_B에서는 out으로 변경)
24:         esp/transport//require
25:         ah/transport//require;

 

위 설정 파일을 /etc/setkey.conf로 저장

 

SA 설정

source | destination | ah/esp | SPI (Security Policy Index) any number but should be unique
| algorithm and associated secret key.

 

SP 설정

source | destination | on which kind of traffic to apply the policy (TCP, UDP, port, any) |
the direction in/out | what to do (IPsec/discard/none) | (esp/ah) / (transport/tunnel) /
(IP address of both ends of the tunnel) not required in transport mode / require.

 

 실행

 # setkey -f /etc/setkey.conf

 

확인

# setkey -D : SAD를 확인

# setkey -DP : SPD를 확인

 

실전 Tip

 setkey -f /etc/setkey.conf 로 설정파일을 읽어 들인다음

 설정했던 내용을 지워버리고 싶은 마음이 생길 것이다. 즉

 

# setkey -D

# setkey -DP

 

 이 두개를 실행했을때 아무것도 안나오게  하고 싶으면

 flush.conf 같은 파일을 하나 만들자

 1: #!/usr/local/sbin/setkey -f
 2: flush;           
 3: spdflush;

 

자 이제 이 flush.conf를 이용하여 ipsec 설정을 한방에 날리자

# setkey -f flush.conf

 위에 있는 두 명령으로 확인하면 싹 다 날라간걸 볼 수 있다.

 

참고 파일

IPsec-HowTo-WrittenByMoMTeam.hwp - windows XP까지의 신버전은 IPsec-windows에 올리겠다.

History

Last edited on 06/02/2007 03:09 by [-L-A-B-O-N-]™

Comments (0)

You must log in to leave a comment. Please sign in.