Edgerouter IKEv2/IPSec VPN Roadwarior

7315 단어 networktech
외출지에서 자신의 집으로 연결하기 위해 Edgerouter에 L2TP/IPSec VPN을 설정했습니다.며칠 전 안드로이드 12로 스마트폰을 업그레이드한 L2TP/IPSec 방식은 인스커처라고 경고했다.원래 안드로이드 12는 새 VPN에 연결할 때 IKEv2/IPSec 이외에 다른 선택이 없습니다.안전한 VPN 방식이 아니라서 잘린 모습...
android12
그래서 이번 기회에 자신의 집 Edgerouter에 IKEv2/IPSec을 설정했습니다.
공식 문서에는 몇 개의Site-to-Site의 인터페이스 간 VPN의 설정 절차가 있지만 외부의 어떤 단말기에서 LAN에서 VPN 터널을 만드는 설정 절차에 대한 기록이 없다.

IKEv2/IPSec은


IKEv2(Internet Key Exchange Version2)는 IPsec을 기반으로 Cisco와 Microsoft가 개발 및 구현하는 비교적 새로운 프로토콜입니다.Windows/Linux/Mac/Android/iOS 대부분의 OS와 맞물려 L2 TP, PPTP, SSP와 비교해도 안전성을 희생하지 않고 더 높은 연결을 할 수 있다.
따라서 IKEv2/IPSec이 사용할 수 있는 환경이라면 L2 TP/IPSec을 고집할 필요가 없다.

인증서 작성


IKEv2/IPSec에서는 VPN 터널에서 사용되는 키 교환을 자동화하기 위해 X.509 인증서를 사용합니다.인증서(CA), 서버 인증서, 클라이언트 인증서(사용자당)를 각각 만듭니다.

인증 기관


먼저 /config/auth 디렉토리에 자체 서명된 루트 CA 인증서를 만듭니다.
RSA 비밀 키 카키.개인 서명 CA 인증서 caCert제작pem.

서버 인증서


그런 다음 /config/auth 디렉토리에 VPN 서버에 대한 인증서를 만듭니다.
또한 VPN 서버(Edgerouter의 DDNS 이름)를 vpn.example.com로 가정합니다.
RSA 비밀 키 vpnKey.pem을 만들고 추출된 공용 키에서 서버 인증서 vpnCert를 추출합니다.pem을 발행하고 CA로 서명합니다.서버 인증서는 FQDN(예: vpn.example.com)을 통해 식별됩니다.

클라이언트 인증서


마지막으로 고객이 VPN에 연결된 개인 인증서를 만듭니다.클라이언트 인증서는 FQDN이 아니라 클라이언트의 전자 메일 주소입니다(예:[email protected]) 클라이언트 인증서를 식별하는 위치가 다릅니다.
RSA 비밀 키 clientKey.pem을 만들고 추출한 공공 키에서 클라이언트 인증서를 제출합니다.pem을 발행하고 CA로 서명합니다.
작성한 모든 필수 인증서 및 키를 PKCS#12 파일에 채웁니다.p12가 생성되면 클라이언트마다 이 client Ceert가 있습니다.p12만 맞추면 돼.

VPN 서버


Edgerouter는 IKEv2/IPSec VPN 서버로 다음 구성에 투입됩니다.esp-settings proposal 또는 ike-settings proposal에 연결된 클라이언트에 대해 Cipher Suite를 지정합니다.다음은 안드로이드 12 터미널에 설정proposal 1, Windows 10 터미널에 설정proposal 2입니다.{{USERNAME}}{{PASSWORD}}는 클라이언트의 VPN 연결 시 요청한 로컬 계정을 임의로 지정한다.
edgerouter:~$ mkdir -p /config/auth
edgerouter:~$ cd /config/auth

edgerouter:/config/auth$ pki --gen --outform pem > caKey.pem
edgerouter:/config/auth$ pki --self --in caKey.pem --dn "C=JP,CN=Edgerouter Certificate Authority" --ca --outform pem > caCert.pem
IKE에서 UDP 포트 500호와 4500호는 ESP에서 IP 프로토콜 50호를 사용하기 때문에 WAN 인터페이스에 방화벽을 미리 설치하여 통과시켜야 한다.
자세한 내용은 여기.를 참조하십시오.
edgerouter:/config/auth$ pki --gen --outform pem > vpnKey.pem
edgerouter:/config/auth$ pki --pub --in vpnKey.pem | pki --issue --cacert caCert.pem --cakey caKey.pem --dn "C=JP,CN=vpn.example.com" --san="vpn.example.com" --flag serverAuth --flag --outform pem --digest sha256 > vpnCert.pem

