I'm working on setting up my first wireguard server on FreeBSD 13.3.
The issue: once I start the wireguard service I can't reach the server anymore, the server still can access the internet but nothing can connect to it. The server is in the cloud.
On the same server I'm running an openvpn server, there are no issues there.
Do you have an idea what should I try? What did I miss?
rc.conf
wg0.conf
In pf.conf I have the following wireguard related lines
- x.x.x.x - the server's public IP
- 10.8.0.0/24 - openvpn network
- 10.9.0.0/24 - wireguard network
The issue: once I start the wireguard service I can't reach the server anymore, the server still can access the internet but nothing can connect to it. The server is in the cloud.
On the same server I'm running an openvpn server, there are no issues there.
Do you have an idea what should I try? What did I miss?
rc.conf
Code:
...
wireguard_enable="YES"
wireguard_interfaces="wg0"
wg0.conf
Code:
[Interface]
Address = 10.9.0.1/32 # address the server will bind to
ListenPort = 51820 # listener port
PrivateKey = ***
[Peer]
AllowedIPs = public-ip-of-the-source/32
PreSharedKey = ***
PublicKey = ***
In pf.conf I have the following wireguard related lines
Code:
ext_if = "em0"
ext_ip = "x.x.x.x"
wg_lan = "10.9.0.0/24"
nat on $ext_if from $wg_lan to any -> $ext_if
pass in on $ext_if inet proto udp from any to ($ext_if) port { 51820 } keep state
Code:
% pfctl -v -s nat
No ALTQ support in kernel
ALTQ related functions disabled
nat on em0 inet from 10.8.0.0/24 to any -> x.x.x.x
[ Evaluations: 256 Packets: 1567 Bytes: 101044 States: 3 ]
[ Inserted: uid 0 pid 44084 State Creations: 21 ]
nat on em0 inet from 10.9.0.0/24 to any -> x.x.x.x
[ Evaluations: 80 Packets: 0 Bytes: 0 States: 0 ]
[ Inserted: uid 0 pid 44084 State Creations: 0 ]
Code:
% sudo service wireguard restart
[#] ifconfig wg0 destroy
[#] ifconfig wg create name wg0
[#] wg setconf wg0 /dev/stdin
[#] ifconfig wg0 inet 10.9.0.1/32 alias
[#] ifconfig wg0 mtu 1420
[#] ifconfig wg0 up
[#] route -q -n add -inet x.x.x.x/32 -interface wg0
[+]
Backgrounding route
- x.x.x.x - the server's public IP
- 10.8.0.0/24 - openvpn network
- 10.9.0.0/24 - wireguard network