Wiki source code of Use Wireguard VPN in Dragino Gateways
Version 11.1 by Edwin Chen on 2023/11/10 20:34
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | (% class="wikigeneratedid" %) | ||
2 | **Table of Contents:** | ||
3 | |||
4 | {{toc/}} | ||
5 | |||
6 | |||
7 | |||
8 | |||
9 | = 1. What is Wireguard VPN? = | ||
10 | |||
11 | [[WireGuard>>https://www.wireguard.com/]]^^®^^ is an extremely simple yet fast and modern VPN that utilizes **state-of-the-art [[cryptography>>url:https://www.wireguard.com/protocol/]]**. It aims to be [[faster>>url:https://www.wireguard.com/performance/]], [[simpler>>url:https://www.wireguard.com/quickstart/]], leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN. WireGuard is designed as a general purpose VPN for running on embedded interfaces and super computers alike, fit for many different circumstances. Initially released for the Linux kernel, it is now cross-platform (Windows, macOS, BSD, iOS, Android) and widely deployable. It is currently under heavy development, but already it might be regarded as the most secure, easiest to use, and simplest VPN solution in the industry. | ||
12 | |||
13 | |||
14 | = 2. Run WireGuard VPN in PC = | ||
15 | |||
16 | |||
17 | = 3. Configure Wireguard VPN on Gatewaythe LPS8N/DLOS8N/LG308N = | ||
18 | |||
19 | |||
20 | == 3.1 For LPS8N/DLOS8N/LG308N == | ||
21 | |||
22 | Due to the size of Wireguard packages. We didn't add it as a default feature of gateways. If the user wants to use Wireguard Please upgrade your gateway firmware with the special [[firmware>>https://www.dragino.com/downloads/index.php?dir=LoRa_Gateway/DLOS8/Firmware/Wireguard-firmware/]]. | ||
23 | |||
24 | |||
25 | === 3.1.1 Configuration via command line === | ||
26 | |||
27 | ==== 3.1.1.1 Key Management ==== | ||
28 | |||
29 | |||
30 | **#Generate keys** | ||
31 | |||
32 | (% class="box infomessage" %) | ||
33 | ((( | ||
34 | umask go= | ||
35 | |||
36 | wg genkey | tee wgserver.key | wg pubkey > wgserver.pub | ||
37 | |||
38 | wg genkey | tee wgclient.key | wg pubkey > wgclient.pub | ||
39 | |||
40 | wg genpsk > wgclient.psk | ||
41 | ))) | ||
42 | |||
43 | [[image:image-20231110150147-1.png||height="82" width="566"]] | ||
44 | |||
45 | |||
46 | ==== 3.1.1.2 Firewall configuration ==== | ||
47 | |||
48 | |||
49 | ((( | ||
50 | **#Configure firewall** | ||
51 | ))) | ||
52 | |||
53 | (% class="box infomessage" %) | ||
54 | ((( | ||
55 | uci del_list firewall.wan.network="vpn" | ||
56 | |||
57 | uci add_list firewall.wan.network="vpn" | ||
58 | |||
59 | uci commit firewall | ||
60 | ))) | ||
61 | |||
62 | [[image:image-20231110151524-2.png]] | ||
63 | |||
64 | |||
65 | ((( | ||
66 | **#Reload firewall** | ||
67 | ))) | ||
68 | |||
69 | (% class="box infomessage" %) | ||
70 | ((( | ||
71 | /etc/init.d/firewall | ||
72 | ))) | ||
73 | |||
74 | |||
75 | ==== 3.1.1.3 Network configuration ==== | ||
76 | |||
77 | |||
78 | ((( | ||
79 | **#Configure network** | ||
80 | ))) | ||
81 | |||
82 | (% class="box infomessage" %) | ||
83 | ((( | ||
84 | uci -q delete network.vpn | ||
85 | uci set network.vpn="interface" | ||
86 | uci set network.vpn.proto="wireguard" | ||
87 | uci set network.vpn.private_key="{VPN_KEY}" | ||
88 | uci add_list network.vpn.addresses="{VPN_ADDRESS}" | ||
89 | ))) | ||
90 | |||
91 | [[image:image-20231110152122-4.png]] | ||
92 | |||
93 | |||
94 | ((( | ||
95 | **#Add VPN peers** | ||
96 | ))) | ||
97 | |||
98 | (% class="box infomessage" %) | ||
99 | ((( | ||
100 | uci -q delete network.wgserver | ||
101 | uci set network.wgserver="wireguard_vpn" | ||
102 | uci set network.wgserver.public_key="{VPN_PUB}" | ||
103 | uci set network.wgserver.endpoint_host="{VPN_SERVER}" | ||
104 | uci set network.wgserver.preshared_key="{VPN_PSK}" | ||
105 | uci set network.wgserver.endpoint_port="{VPN_PORT}" | ||
106 | uci set network.wgserver.persistent_keepalive="25" | ||
107 | uci set network.wgserver.route_allowed_ips="1" | ||
108 | uci add_list network.wgserver.allowed_ips="0.0.0.0/0" | ||
109 | uci add_list network.wgserver.allowed_ips="::/0" | ||
110 | uci commit network | ||
111 | ))) | ||
112 | |||
113 | [[image:image-20231110152109-3.png]] | ||
114 | |||
115 | |||
116 | ((( | ||
117 | **#reload network service** | ||
118 | ))) | ||
119 | |||
120 | (% class="box infomessage" %) | ||
121 | ((( | ||
122 | /etc/init.d/network reload | ||
123 | ))) | ||
124 | |||
125 | |||
126 | |||
127 |