Project

General

Profile

Ungleich IPv6 wireguard VPN » History » Version 11

Jin-Guk Kwon, 03/04/2024 06:07 AM

1 1 Timothée Floure
h1. Ungleich IPv6 wireguard VPN
2
3
{{toc}}
4
5 5 Timothée Floure
*%{color:green}This document only concerns VPN clients and is intended for end-users/customers. See [[The ungleich VPN infrastructure]] page for server-side documentation.%*
6 1 Timothée Floure
7
h2. Status
8
9
This document is *IN PRODUCTION*.
10
11
h2. How to get VPN
12
13
* If you are a VM users of DataCenterLight, you get it for free
14
* Otherwise you can book it at https://IPv6VPN.ch
15
* In both cases, send a request to support at ungleich.ch
16
17
Technically, the following steps are necessary:
18
19
<pre>
20
1. Install Wireguard
21
 https://www.wireguard.com/install/
22
23
2. Create your private key:
24
 umask 077; wg genkey > privkey
25
26
3. Get your public key
27
  wg pubkey < privkey
28
29
4. Send us the pubkey
30
</pre>
31
32
If you want to be fast, you can already take these steps before contacting support.
33
34
35
h2. Security of IPv6 vs. NAT
36
37
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.
38
39 3 Timothée Floure
h2. Proxy all traffic (IPv6 + NAT64 for IPv4) via the VPN
40 2 Timothée Floure
41
It is possible to forward (almost) all traffic to the ungleich VPN by using our DNS64 resolvers. You can do so by configuring 2a0a:e5c0:2:12:0:f0ff:fea9:c451 (unbound1.place6.ungleich.ch) and 2a0a:e5c0:2:12:0:f0ff:fea9:c45d (unbound2.place6.ungleich.ch) as DNS servers when connected to the VPN.
42
43
It will:
44
45
* Use those two servers (via the VPN) for "DNS":https://en.wikipedia.org/wiki/Domain_Name_System traffic.
46
* Route all traffic to domain names (resolved by any of the two DNS servers) via the VPN.
47
48
It won't:
49
50
* Route traffic to specific IP addresses (= bypassing DNS) via the VPN.
51 6 Nico Schottelius
* Route traffic from application using their own DNS resolving system (e.g. Firefox with DNS-over-HTTPS enabled)
52
* Route IPv4 traffic
53 2 Timothée Floure
54 4 Timothée Floure
*Complete isolation* can be achieved using network namespaces, as "described on wireguard's documentation":https://www.wireguard.com/netns/#the-new-namespace-solution.
55
56 2 Timothée Floure
h3. Setup instruction
57 1 Timothée Floure
58 3 Timothée Floure
It's dead-simple! You only have to add the following lines to the @[Interface]@ section (just below (@ListenPort = 51280@) of your wireguard configuration:
59
60 11 Jin-Guk Kwon
old
61 3 Timothée Floure
<pre>
62
DNS = 2a0a:e5c0:2:12:0:f0ff:fea9:c451
63
DNS = 2a0a:e5c0:2:12:0:f0ff:fea9:c45d
64 11 Jin-Guk Kwon
</pre>
65
66
new
67
<pre>
68
DNS = 2a0a:e5c0:2:a::a 
69
DNS = 2a0a:e5c0:2:a::b
70 3 Timothée Floure
</pre>
71 2 Timothée Floure
72 1 Timothée Floure
h2. Wireguard VPN on vpn-2a0ae5c1.ungleich.ch
73
74
* Server: vpn-2a0ae5c1.ungleich.ch
75
* Port: 51820
76
* Requires a public key
77
* Client network: 2a0a:e5c1:100::/40
78
* Client network size: /48
79
80
h3. Sample clustomer client configuration
81
82
* "Install wireguard":https://www.wireguard.com/install/
83
* Create your private key: @umask 077; wg genkey > privkey@
84
* Get your public key: @wg pubkey < privkey@
85
** You need to send this pubkey to ungleich
86
* You will get your network definition after we have received your public key
87
* Create /etc/wireguard/wg0.conf
88
89
<pre>
90
[Interface]
91
PrivateKey = YOURKEYHERE
92
Address = YOURIPv6IPADDRESSHERE/48
93 10 Nico Schottelius
ListenPort = 51820
94 1 Timothée Floure
95
[Peer]
96
PublicKey = hi60lGP+xEUQ+kVnqA7PlJAO1SVqTS1W36g0LhFP0xQ=
97
Endpoint = vpn-2a0ae5c1.ungleich.ch:51820
98
AllowedIPs = ::/0
99
</pre>
100
101
* *ONLY change* the PrivateKey and the Address entries.
102
* *ALL other entries* (especially PublicKey, Endpoint and AllowedIPs) need to *stay as is*
103
104
h3. How to setup the VPN (the easy way)
105
106
Once you have created the configuration, you can simply call
107
108
<pre>
109
wg-quick up wg0
110
</pre>
111
112
And to stop the VPN, you can use
113
114
<pre>
115
wg-quick down wg0
116
</pre>
117
118
119
h3. How to setup the VPN (the manual way)
120
121
122
Commands for setting it up
123
124
<pre>
125
MY_NET=2a0a:e5c1:XXXX::1/48
126
127
ip link add dev wg0 type wireguard
128
129
# Replace with your range
130
ip addr add $MY_NET dev wg0
131
132
# Add routing
133
ip route add 2a0a:e5c1::/32 dev wg0
134
ip route add ::/0 via 2a0a:e5c1:100::1
135
136
# Configure the interface
137
wg setconf wg0 /etc/wireguard/wg0.conf
138
139
# Bring it up
140
ip link set wg0 up
141
</pre>
142
143
h3. About usable IPv6 addresses
144
145
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.
146
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
147
are supposed to answer on this address.
148
149
In other words, in your wg0.conf use:
150
151
<pre>
152
[Interface]
153
...
154
Address = 2a0a:e5c1:101::42/48
155
</pre>
156
157
Do *NOT* use:
158
159
<pre>
160
[Interface]
161
...
162
# Don't use this
163
Address = 2a0a:e5c1:101::/48
164
</pre>
165
166
167
h3. How to debug
168
169
* wg show # Show configuration
170
* ping 2a0a:e5c1:100::1 # Try to ping the gateway
171
172
If you want to send us your configuration, you should remove your private key from wg0.conf.
173
Under Linux/BSD/MacOS you can do that as follows:
174
175
<pre>
176
cat /etc/wireguard/wg0.conf  | sed 's/\(PrivateKey =\).*/\1 MYPRIVATEKEY/'
177
</pre>
178
179
The result could look as follows:
180
181
<pre>
182
root@line:~# cat /etc/wireguard/wg0.conf  | sed 's/\(PrivateKey =\).*/\1 MYPRIVATEKEY/'
183
[Interface]
184
PrivateKey = MYPRIVATEKEY
185
ListenPort = 51280
186
Address = 2a0a:e5c1:101::42/48
187
#DNS = 2a0a:e5c0::3, 2a0a:e5c0::4
188
189
[Peer]
190
PublicKey = hi60lGP+xEUQ+kVnqA7PlJAO1SVqTS1W36g0LhFP0xQ=
191
Endpoint = vpn-2a0ae5c1.ungleich.ch:51820
192
AllowedIPs = ::/0
193
</pre>
194
195
h3. How to config wireguard on mobile phone(android / ios)
196
197
<pre>
198
You should fill out DNS field.
199
ex) for ipv6 DNS ==> 2a0a:e5c0::3 or 2a0a:e5c0::4
200
and you should assgin phone own IP.
201
ex) laptop Address = 2a0a:e5c1:101::42/48
202
    phone Address = 2a0a:e5c1:101::43/48
