The ungleich VPN infrastructure » History » Version 15
Nico Schottelius, 02/16/2019 12:33 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 | This document is *IN PRODUCTION*. |
||
8 | |||
9 | 13 | Nico Schottelius | h2. Security of IPv6 vs. NAT |
10 | |||
11 | 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. |
||
12 | |||
13 | 14 | Nico Schottelius | h2. Wireguard VPN on vpn-2a0ae5c1.ungleich.ch |
14 | 1 | Nico Schottelius | |
15 | * Server: vpn-2a0ae5c1.ungleich.ch |
||
16 | * Port: 51820 |
||
17 | * Requires a public key |
||
18 | 7 | Nico Schottelius | * Client network: 2a0a:e5c1:100::/40 |
19 | 1 | Nico Schottelius | * Client network size: /48 |
20 | |||
21 | 9 | Nico Schottelius | h3. How to add a new customer connection |
22 | 1 | Nico Schottelius | |
23 | 9 | Nico Schottelius | * Get the public key of the customer |
24 | * Edit dot-cdist/type/__ungleich_wireguard/manifest and add the new network definition at the end of the file |
||
25 | * Let the customer know their network |
||
26 | 1 | Nico Schottelius | |
27 | 9 | Nico Schottelius | h3. Sample clustomer client configuration |
28 | |||
29 | * "Install wireguard":https://www.wireguard.com/install/ |
||
30 | * Create your private key: @umask 077; wg genkey > privkey@ |
||
31 | * Get your public key: @wg pubkey < privkey@ |
||
32 | ** You need to send this pubkey to ungleich |
||
33 | * You will get your network definition after we have received your public key |
||
34 | * Create /etc/wireguard/wg0.conf |
||
35 | |||
36 | 1 | Nico Schottelius | <pre> |
37 | [Interface] |
||
38 | PrivateKey = YOURKEYHERE |
||
39 | 12 | Nico Schottelius | Address = YOURIPv6IPADDRESSHERE/48 |
40 | 1 | Nico Schottelius | ListenPort = 51280 |
41 | |||
42 | [Peer] |
||
43 | 9 | Nico Schottelius | PublicKey = hi60lGP+xEUQ+kVnqA7PlJAO1SVqTS1W36g0LhFP0xQ= |
44 | 1 | Nico Schottelius | Endpoint = vpn-2a0ae5c1.ungleich.ch:51820 |
45 | AllowedIPs = ::/0 |
||
46 | </pre> |
||
47 | |||
48 | 14 | Nico Schottelius | h3. How to setup the VPN (the easy way) |
49 | |||
50 | Once you have created the configuration, you can simply call |
||
51 | |||
52 | <pre> |
||
53 | wg-quick up wg0 |
||
54 | </pre> |
||
55 | |||
56 | And to stop the VPN, you can use |
||
57 | |||
58 | <pre> |
||
59 | wg-quick down wg0 |
||
60 | </pre> |
||
61 | |||
62 | |||
63 | h3. How to setup the VPN (the manual way) |
||
64 | |||
65 | |||
66 | 1 | Nico Schottelius | Commands for setting it up |
67 | |||
68 | <pre> |
||
69 | MY_NET=2a0a:e5c1:XXXX::1/48 |
||
70 | |||
71 | ip link add dev wg0 type wireguard |
||
72 | |||
73 | # Replace with your range |
||
74 | ip addr add $MY_NET dev wg0 |
||
75 | |||
76 | 12 | Nico Schottelius | # Add routing |
77 | 14 | Nico Schottelius | ip route add 2a0a:e5c1::/32 dev wg0 |
78 | 1 | Nico Schottelius | ip route add ::/0 via 2a0a:e5c1:100::1 |
79 | |||
80 | 12 | Nico Schottelius | # Configure the interface |
81 | wg setconf wg0 /etc/wireguard/wg0.conf |
||
82 | 1 | Nico Schottelius | |
83 | 12 | Nico Schottelius | # Bring it up |
84 | ip link set wg0 up |
||
85 | </pre> |
||
86 | |||
87 | 15 | Nico Schottelius | h3. About usable IPv6 addresses |
88 | 1 | Nico Schottelius | |
89 | 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. |
90 | 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 |
||
91 | are supposed to answer on this address. |
||
92 | |||
93 | In other words, in your wg0.conf use: |
||
94 | |||
95 | <pre> |
||
96 | [Interface] |
||
97 | ... |
||
98 | Address = 2a0a:e5c1:101::42/48 |
||
99 | </pre> |
||
100 | |||
101 | Do *NOT* use: |
||
102 | |||
103 | <pre> |
||
104 | [Interface] |
||
105 | ... |
||
106 | # Don't use this |
||
107 | Address = 2a0a:e5c1:101::/48 |
||
108 | </pre> |
||
109 | |||
110 | |||
111 | 14 | Nico Schottelius | h3. How to debug |
112 | 1 | Nico Schottelius | |
113 | 14 | Nico Schottelius | * wg show # Show configuration |
114 | * ping 2a0a:e5c1:100::1 # Try to ping the gateway |
||
115 | 15 | Nico Schottelius | |
116 | |||
117 | 6 | Nico Schottelius | |
118 | h3. Sample server configuration |
||
119 | 1 | Nico Schottelius | |
120 | 10 | Nico Schottelius | This is just for reference - as a client you don't need this configuration |
121 | |||
122 | 6 | Nico Schottelius | /etc/wireguard/wg0.conf: |
123 | |||
124 | <pre> |
||
125 | [Interface] |
||
126 | ListenPort = 51820 |
||
127 | 7 | Nico Schottelius | PrivateKey = SERVERKEYHERE |
128 | 6 | Nico Schottelius | |
129 | # Nico, 2019-01-23 |
||
130 | [Peer] |
||
131 | PublicKey = kL1S/Ipq6NkFf1MAsNRou4b9VoUsnnb4ZxgiBrH0zA8= |
||
132 | AllowedIPs = 2a0a:e5c1:101::/48 |
||
133 | |||
134 | # Customer networks below |
||
135 | # ... |
||
136 | </pre> |
||
137 | |||
138 | Sample server rc.local: |
||
139 | |||
140 | <pre> |
||
141 | ip link add dev wg0 type wireguard |
||
142 | ip addr add 2a0a:e5c1:100::1/40 dev wg0 |
||
143 | wg setconf wg0 /etc/wireguard/wg0.conf |
||
144 | ip link set wg0 up |
||
145 | |||
146 | 1 | Nico Schottelius | </pre> |
147 | |||
148 | h2. OpenVPN on openvpn.ungleich.ch |
||
149 | |||
150 | * Server: openvpn.ungleich.ch |
||
151 | * Port: 1195 |
||
152 | * Requires a certificate |
||
153 | * Address range: 2a0a:e5c0:3::/48 |
||
154 | ** Client networks are /64 |