2016-09-02 06:23:56 +02:00
|
|
|
OpenVPN
|
2015-09-01 03:53:21 +02:00
|
|
|
=======
|
|
|
|
|
2016-07-11 07:57:48 +02:00
|
|
|
[OpenVPN][1] is blocked in China. You need to connect vpn via secure tunnel.
|
2015-09-01 03:53:21 +02:00
|
|
|
|
2016-09-03 07:54:20 +02:00
|
|
|
Instead of using [fteproxy][2] as bridge, you can also use [stunnel][3] or [kcptun][4].
|
2015-09-01 03:53:21 +02:00
|
|
|
|
2016-05-01 03:06:20 +02:00
|
|
|
- server: vpn.easypi.info
|
|
|
|
- bridge: bridge.easypi.info
|
2015-09-01 03:53:21 +02:00
|
|
|
- client: localhost
|
|
|
|
|
|
|
|
## docker-compose.yml (server)
|
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
```yaml
|
|
|
|
openvpn:
|
2016-09-19 07:04:07 +02:00
|
|
|
image: kylemanna/openvpn
|
2016-09-02 06:23:56 +02:00
|
|
|
ports:
|
|
|
|
- "1194:1194"
|
|
|
|
volumes:
|
|
|
|
- ./data:/etc/openvpn
|
2015-09-01 03:53:21 +02:00
|
|
|
cap_add:
|
|
|
|
- NET_ADMIN
|
|
|
|
restart: always
|
|
|
|
|
|
|
|
fteproxy:
|
|
|
|
image: vimagick/fteproxy
|
|
|
|
ports:
|
|
|
|
- "4911:4911"
|
|
|
|
links:
|
2016-09-02 06:23:56 +02:00
|
|
|
- openvpn
|
2015-09-01 03:53:21 +02:00
|
|
|
environment:
|
2016-09-02 06:23:56 +02:00
|
|
|
- MODE=server
|
|
|
|
- SERVER_IP=0.0.0.0
|
|
|
|
- SERVER_PORT=4911
|
|
|
|
- PROXY_IP=openvpn
|
|
|
|
- PROXY_PORT=1194
|
|
|
|
- KEY=CB2FBA2BC70490526E749E01BB050F6B555964290DFF58CF24785B4A093F7B18
|
2015-09-01 03:53:21 +02:00
|
|
|
restart: always
|
|
|
|
```
|
|
|
|
|
|
|
|
## docker-compose.yml (bridge)
|
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
```yaml
|
2015-09-01 03:53:21 +02:00
|
|
|
fteproxy:
|
|
|
|
image: vimagick/fteproxy
|
|
|
|
ports:
|
|
|
|
- "1194:1194"
|
|
|
|
environment:
|
2016-09-02 06:23:56 +02:00
|
|
|
- MODE=client
|
2018-03-15 12:10:45 +02:00
|
|
|
- SERVER_IP=vpn.easypi.pro
|
2016-09-02 06:23:56 +02:00
|
|
|
- SERVER_PORT=4911
|
|
|
|
- CLIENT_IP=0.0.0.0
|
|
|
|
- CLIENT_PORT=1194
|
|
|
|
- KEY=CB2FBA2BC70490526E749E01BB050F6B555964290DFF58CF24785B4A093F7B18
|
2015-09-01 03:53:21 +02:00
|
|
|
restart: always
|
|
|
|
```
|
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
## Server Setup
|
2015-09-01 03:53:21 +02:00
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
```bash
|
2015-09-01 03:53:21 +02:00
|
|
|
$ ./setup.sh
|
2016-09-02 06:23:56 +02:00
|
|
|
1) server ...... (Step 1)
|
|
|
|
2) client ...... (Step 2)
|
2015-09-01 05:00:28 +02:00
|
|
|
3) revoke
|
2016-09-02 06:23:56 +02:00
|
|
|
4) quit ...... (Step 3)
|
2015-09-01 03:53:21 +02:00
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
$ docker-compose up -d
|
2015-09-01 03:53:21 +02:00
|
|
|
```
|
|
|
|
|
2018-03-15 12:10:45 +02:00
|
|
|
Some Advanced Config
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ cat ./data/openvpn.conf
|
|
|
|
...
|
|
|
|
### Push Configurations Below
|
|
|
|
push "route 114.114.114.114 255.255.255.255 net_gateway"
|
|
|
|
push "route 192.168.0.0 255.255.0.0 net_gateway"
|
|
|
|
push "route 172.16.0.0 255.240.0.0 net_gateway"
|
|
|
|
push "route 10.0.0.0 255.0.0.0 net_gateway"
|
|
|
|
|
|
|
|
$ docker-compose restart
|
|
|
|
```
|
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
## Bridge Setup
|
2015-09-01 03:53:21 +02:00
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
```bash
|
|
|
|
$ docker-compose up -d
|
2015-09-01 03:53:21 +02:00
|
|
|
```
|
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
## Client Setup
|
2015-09-01 03:53:21 +02:00
|
|
|
|
2016-09-02 06:23:56 +02:00
|
|
|
```bash
|
2015-09-01 03:53:21 +02:00
|
|
|
$ cat /etc/openvpn/client.conf
|
|
|
|
...
|
2016-05-01 03:06:20 +02:00
|
|
|
remote bridge.easypi.info 1194 tcp
|
2017-09-02 07:57:01 +02:00
|
|
|
route 192.168.0.0 255.255.0.0 net_gateway
|
|
|
|
route 172.16.0.0 255.240.0.0 net_gateway
|
|
|
|
route 10.0.0.0 255.0.0.0 net_gateway
|
2015-09-01 03:53:21 +02:00
|
|
|
...
|
|
|
|
$ systemctl start openvpn@client
|
|
|
|
$ systemctl enable openvpn@client
|
|
|
|
```
|
2016-07-11 07:57:48 +02:00
|
|
|
|
|
|
|
## References
|
|
|
|
|
|
|
|
- <https://community.openvpn.net/openvpn/wiki>
|
|
|
|
- <https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-16-04>
|
|
|
|
|
|
|
|
[1]: https://openvpn.net/index.php/open-source.html
|
|
|
|
[2]: https://github.com/vimagick/dockerfiles/tree/master/fteproxy
|
|
|
|
[3]: https://github.com/vimagick/dockerfiles/tree/master/stunnel
|
2016-09-04 08:18:52 +02:00
|
|
|
[4]: https://github.com/vimagick/dockerfiles/tree/master/kcptun
|