Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:services:vpn:wireguard:client [2019/09/18 13:07] – [Introduction] correct the terminology vgaetera | docs:guide-user:services:vpn:wireguard:client [2023/10/28 18:47] – [2. Key management] vgaetera | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== WireGuard client ====== | ====== WireGuard client ====== | ||
| - | {{section> | + | {{section> |
| ===== Introduction ===== | ===== Introduction ===== | ||
| * This how-to describes the method for setting up [[wp> | * This how-to describes the method for setting up [[wp> | ||
| - | | + | * Follow [[docs: |
| - | | + | |
| ===== Goals ===== | ===== Goals ===== | ||
| - | {{section> | + | {{section> |
| - | ===== Instructions | + | ===== Command-line instructions |
| ==== 1. Preparation ==== | ==== 1. Preparation ==== | ||
| - | Install the packages | + | Install the required |
| + | Specify | ||
| <code bash> | <code bash> | ||
| # Install packages | # Install packages | ||
| opkg update | opkg update | ||
| - | opkg install wireguard | + | opkg install wireguard-tools |
| # Configuration parameters | # Configuration parameters | ||
| - | WG_IF="wg0" | + | VPN_IF="vpn" |
| - | WG_SERV="SERVER_NAME_OR_IP_ADDRESS" | + | VPN_SERV="SERVER_ADDRESS" |
| - | WG_PORT=" | + | VPN_PORT=" |
| - | WG_ADDR=" | + | VPN_ADDR=" |
| - | WG_ADDR6="fdf1:7610: | + | VPN_ADDR6="fd00:9:: |
| </ | </ | ||
| ==== 2. Key management ==== | ==== 2. Key management ==== | ||
| - | Generate | + | Generate and exchange |
| - | Exchange the public keys and the pre-shared key between the server and the client using [[docs: | + | |
| <code bash> | <code bash> | ||
| - | # Generate | + | # Generate keys |
| + | umask go= | ||
| + | wg genkey | tee wgserver.key | wg pubkey > wgserver.pub | ||
| wg genkey | tee wgclient.key | wg pubkey > wgclient.pub | wg genkey | tee wgclient.key | wg pubkey > wgclient.pub | ||
| + | wg genpsk > wgclient.psk | ||
| - | WG_KEY=" | + | # Client private key |
| - | WG_PSK=" | + | VPN_KEY=" |
| - | WG_PUB=" | + | |
| + | # Pre-shared key | ||
| + | VPN_PSK=" | ||
| + | |||
| + | # Server public key | ||
| + | VPN_PUB=" | ||
| </ | </ | ||
| ==== 3. Firewall ==== | ==== 3. Firewall ==== | ||
| - | Consider VPN network as public | + | Consider VPN network as public. |
| + | Assign | ||
| <code bash> | <code bash> | ||
| Line 47: | Line 55: | ||
| uci rename firewall.@zone[0]=" | uci rename firewall.@zone[0]=" | ||
| uci rename firewall.@zone[1]=" | uci rename firewall.@zone[1]=" | ||
| - | uci rename firewall.@forwarding[0]=" | + | uci del_list firewall.wan.network=" |
| - | uci del_list firewall.wan.network=" | + | uci add_list firewall.wan.network=" |
| - | uci add_list firewall.wan.network=" | + | |
| uci commit firewall | uci commit firewall | ||
| - | / | + | service |
| </ | </ | ||
| ==== 4. Network ==== | ==== 4. Network ==== | ||
| - | Set up VPN interface and peers. | + | Configure |
| <code bash> | <code bash> | ||
| # Configure network | # Configure network | ||
| - | uci -q delete network.${WG_IF} | + | uci -q delete network.${VPN_IF} |
| - | uci set network.${WG_IF}=" | + | uci set network.${VPN_IF}=" |
| - | uci set network.${WG_IF}.proto=" | + | uci set network.${VPN_IF}.proto=" |
| - | uci set network.${WG_IF}.private_key=" | + | uci set network.${VPN_IF}.private_key=" |
| - | uci set network.${WG_IF}.preshared_key=" | + | uci add_list network.${VPN_IF}.addresses=" |
| - | uci add_list network.${WG_IF}.addresses=" | + | uci add_list network.${VPN_IF}.addresses=" |
| - | uci add_list network.${WG_IF}.addresses=" | + | |
| # Add VPN peers | # Add VPN peers | ||
| uci -q delete network.wgserver | uci -q delete network.wgserver | ||
| - | uci set network.wgserver=" | + | uci set network.wgserver=" |
| - | uci set network.wgserver.public_key=" | + | uci set network.wgserver.public_key=" |
| - | uci set network.wgserver.endpoint_host=" | + | uci set network.wgserver.preshared_key=" |
| - | uci set network.wgserver.endpoint_port=" | + | uci set network.wgserver.endpoint_host=" |
| + | uci set network.wgserver.endpoint_port=" | ||
| uci set network.wgserver.route_allowed_ips=" | uci set network.wgserver.route_allowed_ips=" | ||
| uci set network.wgserver.persistent_keepalive=" | uci set network.wgserver.persistent_keepalive=" | ||
| - | uci add_list network.wgserver.allowed_ips=" | + | uci add_list network.wgserver.allowed_ips=" |
| - | uci add_list network.wgserver.allowed_ips=" | + | |
| uci add_list network.wgserver.allowed_ips="::/ | uci add_list network.wgserver.allowed_ips="::/ | ||
| uci commit network | uci commit network | ||
| - | / | + | service |
| </ | </ | ||
| - | See also: | + | Resolve [[docs:guide-user: |
| - | [[docs: | + | |
| ===== Testing ===== | ===== Testing ===== | ||
| - | {{section> | + | {{section> |
| ===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
| - | {{section> | + | {{section> |