Project

General

Profile

The ungleich VPN infrastructure » History » Version 27

Nico Schottelius, 12/02/2019 04:39 PM

1 1 Nico Schottelius
h1. The ungleich VPN infrastructure
2
3 5 Nico Schottelius
{{toc}}
4
5 11 Nico Schottelius
h2. Status
6
7 24 Sanghee Kim
This document is *IN PRODUCTION*.
8 11 Nico Schottelius
9 27 Nico Schottelius
h2. How to get VPN
10
11
* If you are a VM users of DataCenterLight, you get it for free
12
* Otherwise you can book it at https://IPv6VPN.ch
13
* In both cases, send a request to suport at ungleich.ch
14
15
16 13 Nico Schottelius
h2. Security of IPv6 vs. NAT
17
18
A quick reminder: whether you are using private RFC1918 IPv4 addresses or IPv6 addresses, if you don't want people to access your network, you need to configure a firewall.
19
20 14 Nico Schottelius
h2. Wireguard VPN on vpn-2a0ae5c1.ungleich.ch
21 1 Nico Schottelius
22
* Server: vpn-2a0ae5c1.ungleich.ch
23
* Port: 51820
24
* Requires a public key
25 7 Nico Schottelius
* Client network: 2a0a:e5c1:100::/40
26 1 Nico Schottelius
* Client network size: /48
27
28 9 Nico Schottelius
h3. How to add a new customer connection
29 1 Nico Schottelius
30 9 Nico Schottelius
* Get the public key of the customer
31
* Edit dot-cdist/type/__ungleich_wireguard/manifest and add the new network definition at the end of the file
32
* Let the customer know their network
33 1 Nico Schottelius
34 9 Nico Schottelius
h3. Sample clustomer client configuration
35
36
* "Install wireguard":https://www.wireguard.com/install/
37
* Create your private key: @umask 077; wg genkey > privkey@
38
* Get your public key: @wg pubkey < privkey@
39
** You need to send this pubkey to ungleich
40
* You will get your network definition after we have received your public key
41
* Create /etc/wireguard/wg0.conf
42
43 1 Nico Schottelius
<pre>
44
[Interface]
45
PrivateKey = YOURKEYHERE
46 12 Nico Schottelius
Address = YOURIPv6IPADDRESSHERE/48
47 1 Nico Schottelius
ListenPort = 51280
48
49
[Peer]
50 9 Nico Schottelius
PublicKey = hi60lGP+xEUQ+kVnqA7PlJAO1SVqTS1W36g0LhFP0xQ=
51 1 Nico Schottelius
Endpoint = vpn-2a0ae5c1.ungleich.ch:51820
52
AllowedIPs = ::/0
53
</pre>
54
55 19 Nico Schottelius
* *ONLY change* the PrivateKey and the Address entries.
56
* *ALL other entries* (especially PublicKey, Endpoint and AllowedIPs) need to *stay as is*
57
58 14 Nico Schottelius
h3. How to setup the VPN (the easy way)
59
60
Once you have created the configuration, you can simply call
61
62
<pre>
63
wg-quick up wg0
64
</pre>
65
66
And to stop the VPN, you can use
67
68
<pre>
69
wg-quick down wg0
70
</pre>
71
72
73
h3. How to setup the VPN (the manual way)
74
75
76 1 Nico Schottelius
Commands for setting it up
77
78
<pre>
79
MY_NET=2a0a:e5c1:XXXX::1/48
80
81
ip link add dev wg0 type wireguard
82
83
# Replace with your range
84
ip addr add $MY_NET dev wg0
85
86 12 Nico Schottelius
# Add routing
87 14 Nico Schottelius
ip route add 2a0a:e5c1::/32 dev wg0
88 1 Nico Schottelius
ip route add ::/0 via 2a0a:e5c1:100::1
89
90 12 Nico Schottelius
# Configure the interface
91
wg setconf wg0 /etc/wireguard/wg0.conf
92 1 Nico Schottelius
93 12 Nico Schottelius
# Bring it up
94
ip link set wg0 up
95
</pre>
96
97 15 Nico Schottelius
h3. About usable IPv6 addresses
98 1 Nico Schottelius
99 15 Nico Schottelius
We route a /48 to everyone. Even though technically possible, you should not use the *zero address* of your network, as it is reserved for reaching all routers.
100
I.e. if your IPv6 network was 2a0a:e5c1:101::/48, don't use 2a0a:e5c1:101::. The reason for this is that all routers (devices that have ip forwarding enabled) for this network
101
are supposed to answer on this address.
102
103
In other words, in your wg0.conf use:
104
105
<pre>
106
[Interface]
107
...
108
Address = 2a0a:e5c1:101::42/48
109
</pre>
110
111
Do *NOT* use:
112
113
<pre>
114
[Interface]
115
...
116
# Don't use this
117
Address = 2a0a:e5c1:101::/48
118
</pre>
119
120
121 14 Nico Schottelius
h3. How to debug
122 1 Nico Schottelius
123 14 Nico Schottelius
* wg show # Show configuration
124
* ping 2a0a:e5c1:100::1 # Try to ping the gateway
125 15 Nico Schottelius
126 16 Nico Schottelius
If you want to send us your configuration, you should remove your private key from wg0.conf.
127
Under Linux/BSD/MacOS you can do that as follows:
128
129
<pre>
130
cat /etc/wireguard/wg0.conf  | sed 's/\(PrivateKey =\).*/\1 MYPRIVATEKEY/'
131
</pre>
132
133
The result could look as follows:
134
135
<pre>
136
root@line:~# cat /etc/wireguard/wg0.conf  | sed 's/\(PrivateKey =\).*/\1 MYPRIVATEKEY/'
137
[Interface]
138
PrivateKey = MYPRIVATEKEY
139
ListenPort = 51280
140
Address = 2a0a:e5c1:101::42/48
141
#DNS = 2a0a:e5c0::3, 2a0a:e5c0::4
142
143
[Peer]
144
PublicKey = hi60lGP+xEUQ+kVnqA7PlJAO1SVqTS1W36g0LhFP0xQ=
145
Endpoint = vpn-2a0ae5c1.ungleich.ch:51820
146
AllowedIPs = ::/0
147
</pre>
148
149 15 Nico Schottelius
150 6 Nico Schottelius
151
h3. Sample server configuration
152 1 Nico Schottelius
153 10 Nico Schottelius
This is just for reference - as a client you don't need this configuration
154
155 6 Nico Schottelius
/etc/wireguard/wg0.conf:
156
157
<pre>
158
[Interface]
159
ListenPort = 51820
160 7 Nico Schottelius
PrivateKey = SERVERKEYHERE
161 6 Nico Schottelius
162
# Nico, 2019-01-23
163
[Peer]
164
PublicKey = kL1S/Ipq6NkFf1MAsNRou4b9VoUsnnb4ZxgiBrH0zA8=
165
AllowedIPs = 2a0a:e5c1:101::/48
166
167
# Customer networks below
168
# ...
169
</pre>
170
171
Sample server rc.local:
172
173
<pre>
174
ip link add dev wg0 type wireguard
175
ip addr add 2a0a:e5c1:100::1/40 dev wg0
176
wg setconf wg0 /etc/wireguard/wg0.conf
177
ip link set wg0 up
178
179 1 Nico Schottelius
</pre>
180
181 20 Jin-Guk Kwon
h3. How to config wireguard on mobile phone(android / ios)
182
183
<pre>
184
You should fill out DNS field.
185 22 Jin-Guk Kwon
ex) for ipv6 DNS ==> 2a0a:e5c0::3 or 2a0a:e5c0::4
186 20 Jin-Guk Kwon
and you should assgin phone own IP.
187
ex) laptop Address = 2a0a:e5c1:101::42/48
188 21 Jin-Guk Kwon
    phone Address = 2a0a:e5c1:101::43/48
189
another things are same as client's configutaion.
190 20 Jin-Guk Kwon
</pre>
191
192 26 Jin-Guk Kwon
h3. How to config IPv6 DNS on wireguard(if it can't find DNS)
193 25 Jin-Guk Kwon
194
<pre>
195
You should fill out DNS field.
196 1 Nico Schottelius
ex) for ipv6 DNS ==> 2a0a:e5c0::3 or 2a0a:e5c0::4
197 26 Jin-Guk Kwon
DNS = 2a0a:e5c0::3
198 25 Jin-Guk Kwon
</pre>
199
200 1 Nico Schottelius
h2. OpenVPN on openvpn.ungleich.ch
201
202
* Server: openvpn.ungleich.ch
203
* Port: 1195
204
* Requires a certificate
205
* Address range: 2a0a:e5c0:3::/48
206
** Client networks are /64
207 17 Nico Schottelius
208 18 Nico Schottelius
*END OF LIFE by 2019-06-30*