Skip to content

Commit 4d7ca74

Browse files
committed
Deploy on Azure
1 parent 9a7844f commit 4d7ca74

File tree

4 files changed

+355
-0
lines changed

4 files changed

+355
-0
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ We will use <a href="https://libreswan.org/" target="_blank">Libreswan</a> as th
3737

3838
## Requirements
3939

40+
Microsoft Azure Subscription
41+
42+
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fderdanu%2Fsetup-ipsec-vpn%2Fmaster%2Fazure%2Fazuredeploy.json" target="_blank">
43+
<img src="http://azuredeploy.net/deploybutton.png"/>
44+
</a>
45+
4046
A newly created <a href="https://aws.amazon.com/ec2/" target="_blank">Amazon EC2</a> instance, using these AMIs: (See <a href="https://blog.ls20.com/ipsec-l2tp-vpn-auto-setup-for-ubuntu-12-04-on-amazon-ec2/#vpnsetup" target="_blank">instructions</a>)
4147
- <a href="https://cloud-images.ubuntu.com/locator/" target="_blank">Ubuntu 16.04 (Xenial), 14.04 (Trusty) or 12.04 (Precise)</a>
4248
- <a href="https://wiki.debian.org/Cloud/AmazonEC2Image" target="_blank">Debian 8 (Jessie) EC2 Images</a>

Diff for: azure/azuredeploy.json

