Thursday, March 28, 2024

在Windows Azure中部署SSTP和L2TP VPN

現在,Windows Azure越來越受歡迎。同時,我們都知道可以在Windows Azure上部署虛擬網絡。然而,部署Windows Azure的虛擬網絡是一件很煩人的事情。因此,我們可以使用Windows Server 2012的RRAS Roles提供 VPN。按照下面的步驟可以實現。

前提條件

創建SSL證書。

由於SSTP VPN是一種基於HTTPS的VPN,所以我們需要創建一個SSL證書。如果您想從SSL認證機構購買一個SSL證書,那會更好。如果不想買,我們可以創建一個自簽名證書(self-certificate)。

首先,打開IIS manager,選擇Server(RoccosVPN) – Server Certificates。如果在這個窗口顯示有一個頒發給您的VM FQDN名字的證書,請其導出私鑰。或者,你按照下面的步驟,製作自簽名證書。

圖 1 – 服務器證書

圖 2 – 導出證書

製作自簽名證書

  1. 打開CMD提示符(管理員權限)
  2. 使用 SelfSSL (IIS6 Resource Kit) 為SSTP生成一個自簽名SSL證書。
    selfssl.exe /N:cn=RoccosVPN.cloudapp.net /V:3650
    (3650 == 10年,”RoccosVPN.cloudapp.net” 表示一個合格的域名,the fully-qualified domain name, FQDN)
  3. 輸入”y”確認, 忽略metabase error(如果出現)
  4. 運行 mmc.exe, 添加 snap-in for Certificates -> Computer account
  5. 點擊 Personal -> Certificates
  6. 在 RoccosVPN.cloudapp.net certificate 上單擊右鍵, 然後選擇 All Tasks -> Export, 包括private keys和protect with password。

 

第一步, 創建 Windows Azure VM

點擊左下角按鈕 NEW, 選擇 COMPUTE – VIRTUAL MACHINE – QUICK CREATE, 在文本框中填寫 DNS NAME, USER NAME 和 NEW PASSWORD

圖 3 – 創建 VM

 

第二步, 配置 Windows Azure

為了部署 SSTP VPN, 首先, 我們應當為 VM 開啟 TCP 443 端口。

圖 4 – Azure Endpoint

然後使用 RDP(Remote Desktop Protocol,遠程桌面協議) 連接 VM 。

 

第三步, 添加 Server Role

點擊 Server Manager – Add roles and features,然後它會彈出一個窗口。在這個窗口中,我們將添加

圖 5 – 添加 Roles

它會彈出一個窗口。在這個窗口中,我們將添加 Remote Access role, DirectAccess and VPN (RAS) and Routing role services.

安裝 role and role services之後,它可能需要重新啟動。

 

第四步, 配置 Routing and Remote Access

重新啟動之後,打開 Server Manager – Notification – Open the Getting Started Wizard, 選擇 Deploy VPN only.

圖 6 – Getting Started Wizard

現在,打開 Routing and Remote Access 窗口。 右鍵點擊服務器名稱,點擊 Configure and Enable Routing and Remote Access

圖 7 – Routing and Remote Access Configure

然後, Routing and Remote Access Server Setup Wizard 將被打開。

圖 8 – Setup Wizard

點擊 Next 按鈕後,選擇 Custom configuration,並在Custom Configuration界面勾選 VPN access 和 NAT 

圖 9 – Customer Configuration

單擊 Finish後,它會啟動 Routing and Remote Access  服務。

在服務器上單擊鼠標右鍵,然後單擊 Properties ,選擇 Security 選項卡。在該選項卡中,選擇roccosvpn.cloudapp.net證書。

然後,點擊 IPV4 選項卡,選中 “Static address pool” 為客戶端獲取 IPv4 地址並點擊 OK 確定,如下:

點擊 IPv4 node 並展開。右鍵單擊 NAT 選擇 New Interface…

在這個對話框中,選擇一個 external interface。在 Network Address Translation Properties 對話框中,選擇Public interface connected to the Internet 和選中 Enable NAT on this interface。點擊 OK 保存配置。

圖 10 – NAT Properties

第五步, 添加 VPN Users

使用 Local Users and Groups 管理工具來添加一個新用戶。

打開 Run 對話框並輸入 lusrmgr.msc 然後點擊 OK 打開 Local Users and Group management.

然後單擊 Users  文件夾,在中間面板上的空白處單擊右鍵,選擇 New User ,輸入 Users Name, Full Name 和 Password,取消選中 User must change password at next logon.

之後,雙擊這個用戶名,切換到 Dial-in 標籤。在 Network Access Permission 中選擇 Allow access

圖 11 – User Properties

第六步, Client Configuration

安裝從服務器導出的證書到 Trusted Root Certificate Authorities.

轉到 Network and Sharing Center,單擊 Setup a new connection or network,然後選擇 Connect to a workplace 然後再選 Use my Internet Connection (VPN).

Internet Address 中輸入RoccosVPN.cloudapp.net,並輸入您的 Destination Name  然後 Create.

點擊網絡托盤圖標,右鍵單擊VPN connection,然後選擇 Properties

切換到 Security 選項卡。更改 VPN type 為 Secure Socket Tunneling Protocol (SSTP).

最後,選中 Microsoft CHAP Version 2 (MS-CHAP v2)  並點擊 OK 。

現在,連接這個VPN,輸入您的VPN用戶信息。開心的享用您的Windows Azure VPN。

第七步, L2TP VPN Deployment

部署 L2TP VPN時,我們首先應當在Windows Azure中開啟一些 UDP 端口。

L2TP port: UDP 1701

IPsec port: UDP 500

IKEv2 port: UDP 4500

此外,在Windows Server防火牆添加例外。

然後打開 RRAS management tools,右鍵單擊服務器,選擇 Properties 和 Security 選項卡。

選中 “Allow custom IPsec policy for L2TP/IKEv2 connection” 並輸入Preshared Key(預共享密鑰)。

參考文章:How to Setup Windows Azure (Server 2012) as an SSTP and L2TP VPN Provider

英文鏈接:How to Deploy SSTP and L2TP VPN in Windows Azure (Windows Server 2012)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.