accplan commited on
Commit
74d0f30
β€’
1 Parent(s): 9a0ab0f
Files changed (1) hide show
  1. README.md +10 -361
README.md CHANGED
@@ -1,361 +1,10 @@
1
- [English](README.md) | [δΈ­ζ–‡](README-zh.md)
2
-
3
- # IPsec VPN Server on Docker
4
-
5
- [![Build Status](https://github.com/hwdsl2/docker-ipsec-vpn-server/actions/workflows/main-alpine.yml/badge.svg)](https://github.com/hwdsl2/docker-ipsec-vpn-server/actions/workflows/main-alpine.yml) [![GitHub Stars](docs/images/badges/github-stars.svg)](https://github.com/hwdsl2/docker-ipsec-vpn-server/stargazers) [![Docker Stars](docs/images/badges/docker-stars.svg)](https://hub.docker.com/r/hwdsl2/ipsec-vpn-server/) [![Docker Pulls](docs/images/badges/docker-pulls.svg)](https://hub.docker.com/r/hwdsl2/ipsec-vpn-server/)
6
-
7
- Docker image to run an IPsec VPN server, with IPsec/L2TP, Cisco IPsec and IKEv2.
8
-
9
- Based on Alpine 3.17 or Debian 11 with [Libreswan](https://libreswan.org) (IPsec VPN software) and [xl2tpd](https://github.com/xelerance/xl2tpd) (L2TP daemon).
10
-
11
- An IPsec VPN encrypts your network traffic, so that nobody between you and the VPN server can eavesdrop on your data as it travels via the Internet. This is especially useful when using unsecured networks, e.g. at coffee shops, airports or hotel rooms.
12
-
13
- [**» See also: IPsec VPN Server Auto Setup Scripts**](https://github.com/hwdsl2/setup-ipsec-vpn)
14
-
15
- ## Quick start
16
-
17
- Use this command to set up an IPsec VPN server on Docker:
18
-
19
- ```
20
- docker run \
21
- --name ipsec-vpn-server \
22
- --restart=always \
23
- -v ikev2-vpn-data:/etc/ipsec.d \
24
- -v /lib/modules:/lib/modules:ro \
25
- -p 500:500/udp \
26
- -p 4500:4500/udp \
27
- -d --privileged \
28
- hwdsl2/ipsec-vpn-server
29
- ```
30
-
31
- Your VPN login details will be randomly generated. See [Retrieve VPN login details](#retrieve-vpn-login-details).
32
-
33
- To learn more about how to use this image, read the sections below.
34
-
35
- ## Features
36
-
37
- - Supports IKEv2 with strong and fast ciphers (e.g. AES-GCM)
38
- - Generates VPN profiles to auto-configure iOS, macOS and Android devices
39
- - Supports Windows, macOS, iOS, Android, Chrome OS and Linux as VPN clients
40
- - Includes a helper script to manage IKEv2 users and certificates
41
-
42
- ## Install Docker
43
-
44
- First, [install Docker](https://docs.docker.com/engine/install/) on your Linux server. You may also use [Podman](https://podman.io) to run this image, after [creating an alias](https://podman.io/whatis.html) for `docker`.
45
-
46
- Advanced users can use this image on macOS with [Docker for Mac](https://docs.docker.com/docker-for-mac/). Before using IPsec/L2TP mode, you may need to restart the Docker container once with `docker restart ipsec-vpn-server`. This image does not support Docker for Windows.
47
-
48
- ## Download
49
-
50
- Get the trusted build from the [Docker Hub registry](https://hub.docker.com/r/hwdsl2/ipsec-vpn-server/):
51
-
52
- ```
53
- docker pull hwdsl2/ipsec-vpn-server
54
- ```
55
-
56
- Alternatively, you may download from [Quay.io](https://quay.io/repository/hwdsl2/ipsec-vpn-server):
57
-
58
- ```
59
- docker pull quay.io/hwdsl2/ipsec-vpn-server
60
- docker image tag quay.io/hwdsl2/ipsec-vpn-server hwdsl2/ipsec-vpn-server
61
- ```
62
-
63
- Supported platforms: `linux/amd64`, `linux/arm64` and `linux/arm/v7`.
64
-
65
- Advanced users can [build from source code](docs/advanced-usage.md#build-from-source-code) on GitHub.
66
-
67
- ### Image comparison
68
-
69
- Two pre-built images are available. The default Alpine-based image is only ~17MB.
70
-
71
- | | Alpine-based | Debian-based |
72
- | ----------------- | ------------------------ | ------------------------------ |
73
- | Image name | hwdsl2/ipsec-vpn-server | hwdsl2/ipsec-vpn-server:debian |
74
- | Compressed size | ~ 17 MB | ~ 62 MB |
75
- | Base image | Alpine Linux 3.17 | Debian Linux 11 |
76
- | Platforms | amd64, arm64, arm/v7 | amd64, arm64, arm/v7 |
77
- | Libreswan version | 4.10 | 4.10 |
78
- | IPsec/L2TP | βœ… | βœ… |
79
- | Cisco IPsec | βœ… | βœ… |
80
- | IKEv2 | βœ… | βœ… |
81
-
82
- **Note:** To use the Debian-based image, replace every `hwdsl2/ipsec-vpn-server` with `hwdsl2/ipsec-vpn-server:debian` in this README. These images are not currently compatible with Synology NAS systems.
83
-
84
- ## How to use this image
85
-
86
- ### Environment variables
87
-
88
- **Note:** All the variables to this image are optional, which means you don't have to type in any variable, and you can have an IPsec VPN server out of the box! To do that, create an empty `env` file using `touch vpn.env`, and skip to the next section.
89
-
90
- This Docker image uses the following variables, that can be declared in an `env` file (see [example](vpn.env.example)):
91
-
92
- ```
93
- VPN_IPSEC_PSK=your_ipsec_pre_shared_key
94
- VPN_USER=your_vpn_username
95
- VPN_PASSWORD=your_vpn_password
96
- ```
97
-
98
- This will create a user account for VPN login, which can be used by your multiple devices[*](#important-notes). The IPsec PSK (pre-shared key) is specified by the `VPN_IPSEC_PSK` environment variable. The VPN username is defined in `VPN_USER`, and VPN password is specified by `VPN_PASSWORD`.
99
-
100
- Additional VPN users are supported, and can be optionally declared in your `env` file like this. Usernames and passwords must be separated by spaces, and usernames cannot contain duplicates. All VPN users will share the same IPsec PSK.
101
-
102
- ```
103
- VPN_ADDL_USERS=additional_username_1 additional_username_2
104
- VPN_ADDL_PASSWORDS=additional_password_1 additional_password_2
105
- ```
106
-
107
- **Note:** In your `env` file, DO NOT put `""` or `''` around values, or add space around `=`. DO NOT use these special characters within values: `\ " '`. A secure IPsec PSK should consist of at least 20 random characters.
108
-
109
- **Note:** If you modify the `env` file after the Docker container is already created, you must remove and re-create the container for the changes to take effect. Refer to [Update Docker image](#update-docker-image).
110
-
111
- <details>
112
- <summary>
113
- :information_source: You may optionally specify a DNS name, client name and/or custom DNS servers. :information_source:
114
- </summary>
115
-
116
- Advanced users can optionally specify a DNS name for the IKEv2 server address. The DNS name must be a fully qualified domain name (FQDN). Example:
117
-
118
- ```
119
- VPN_DNS_NAME=vpn.example.com
120
- ```
121
-
122
- You may specify a name for the first IKEv2 client. Use one word only, no special characters except `-` and `_`. The default is `vpnclient` if not specified.
123
-
124
- ```
125
- VPN_CLIENT_NAME=your_client_name
126
- ```
127
-
128
- By default, clients are set to use [Google Public DNS](https://developers.google.com/speed/public-dns/) when the VPN is active. You may specify custom DNS server(s) for all VPN modes. Example:
129
-
130
- ```
131
- VPN_DNS_SRV1=1.1.1.1
132
- VPN_DNS_SRV2=1.0.0.1
133
- ```
134
-
135
- By default, no password is required when importing IKEv2 client configuration. You can choose to protect client config files using a random password.
136
-
137
- ```
138
- VPN_PROTECT_CONFIG=yes
139
- ```
140
-
141
- **Note:** The variables above have no effect for IKEv2 mode, if IKEv2 is already set up in the Docker container. In this case, you may remove IKEv2 and set it up again using custom options. Refer to [Configure and use IKEv2 VPN](#configure-and-use-ikev2-vpn).
142
- </details>
143
-
144
- ### Start the IPsec VPN server
145
-
146
- Create a new Docker container from this image (replace `./vpn.env` with your own `env` file):
147
-
148
- ```
149
- docker run \
150
- --name ipsec-vpn-server \
151
- --env-file ./vpn.env \
152
- --restart=always \
153
- -v ikev2-vpn-data:/etc/ipsec.d \
154
- -v /lib/modules:/lib/modules:ro \
155
- -p 500:500/udp \
156
- -p 4500:4500/udp \
157
- -d --privileged \
158
- hwdsl2/ipsec-vpn-server
159
- ```
160
-
161
- In this command, we use the `-v` option of `docker run` to create a new [Docker volume](https://docs.docker.com/storage/volumes/) named `ikev2-vpn-data`, and mount it into `/etc/ipsec.d` in the container. IKEv2 related data such as certificates and keys will persist in the volume, and later when you need to re-create the Docker container, just specify the same volume again.
162
-
163
- It is recommended to enable IKEv2 when using this image. However, if you prefer not to enable IKEv2 and use only the IPsec/L2TP and IPsec/XAuth ("Cisco IPsec") modes to connect to the VPN, remove the first `-v` option from the `docker run` command above.
164
-
165
- **Note:** Advanced users can also [run without privileged mode](docs/advanced-usage.md#run-without-privileged-mode).
166
-
167
- ### Retrieve VPN login details
168
-
169
- If you did not specify an `env` file in the `docker run` command above, `VPN_USER` will default to `vpnuser` and both `VPN_IPSEC_PSK` and `VPN_PASSWORD` will be randomly generated. To retrieve them, view the container logs:
170
-
171
- ```
172
- docker logs ipsec-vpn-server
173
- ```
174
-
175
- Search for these lines in the output:
176
-
177
- ```
178
- Connect to your new VPN with these details:
179
-
180
- Server IP: your_vpn_server_ip
181
- IPsec PSK: your_ipsec_pre_shared_key
182
- Username: your_vpn_username
183
- Password: your_vpn_password
184
- ```
185
-
186
- The output will also include details for IKEv2 mode, if enabled.
187
-
188
- (Optional) Backup the generated VPN login details (if any) to the current directory:
189
-
190
- ```
191
- docker cp ipsec-vpn-server:/etc/ipsec.d/vpn-gen.env ./
192
- ```
193
-
194
- ## Next steps
195
-
196
- *Read this in other languages: [English](README.md#next-steps), [δΈ­ζ–‡](README-zh.md#δΈ‹δΈ€ζ­₯).*
197
-
198
- Get your computer or device to use the VPN. Please refer to:
199
-
200
- **[Configure and use IKEv2 VPN (recommended)](#configure-and-use-ikev2-vpn)**
201
-
202
- **[Configure IPsec/L2TP VPN Clients](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients.md)**
203
-
204
- **[Configure IPsec/XAuth ("Cisco IPsec") VPN Clients](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients-xauth.md)**
205
-
206
- **[:book: Book: Set Up Your Own IPsec VPN, OpenVPN and WireGuard Server](https://mybook.to/vpn)**
207
-
208
- Enjoy your very own VPN! :sparkles::tada::rocket::sparkles:
209
-
210
- Like this project? [:heart: Sponsor](https://github.com/sponsors/hwdsl2?metadata_o=d) or [:coffee: Support](https://ko-fi.com/hwdsl2) and access [extra content](https://ko-fi.com/post/Support-this-project-and-get-access-to-supporter-o-O5O7FVF8J).
211
-
212
- ## Important notes
213
-
214
- **Windows users**: For IPsec/L2TP mode, a [one-time registry change](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients.md#windows-error-809) is required if the VPN server or client is behind NAT (e.g. home router).
215
-
216
- The same VPN account can be used by your multiple devices. However, due to an IPsec/L2TP limitation, if you wish to connect multiple devices from behind the same NAT (e.g. home router), you must use [IKEv2](#configure-and-use-ikev2-vpn) or [IPsec/XAuth](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients-xauth.md) mode.
217
-
218
- If you wish to add, edit or remove VPN user accounts, first update your `env` file, then you must remove and re-create the Docker container using instructions from the [next section](#update-docker-image). Advanced users can [bind mount](docs/advanced-usage.md#bind-mount-the-env-file) the `env` file.
219
-
220
- For servers with an external firewall (e.g. [EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html)/[GCE](https://cloud.google.com/vpc/docs/firewalls)), open UDP ports 500 and 4500 for the VPN. Aliyun users, see [#433](https://github.com/hwdsl2/setup-ipsec-vpn/issues/433).
221
-
222
- Clients are set to use [Google Public DNS](https://developers.google.com/speed/public-dns/) when the VPN is active. If another DNS provider is preferred, read [this section](docs/advanced-usage.md#use-alternative-dns-servers).
223
-
224
- ## Update Docker image
225
-
226
- To update the Docker image and container, first [download](#download) the latest version:
227
-
228
- ```
229
- docker pull hwdsl2/ipsec-vpn-server
230
- ```
231
-
232
- If the Docker image is already up to date, you should see:
233
-
234
- ```
235
- Status: Image is up to date for hwdsl2/ipsec-vpn-server:latest
236
- ```
237
-
238
- Otherwise, it will download the latest version. To update your Docker container, first write down all your [VPN login details](#retrieve-vpn-login-details). Then remove the Docker container with `docker rm -f ipsec-vpn-server`. Finally, re-create it using instructions from [How to use this image](#how-to-use-this-image).
239
-
240
- ## Configure and use IKEv2 VPN
241
-
242
- IKEv2 mode has improvements over IPsec/L2TP and IPsec/XAuth ("Cisco IPsec"), and does not require an IPsec PSK, username or password. Read more [here](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/ikev2-howto.md).
243
-
244
- First, check container logs to view details for IKEv2:
245
-
246
- ```bash
247
- docker logs ipsec-vpn-server
248
- ```
249
-
250
- **Note:** If you cannot find IKEv2 details, IKEv2 may not be enabled in the container. Try updating the Docker image and container using instructions from the [Update Docker image](#update-docker-image) section.
251
-
252
- During IKEv2 setup, an IKEv2 client (with default name `vpnclient`) is created, with its configuration exported to `/etc/ipsec.d` **inside the container**. To copy config file(s) to the Docker host:
253
-
254
- ```bash
255
- # Check contents of /etc/ipsec.d in the container
256
- docker exec -it ipsec-vpn-server ls -l /etc/ipsec.d
257
- # Example: Copy a client config file from the container
258
- # to the current directory on the Docker host
259
- docker cp ipsec-vpn-server:/etc/ipsec.d/vpnclient.p12 ./
260
- ```
261
-
262
- **Next steps:** [Configure your devices](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/ikev2-howto.md) to use the IKEv2 VPN.
263
-
264
- <details>
265
- <summary>
266
- Learn how to manage IKEv2 clients.
267
- </summary>
268
-
269
- You can manage IKEv2 clients using the helper script. See examples below. To customize client options, run the script without arguments.
270
-
271
- ```bash
272
- # Add a new client (using default options)
273
- docker exec -it ipsec-vpn-server ikev2.sh --addclient [client name]
274
- # Export configuration for an existing client
275
- docker exec -it ipsec-vpn-server ikev2.sh --exportclient [client name]
276
- # List existing clients
277
- docker exec -it ipsec-vpn-server ikev2.sh --listclients
278
- # Show usage
279
- docker exec -it ipsec-vpn-server ikev2.sh -h
280
- ```
281
-
282
- **Note:** If you encounter error "executable file not found", replace `ikev2.sh` above with `/opt/src/ikev2.sh`.
283
- </details>
284
- <details>
285
- <summary>
286
- Learn how to change the IKEv2 server address.
287
- </summary>
288
-
289
- In certain circumstances, you may need to change the IKEv2 server address. For example, to switch to use a DNS name, or after server IP changes. To change the IKEv2 server address, first [open a bash shell inside the container](docs/advanced-usage.md#bash-shell-inside-container), then [follow these instructions](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/ikev2-howto.md#change-ikev2-server-address). Note that the container logs will not show the new IKEv2 server address until you restart the Docker container.
290
- </details>
291
- <details>
292
- <summary>
293
- Remove IKEv2 and set it up again using custom options.
294
- </summary>
295
-
296
- In certain circumstances, you may need to remove IKEv2 and set it up again using custom options.
297
-
298
- **Warning:** All IKEv2 configuration including certificates and keys will be **permanently deleted**. This **cannot be undone**!
299
-
300
- **Option 1:** Remove IKEv2 and set it up again using the helper script.
301
-
302
- Note that this will override variables you specified in the `env` file, such as `VPN_DNS_NAME` and `VPN_CLIENT_NAME`, and the container logs will no longer show up-to-date information for IKEv2.
303
-
304
- ```bash
305
- # Remove IKEv2 and delete all IKEv2 configuration
306
- docker exec -it ipsec-vpn-server ikev2.sh --removeikev2
307
- # Set up IKEv2 again using custom options
308
- docker exec -it ipsec-vpn-server ikev2.sh
309
- ```
310
-
311
- **Option 2:** Remove `ikev2-vpn-data` and re-create the container.
312
-
313
- 1. Write down all your [VPN login details](#retrieve-vpn-login-details).
314
- 1. Remove the Docker container: `docker rm -f ipsec-vpn-server`.
315
- 1. Remove the `ikev2-vpn-data` volume: `docker volume rm ikev2-vpn-data`.
316
- 1. Update your `env` file and add custom IKEv2 options such as `VPN_DNS_NAME` and `VPN_CLIENT_NAME`, then re-create the container. Refer to [How to use this image](#how-to-use-this-image).
317
- </details>
318
-
319
- ## Advanced usage
320
-
321
- See [Advanced usage](docs/advanced-usage.md).
322
-
323
- - [Use alternative DNS servers](docs/advanced-usage.md#use-alternative-dns-servers)
324
- - [Run without privileged mode](docs/advanced-usage.md#run-without-privileged-mode)
325
- - [Select VPN modes](docs/advanced-usage.md#select-vpn-modes)
326
- - [Access other containers on the Docker host](docs/advanced-usage.md#access-other-containers-on-the-docker-host)
327
- - [Specify VPN server's public IP](docs/advanced-usage.md#specify-vpn-servers-public-ip)
328
- - [Assign static IPs to VPN clients](docs/advanced-usage.md#assign-static-ips-to-vpn-clients)
329
- - [Customize VPN subnets](docs/advanced-usage.md#customize-vpn-subnets)
330
- - [About host network mode](docs/advanced-usage.md#about-host-network-mode)
331
- - [Enable Libreswan logs](docs/advanced-usage.md#enable-libreswan-logs)
332
- - [Check server status](docs/advanced-usage.md#check-server-status)
333
- - [Build from source code](docs/advanced-usage.md#build-from-source-code)
334
- - [Bash shell inside container](docs/advanced-usage.md#bash-shell-inside-container)
335
- - [Bind mount the env file](docs/advanced-usage.md#bind-mount-the-env-file)
336
- - [Deploy Google BBR congestion control](docs/advanced-usage.md#deploy-google-bbr-congestion-control)
337
-
338
- ## Technical details
339
-
340
- There are two services running: `Libreswan (pluto)` for the IPsec VPN, and `xl2tpd` for L2TP support.
341
-
342
- The default IPsec configuration supports:
343
-
344
- * IPsec/L2TP with PSK
345
- * IKEv1 with PSK and XAuth ("Cisco IPsec")
346
- * IKEv2
347
-
348
- The ports that are exposed for this container to work are:
349
-
350
- * 4500/udp and 500/udp for IPsec
351
-
352
- ## License
353
-
354
- **Note:** The software components inside the pre-built image (such as Libreswan and xl2tpd) are under the respective licenses chosen by their respective copyright holders. As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
355
-
356
- Copyright (C) 2016-2023 [Lin Song](https://github.com/hwdsl2) [![View my profile on LinkedIn](https://static.licdn.com/scds/common/u/img/webpromo/btn_viewmy_160x25.png)](https://www.linkedin.com/in/linsongui)
357
- Based on [the work of Thomas Sarlandie](https://github.com/sarfata/voodooprivacy) (Copyright 2012)
358
-
359
- [![Creative Commons License](https://i.creativecommons.org/l/by-sa/3.0/88x31.png)](http://creativecommons.org/licenses/by-sa/3.0/)
360
- This work is licensed under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/)
361
- Attribution required: please include my name in any derivative and let me know how you have improved it!
 
1
+ ---
2
+ title: testx
3
+ emoji: πŸ’»
4
+ colorFrom: gray
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 3.17.0
8
+ pinned: false
9
+ license: apache-2.0
10
+ ---