+321
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"username": {
6+
"type": "string",
7+
"minLength": 1,
8+
"metadata": {
9+
"description": "User name for SSH and VPN"
10+
}
11+
},
12+
"password": {
13+
"type": "securestring",
14+
"metadata": {
15+
"description": "User password for SSH and VPN"
16+
}
17+
},
18+
"preSharedKey": {
19+
"type": "securestring",
20+
"metadata": {
21+
"description": "Pre-Shared Key for VPN"
22+
}
23+
},
24+
"image": {
25+
"type": "string",
26+
"allowedValues": [
27+
"ubuntu",
28+
"debian"
29+
],
30+
"defaultValue": "debian",
31+
"metadata": {
32+
"description": "OS to use. Debian or Ubuntu"
33+
}
34+
},
35+
"VMSize": {
36+
"type": "string",
37+
"defaultValue": "Standard_A0",
38+
"allowedValues": [
39+
"Standard_A0",
40+
"Standard_A1",
41+
"Standard_A2",
42+
"Standard_A3",
43+
"Standard_A4",
44+
"Standard_A5",
45+
"Standard_A6",
46+
"Standard_A7",
47+
"Standard_A8",
48+
"Standard_A9",
49+
"Standard_A10",
50+
"Standard_A11",
51+
"Standard_D1",
52+
"Standard_D2",
53+
"Standard_D3",
54+
"Standard_D4",
55+
"Standard_D11",
56+
"Standard_D12",
57+
"Standard_D13",
58+
"Standard_D14",
59+
"Standard_D1_v2",
60+
"Standard_D2_v2",
61+
"Standard_D3_v2",
62+
"Standard_D4_v2",
63+
"Standard_D5_v2",
64+
"Standard_D11_v2",
65+
"Standard_D12_v2",
66+
"Standard_D13_v2",
67+
"Standard_D14_v2",
68+
"Standard_G1",
69+
"Standard_G2",
70+
"Standard_G3",
71+
"Standard_G4",
72+
"Standard_G5",
73+
"Standard_DS1",
74+
"Standard_DS2",
75+
"Standard_DS3",
76+
"Standard_DS4",
77+
"Standard_DS11",
78+
"Standard_DS12",
79+
"Standard_DS13",
80+
"Standard_DS14",
81+
"Standard_GS1",
82+
"Standard_GS2",
83+
"Standard_GS3",
84+
"Standard_GS4",
85+
"Standard_GS5"
86+
],
87+
"metadata": {
88+
"description": "The size of the Virtual Machine."
89+
}
90+
}
91+
},
92+
"variables": {
93+
"location": "[resourceGroup().location]",
94+
"vmName": "vpnserver",
95+
"virtualNetworkName": "vpnVnet",
96+
"addressPrefix": "10.0.0.0/16",
97+
"subnetName": "VPNSubnet",
98+
"subnetPrefix": "10.0.1.0/24",
99+
"apiVersion": "2015-06-15",
100+
"storageName": "[concat(uniqueString(resourceGroup().id), 'vpnsa')]",
101+
"vhdStorageType": "Standard_LRS",
102+
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
103+
"SubnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]",
104+
"ubuntu": {
105+
"publisher": "Canonical",
106+
"offer": "UbuntuServer",
107+
"sku": "16.04.0-LTS",
108+
"version": "latest"
109+
},
110+
"debian": {
111+
"publisher": "credativ",
112+
"offer": "Debian",
113+
"sku": "8",
114+
"version": "latest"
115+
},
116+
"installScriptURL": "https://raw.githubusercontent.com/derdanu/setup-ipsec-vpn/master/azure/install.sh",
117+
"installCommand": "[concat('sh install.sh ', parameters('preSharedKey'), ' ', parameters('username'), ' ', parameters('password'))]"
118+
},
119+
"resources": [
120+
{
121+
"type": "Microsoft.Storage/storageAccounts",
122+
"name": "[variables('storageName')]",
123+
"apiVersion": "[variables('apiVersion')]",
124+
"location": "[variables('location')]",
125+
"tags": {
126+
"displayName": "StorageAccount"
127+
},
128+
"properties": {
129+
"accountType": "[variables('vhdStorageType')]"
130+
}
131+
},
132+
{
133+
"apiVersion": "[variables('apiVersion')]",
134+
"type": "Microsoft.Network/virtualNetworks",
135+
"name": "[variables('virtualNetworkName')]",
136+
"location": "[variables('location')]",
137+
"tags": {
138+
"displayName": "VirtualNetwork"
139+
},
140+
"properties": {
141+
"addressSpace": {
142+
"addressPrefixes": [
143+
"[variables('addressPrefix')]"
144+
]
145+
},
146+
"subnets": [
147+
{
148+
"name": "[variables('subnetName')]",
149+
"properties": {
150+
"addressPrefix": "[variables('subnetPrefix')]"
151+
}
152+
}
153+
]
154+
}
155+
},
156+
{
157+
"apiVersion": "[variables('apiVersion')]",
158+
"type": "Microsoft.Network/networkInterfaces",
159+
"name": "[concat(variables('vmName'), 'nic')]",
160+
"location": "[resourceGroup().location]",
161+
"tags": {
162+
"displayName": "NetworkInterface"
163+
},
164+
"dependsOn": [
165+
"[concat('Microsoft.Network/virtualNetworks/', concat(variables('virtualNetworkName')))]",
166+
"[concat('Microsoft.Network/publicIPAddresses/', concat(variables('vmName'), 'pip'))]",
167+
"[concat('Microsoft.Network/networkSecurityGroups/', concat(variables('vmName'), 'nsg'))]"
168+
],
169+
"properties": {
170+
"ipConfigurations": [
171+
{
172+
"name": "ipconfig1",
173+
"properties": {
174+
"privateIPAllocationMethod": "Dynamic",
175+
"publicIPAddress": {
176+
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('vmName'), 'pip'))]"
177+
},
178+
"subnet": {
179+
"id": "[variables('subnetRef')]"
180+
}
181+
}
182+
}
183+
],
184+
"networkSecurityGroup": {
185+
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('vmName'), 'nsg'))]"
186+
}
187+
}
188+
},
189+
{
190+
"apiVersion": "[variables('apiVersion')]",
191+
"type": "Microsoft.Compute/virtualMachines",
192+
"name": "[variables('vmName')]",
193+
"location": "[resourceGroup().location]",
194+
"tags": {
195+
"displayName": "VirtualMachine"
196+
},
197+
"dependsOn": [
198+
"[concat('Microsoft.Network/networkInterfaces/', concat(variables('vmName'), 'nic'))]"
199+
],
200+
"properties": {
201+
"hardwareProfile": {
202+
"vmSize": "[parameters('vmSize')]"
203+
},
204+
"osProfile": {
205+
"computerName": "[variables('vmName')]",
206+
"adminUsername": "[parameters('username')]",
207+
"adminPassword": "[parameters('password')]"
208+
},
209+
"storageProfile": {
210+
"imageReference": "[variables(parameters('image'))]",
211+
"osDisk": {
212+
"name": "osdisk",
213+
"vhd": {
214+
"uri": "[concat('http://', variables('storageName'), '.blob.core.windows.net/vmachines/', variables('vmName'), '.vhd')]"
215+
},
216+
"caching": "ReadWrite",
217+
"createOption": "FromImage"
218+
}
219+
},
220+
"networkProfile": {
221+
"networkInterfaces": [
222+
{
223+
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vmName'), 'nic'))]"
224+
}
225+
]
226+
}
227+
}
228+
},
229+
{
230+
"type": "Microsoft.Compute/virtualMachines/extensions",
231+
"name": "[concat(variables('vmName'),'/installcustomscript')]",
232+
"apiVersion": "[variables('apiVersion')]",
233+
"location": "[resourceGroup().location]",
234+
"tags": {
235+
"displayName": "VirtualMachineCustomScriptExtension"
236+
},
237+
"dependsOn": [
238+
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
239+
],
240+
"properties": {
241+
"publisher": "Microsoft.OSTCExtensions",
242+
"type": "CustomScriptForLinux",
243+
"typeHandlerVersion": "1.3",
244+
"settings": {
245+
"fileUris": [ "[variables('installScriptURL')]" ],
246+
"commandToExecute": "[variables('installCommand')]"
247+
}
248+
}
249+
},
250+
{
251+
"type": "Microsoft.Network/networkSecurityGroups",
252+
"name": "[concat(variables('vmName'), 'nsg')]",
253+
"tags": {
254+
"displayName": "NetworkSecurityGroup"
255+
},
256+
"apiVersion": "[variables('apiVersion')]",
257+
"location": "[resourceGroup().location]",
258+
"properties": {
259+
"securityRules": [
260+
{
261+
"name": "default-ssh",
262+
"properties": {
263+
"protocol": "Tcp",
264+
"sourcePortRange": "*",
265+
"destinationPortRange": "22",
266+
"sourceAddressPrefix": "*",
267+
"destinationAddressPrefix": "*",
268+
"access": "Allow",
269+
"priority": 1000,
270+
"direction": "Inbound"
271+
}
272+
},
273+
{
274+
"name": "default-udp-500",
275+
"properties": {
276+
"protocol": "Udp",
277+
"sourcePortRange": "*",
278+
"destinationPortRange": "500",
279+
"sourceAddressPrefix": "*",
280+
"destinationAddressPrefix": "*",
281+
"access": "Allow",
282+
"priority": 2000,
283+
"direction": "Inbound"
284+
}
285+
},
286+
{
287+
"name": "default-udp-4500",
288+
"properties": {
289+
"protocol": "Udp",
290+
"sourcePortRange": "*",
291+
"destinationPortRange": "4500",
292+
"sourceAddressPrefix": "*",
293+
"destinationAddressPrefix": "*",
294+
"access": "Allow",
295+
"priority": 2001,
296+
"direction": "Inbound"
297+
}
298+
}
299+
]
300+
}
301+
},
302+
{
303+
"apiVersion": "[variables('apiVersion')]",
304+
"type": "Microsoft.Network/publicIPAddresses",
305+
"name": "[concat(variables('vmName'), 'pip')]",
306+
"location": "[resourceGroup().location]",
307+
"tags": {
308+
"displayName": "PublicIPAddress"
309+
},
310+
"properties": {
311+
"publicIPAllocationMethod": "Static"
312+
}
313+
}
314+
],
315+
"outputs": {
316+
"Public IP": {
317+
"type": "string",
318+
"value": "[reference(concat(variables('vmName'), 'pip')).ipAddress]"
319+
}
320+
}
321+
}

Diff for: azure/azuredeploy.parameters.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"username": {
6+
"value": "Vpnuser"
7+
},
8+
"password": {
9+
"value": "Password123#"
10+
},
11+
"preSharedKey": {
12+
"value": "mypsksupersecure"
13+
}
14+
}
15+
}

Diff for: azure/install.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#/bin/bash
2+
export VPN_IPSEC_PSK=$1
3+
export VPN_USER=$2
4+
export VPN_PASSWORD=$3
5+
6+
# Debian on Azure has no lsb_release installed.
7+
if ! [[ -x "/usr/bin/lsb_release" ]]
8+
then
9+
apt-get update
10+
apt-get install -y lsb-release
11+
fi
12+
13+
wget https://git.io/vpnsetup -O vpnsetup.sh && sh vpnsetup.sh

0 commit comments

Comments
 (0)