-
Notifications
You must be signed in to change notification settings - Fork 5
/
pptp-server.yaml
173 lines (167 loc) · 4.84 KB
/
pptp-server.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
AWSTemplateFormatVersion: '2010-09-09'
Description: Setting up your own private and secure VPN.
Parameters:
VPNUsername:
Description: PPTP-VPN User
Type: String
MinLength: 4
MaxLength: 255
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
VPNPassword:
NoEcho: true
Description: PPTP-VPN Password
Type: String
MinLength: 4
MaxLength: 255
ConstraintDescription: must contain atleast 4 characters.
VPNPhrase:
NoEcho: true
Description: Passphrase for IPSEC PSK
Type: String
MinLength: 4
MaxLength: 255
ConstraintDescription: must contain atleast 4 characters.
InstanceSize:
Description: Instance Type
Type: String
Default: Standard.VPN-t2.micro
AllowedValues:
- Standard.VPN-t2.micro
- High.Speed.VPN-t2.medium
- Ultra.High.Speed.VPN-m3.xlarge
DNSServerPrimary:
Description: IPv4 Address for DNS server primary
Type: String
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}'
ConstraintDescription: Must be a valid IPv4 address (e.g. 1.1.1.1)
Default: '1.1.1.1'
DNSServerSecondary:
Description: IPv4 Address for DNS server secondary
Type: String
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}'
ConstraintDescription: Must be a valid IPv4 address (e.g. 1.0.0.1)
Default: '1.0.0.1'
Mappings:
AWSInstanceType2Arch:
Standard.VPN-t2.micro:
InstanceType: t2.micro
High.Speed.VPN-t2.medium:
InstanceType: t2.medium
Ultra.High.Speed.VPN-m3.xlarge:
InstanceType: m3.xlarge
AWSRegionArch2AMI:
us-east-1:
HVM64: ami-80861296
us-east-2:
HVM64: ami-618fab04
us-west-1:
HVM64: ami-2afbde4a
us-west-2:
HVM64: ami-efd0428f
eu-west-1:
HVM64: ami-a8d2d7ce
eu-west-2:
HVM64: ami-f1d7c395
eu-west-3:
HVM64: ami-c1cf79bc
eu-central-1:
HVM64: ami-060cde69
ap-northeast-1:
HVM64: ami-afb09dc8
ap-northeast-2:
HVM64: ami-66e33108
ap-southeast-1:
HVM64: ami-8fcc75ec
ap-southeast-2:
HVM64: ami-96666ff5
sa-east-1:
HVM64: ami-4090f22c
ap-south-1:
HVM64: ami-c2ee9dad
ca-central-1:
HVM64: ami-b3d965d7
Resources:
VPNServerInstance:
Type: AWS::EC2::Instance
Properties:
ImageId:
Fn::FindInMap:
- AWSRegionArch2AMI
- Ref: AWS::Region
- HVM64
InstanceType:
Fn::FindInMap:
- AWSInstanceType2Arch
- Ref: InstanceSize
- InstanceType
SecurityGroups:
- Ref: VPNSecurityGroup
Tags:
- Key: Name
Value:
Ref: AWS::StackName
UserData:
Fn::Base64: !Join
- '#'
- - !Sub |
#!/bin/sh
#Passing variables to shell
YOUR_IPSEC_PSK=${VPNPhrase}
YOUR_USERNAME=${VPNUsername}
YOUR_PASSWORD=${VPNPassword}
YOUR_DNS_PRIMARY=${DNSServerPrimary}
YOUR_DNS_SECONDARY=${DNSServerSecondary}
- |
#VPN 1 - L2TP IPSEC Server
wget https://git.io/vpnsetup -O vpnsetup.sh && sudo \
VPN_IPSEC_PSK=$YOUR_IPSEC_PSK \
VPN_USER=$YOUR_USERNAME \
VPN_PASSWORD=$YOUR_PASSWORD sh vpnsetup.sh
#VPN 2 - Setup PPTP Server
apt-get install pptpd -y
echo "localip 10.0.0.1" >> /etc/pptpd.conf
echo "remoteip 10.0.0.100-200" >> /etc/pptpd.conf
echo "$YOUR_USERNAME pptpd $YOUR_PASSWORD *" >> /etc/ppp/chap-secrets
echo "ms-dns $YOUR_DNS_PRIMARY" >> /etc/ppp/pptpd-options
echo "ms-dns $YOUR_DNS_SECONDARY" >> /etc/ppp/pptpd-options
service pptpd restart
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save
VPNSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: VPN Security Groups
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '500'
ToPort: '500'
CidrIp: 0.0.0.0/0
- IpProtocol: udp
FromPort: '500'
ToPort: '500'
CidrIp: 0.0.0.0/0
- IpProtocol: udp
FromPort: '4500'
ToPort: '4500'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '1723'
ToPort: '1723'
CidrIp: 0.0.0.0/0
- IpProtocol: udp
FromPort: '1723'
ToPort: '1723'
CidrIp: 0.0.0.0/0
- IpProtocol: udp
FromPort: '1701'
ToPort: '1701'
CidrIp: 0.0.0.0/0
Outputs:
VPNServerAddress:
Description: Use the IP as Server Address or VPN Host
Value:
Fn::GetAtt:
- VPNServerInstance
- PublicIp