VPN 클라이언트


안드로이드 터미널


작성된 PKCS#12 파일 client Certp12를 단말기에 나누어 VPN & app user certificate로 설치합니다.
그리고 VPN에서 화면을 새로 만들어서 다음과 같이 설정합니다.
edgerouter:/config/auth$ pki --gen --outform pem > clientKey.pem
edgerouter:/config/auth$ pki --pub --in clientKey.pem | pki --issue --cacert caCert.pem --cakey caKey.pem --dn "C=JP,[email protected]" --san="[email protected]" --outform pem --flag clientAuth --digest sha256 > clientCert.pem
edgerouter:/config/auth$ openssl pkcs12 -export -inkey clientKey.pem -in clientCert.pem -name "client" -certfile caCert.pem -caname "Edgerouter Certificate Authority" -out clientCert.p12
그리고 Connect를 누르면 VPN 연결을 시작하여 목적지에서 자신의 집 환경을 방문할 수 있습니다.
즐겁다.🎉

Windows 터미널


작성된 PKCS#12 파일 client Certp12를 단말기에 나누어 설치합니다.인증서의 저장 위치로 現在のユーザ 대신 ローカルコンピュータ 를 선택해야 합니다.
그리고 VPN에서 화면을 새로 만들어서 다음과 같이 설정합니다.
set vpn ipsec allow-access-to-local-interface enable
set vpn ipsec auto-firewall-nat-exclude enable
set vpn ipsec remote-access authentication local-users username {{USERNAME}} password {{PASSWORD}}
set vpn ipsec remote-access authentication mode local
set vpn ipsec remote-access client-ip-pool subnet 192.168.3.0/24
set vpn ipsec remote-access compatibility-mode disable
set vpn ipsec remote-access dns-servers server-1 192.168.1.1
set vpn ipsec remote-access dns-servers server-2 8.8.8.8
set vpn ipsec remote-access esp-settings proposal 1 dh-group 14
set vpn ipsec remote-access esp-settings proposal 1 encryption aes256
set vpn ipsec remote-access esp-settings proposal 1 hash sha256
set vpn ipsec remote-access esp-settings proposal 2 dh-group 2
set vpn ipsec remote-access esp-settings proposal 2 encryption aes256
set vpn ipsec remote-access esp-settings proposal 2 hash sha1
set vpn ipsec remote-access ike-settings authentication mode x509
set vpn ipsec remote-access ike-settings authentication x509 ca-cert-file /config/auth/caCert.pem
set vpn ipsec remote-access ike-settings authentication x509 local-id vpn.example.com
set vpn ipsec remote-access ike-settings authentication x509 remote-id %any
set vpn ipsec remote-access ike-settings authentication x509 remote-ca-cert-file /config/auth/caCert.pem
set vpn ipsec remote-access ike-settings authentication x509 server-cert-file /config/auth/vpnCert.pem
set vpn ipsec remote-access ike-settings authentication x509 server-key-file /config/auth/vpnKey.pem
set vpn ipsec remote-access ike-settings authentication x509 server-key-type rsa
set vpn ipsec remote-access ike-settings fragmentation disable
set vpn ipsec remote-access ike-settings ike-lifetime 86400
set vpn ipsec remote-access ike-settings operating-mode ikev2-mobike
set vpn ipsec remote-access ike-settings proposal 1 dh-group 14
set vpn ipsec remote-access ike-settings proposal 1 encryption aes256
set vpn ipsec remote-access ike-settings proposal 1 hash sha256
set vpn ipsec remote-access ike-settings proposal 2 dh-group 2
set vpn ipsec remote-access ike-settings proposal 2 encryption aes256
set vpn ipsec remote-access ike-settings proposal 2 hash sha256
set vpn ipsec remote-access inactivity 28800
set vpn ipsec remote-access outside-address 0.0.0.0

그리고 接続를 눌러 VPN 연결을 시작하여 목적지에서 자신의 집 환경을 방문할 수 있습니다.
즐겁다.🎉

좋은 웹페이지 즐겨찾기