[VPN] FortiGate 장비와 MacOS 사이의 IPSec 터널 설정

FortiGate 설정

IPSec Tunnels 생성

Network

  • Remote Gateway: “Dialup User”, Interface: “wan1″(공인 IP가 연결된 WAN 포트)
  • Local Gateway: Disable
  • Mode Config: Disable
  • NAT Traversal: Enable
  • Dead Peer Detection: On Idle
  • Add route: Disable
  • Auto discovery sender / receiver: Disable
  • Device creation: Enabled
  • Tunnel search: Selectors

Authentication

  • Method: Pre-shared Key
  • Pre-shared Key: 정한 PSK를 적는다. 아래 MacOS 설정의 ipsec.secrets 와 당연히 동일(e.g. mySecretKey)해야 한다.
  • IKE Version: 1
  • IKE Mode Main(ID protection)
  • Peer Options: Accept Types는 Specific peer ID로 하고 Peer ID로 아래 ipsec.confleftid와 동일(e.g. dasomoli.org)해야 한다.

Phase 1 Proposal

  • Encryption: AES256
  • Integrity: SHA256
  • DH Group: 14
  • Key Lifetime (seconds): 86400

XAUTH

  • Type: Disabled

Phase 2 Selectors

  • Subnet1
    • Local Address: 192.168.64.0/19 (192.168.64.0/255.255.224.0)
    • RemoteAddress: 192.168.0.0/24 (192.168.0.0/255.255.255.0)
    • Encryption: AES256, Integrity: SHA256, DH Group: 14
    • Enable Replay Detection: Enabled
    • Enable Perfect Forward Secrecy (PFS): Enabled
    • Local Port/Remote Port/Protocol: Enabled
    • Key Lifetime: 3600
  • Subnet2
    • Local Address: 10.30.0.0/16 (10.30.0.0/255.255.0.0)
    • RemoteAddress: 192.168.0.0/24 (192.168.0.0/255.255.255.0)
    • Encryption: AES256, Integrity: SHA256, DH Group: 14
    • Enable Replay Detection: Enabled
    • Enable Perfect Forward Secrecy (PFS): Enabled
    • Local Port/Remote Port/Protocol: Enabled
    • Key Lifetime: 3600

Log 확인

FortiGate CLI에서 확인

diagnose vpn ike gateway list

또는:

diagnose vpn tunnel list

그 외.

  • Static Routes에 터널 연결된 PC로의 routing이 추가되어야 한다.
  • Firewall Policy가 추가된 IPSec 터널을 위한 인터페이스에 incoming/outgoing 모두 허용되어야 한다.
    • NAT는 이 경우 Disable하여야 한다.

MacOS 설정

1. 사전 준비

1.1. strongswan 설치

strongswan 을 설치한다.

brew install strongswan

2. 설정 파일 작성

/opt/homebrew/etc/ipsec.conf 설정 파일을 작성한다.

  • left: 내 Mac
  • right: FortiGate의 공인 IP
  • leftid, rightid: FortiGate와 일치해야 함
  • leftsubnet: 집 네트워크
  • rightsubnet: FortiGate 내부 네트워크
  • ike나 esp의 aes256-sha256-modp2048 는 Encryption: AES256, Integrity: SHA256, DH Group: 14를 의미한다. 느낌표(!)는 강제 적용을 의미한다.
config setup
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"

conn fortigate
    keyexchange=ikev1
    aggressive=no
    authby=psk
    forceencaps=yes
    installpolicy=yes
    type=tunnel
    left=%defaultroute
    leftid=@dasomoli.org
    right=11.13.3.1
    rightid=11.13.3.1
    leftsubnet=192.168.0.0/24
    rightsubnet=192.168.64.0/19,10.30.0.0/16
    leftupdown=/opt/homebrew/etc/ipsec-updown.sh
    ike=aes256-sha256-modp2048!
    esp=aes256-sha256-modp2048!
    ikelifetime=86400s
    lifetime=3600s
    dpdaction=restart
    auto=start

설정 파일에서 사용하는 /opt/homebrew/etc/ipsec-updown.sh 를 작성한다. 이는 strongSwan은 macOS에서 커널 라우팅 테이블에 자동으로 라우트를 추가하지 않기 때문이다. 이는 macOS 커널이 PF_ROUTE를 통해 정책 기반 라우팅을 제공하지 않기 때문이다. 따라서 updown 스크립트를 활용해 수동 라우팅을 추가한다.

#!/bin/sh
case "$PLUTO_VERB" in
    up-client)
        /sbin/route add -net 10.30.0.0/16 -interface $PLUTO_INTERFACE
        /sbin/route add -net 192.168.64.0/19 -interface $PLUTO_INTERFACE
        ;;
    down-client)
        /sbin/route delete -net 10.30.0.0/16
        /sbin/route delete -net 192.168.64.0/19
        ;;
esac

PSK를 /opt/homebrew/etc/ipsec.secrets 파일 안에 다음과 같이 넣는다.

@dasomoli.org @fortigate : PSK "mySecretKey"

3. 실행 방법

macOS에서는 시스템 서비스로 실행되지 않기 때문에, 수동으로 아래와 같이 실행한다.

sudo ipsec start

또는

sudo ipsec down fortigate
sudo ipsec up fortigate

로그 확인:

log show --predicate 'process == "charon"' --info --last 5m

연결 확인:

ipsec statusall

종료:

sudo ipsec stop

라우팅 확인:

route -n get 10.30.0.1

혹은:

netstat -rn | grep 10.

부트캠프 Windows 10에서 에어팟프로 소리가 끊길 때 해결방법

MacBook Pro 2019 16″에 부트캠프(Bootcamp)로 설치한 Windows 10에서 에어팟 프로(Airpods pro)를 연결하면 연결은 잘 된 것 같음에도 불구하고 소리가 제대로 안나오고 끊기면서 나온다. 그냥 안되나보다 하고 USB방식의 게이밍 헤드셋도 하나 샀는데 어이없는 해결방법이 있었다.

해결 방법은 그냥 MacOS로 진입한 후에 설정에서 블루투스를 끄고 재시동해서 Windows 10으로 진입한 후 연결하면 소리가 끊기지 않고 매우 잘 들린다.

참고한 곳은 아래 질문의 맨 아래 답변이다. 정말 silly fix다.

[MacOS] 클립보드 매니저 Clipy

복사/붙여넣기를 할 때 이전 복사했던 것들을 다시 붙여 넣는 경우가 많다.

Windows에서는 Ditto를 애용하는데, 맥에서는 어떤게 있나 보니 오픈소스인 Clipy가 있다.

github https://github.com/Clipy/Clipy 에서 받을 수 있고,

사용법은 간단히 Shift + Cmd + ‘V’ 혹은 Ctrl + Cmd + ‘V’이다.

기본 설정은 항목이 폴더 안에 들어가도록 되어 있는데,

“Preferences…” / “Menu” / “Number of items place inline:” 이 “0”으로 되어 있던 것을 “10” 등으로 적당히 늘려주면 된다.