I have configured Wireguard VPN on Alpine Linux 3.16.2. Manual server and client configuration works fine.
uname -mrs
# Linux 5.15.60-0-virt aarch64
ip link add dev wg0 type wireguard
ip address add dev wg0 10.0.0.4/8
wg setconf wg0 /etc/wireguard/wg0.conf
ip link set up dev wg0
wg
# interface: wg0
# public key: 9nEynT6g.....
# private key: (hidden)
# listening port: 31194
# peer: A2zDuhbX6....
# allowed ips: 10.0.0.5/32
but when I reboot the system device wg0 disappears. How to do it persistent?
I followed the instruction Alpine Linux set up WireGuard VPN server but it seems a bit outdated.
When adding interface to /etc/network/interfaces I faced the following problems.
They do not add new entries to this file directly because NOTE: /sbin/assemble-interfaces rewrites this file. Edit files in /etc/network/interfaces.d/ to persist any customizations
.
If I add new config file with interface description it does not load after reboot:
nano /etc/network/interfaces.d/wg0
The content of /etc/network/interfaces.d/wg0
auto wg0
iface wg0 inet static
address 10.0.0.4/8
gateway 10.0.0.1
pre-up ip link add dev wg0 type wireguard
pre-up wg setconf wg0 /etc/wireguard/wg0.conf
post-down ip link delete wg0
Manual configuration is working. I can establish VPN connection from remote client to server, ssh to server using private address 10.0.0.4 and access Internet. So how configure this interface to up at boot time on Alpine Linux 3.16.2]1?