203
another things are same as client's configutaion.
204
</pre>
205
206
h3. How to config IPv6 DNS on wireguard(if it can't find DNS)
207
208
<pre>
209
You should fill out DNS field.
210 7 Jin-Guk Kwon
ex) for ipv6 DNS ==> 2a0a:e5c0:2:12:0:f0ff:fea9:c451 or 2a0a:e5c0:2:12:0:f0ff:fea9:c45d
211
DNS = 2a0a:e5c0:2:12:0:f0ff:fea9:c451
212 1 Timothée Floure
</pre>
213
214
h3. How to config wireguard manually on Mac OS without APP(for using IPv4 and IPv6 at the same time) 
215
216
<pre>
217
1) install wireguard on macOS
218
- brew install wireguard-tools
219
220
2)find wireguard install location
221
- cd /usr/local/etc/wireguard
222
223
3) create wg0.conf in wireguard location(refer to above)
224
225
4) run wireguard
226
- wg-quick up  wg0
227
</pre>
228
229 8 Nico Schottelius
h2. ungleich VPN types and configuration
230
231
This guide is for internal handling, but also publicly available to allow knowledge sharing.
232
233
h3. Type 1, classic IPv6-VPN
234
235
* We route a /48 into the tunnel, the pool is usually a /40 or bigger
236
* Most VPN servers at ungleich operate like this
237
238
Pro/Con:
239
240
* Very easy setup
241
* Not much knowledge required
242
* Single stack
243
244
h3. Type 2, IPv6-VPN with mapped IPv4
245
246
* We route a /48 into the tunnel, the pool is usually a /40 or bigger
247
* Additionally IPv4 connectivity is provided via NAT64
248
** One or more IPv6 addresses are mapped to IPv4 addresses
249
** The client devices see IPv6 traffic
250
* Outgoing IPv4 mapping can be achieved, if the correct NAT64 network is targetted
251
** Can be configured using DNS64
252
253
Pro/Con:
254
255
* More tailored to clean IPv6 environments
256
* Target networks stay IPv6 only
257
* Needs more knowledge from operator
258
* Needs additional configuration on ungleich side
259
* Port forwarding setups on the router are non-trivial
260
** Needs NAT64 on the router if IPv4 devices should be targetted
261
262
263
h3. Type 3, IPv4 only VPN
264
265
* We route 1 (or more) IPv4 addresses into the tunnel
266
267
Pro/Con:
268
269
* The client can configure port forwarding
270
* No support for new technology/IPv6
271 9 Nico Schottelius
* Solves IPv4 only use cases trivially
272
273
h3. Type 4, IPv6-VPN with native IPv4
274
275
* We route a /48 into the tunnel, the pool is usually a /40 or bigger
276
* We route 1 (or more) IPv4 addresses into the tunnel
277
278
Pro/Con:
279
280
* The client can configure port forwarding
281
* Support for new technology/IPv6 automatically
282
* Solves IPv4 only use cases trivially
283
284 8 Nico Schottelius
285
286 1 Timothée Floure
h2. OpenVPN on openvpn.ungleich.ch
287
288
* Server: openvpn.ungleich.ch
289
* Port: 1195
290
* Requires a certificate
291
* Address range: 2a0a:e5c0:3::/48
292
** Client networks are /64
293
294
*END OF LIFE by 2019-06-30*