Hello folks,
I have been fooling with wireguard on FreeBSD and succeeded for the most part. But I cannot get the part of connecting two LANs to work. I need some help.
I have no problem installing and configuring wireguard on FreeBSD. A mobile device can connect to my LAN through wireguard without any problem. I did the same for my other LAN and it also worked fine.
The problem is connecting the two LANs. I would like my mobile device to be able to access both LANs, but there is only partial success.
Here is a diagram of the network topology, and what happened:
My guess is that it is related to routing configuration on the two wireguard servers? Something to do with pf?
For your information, the goal is actually achieved with wireguard on Debian 11, with the PostUp and PostDown lines in the wireguard configuration file. But I just cannot figure out the equivalence in FreeBSD due to my limited knowledge of FreeBSD. Any help will be greatly appreciated.
Configuration details of LAN A’s wireguard server (192.168.1.10, FreeBSD 13):
/usr/local/etc/wireguard/lana_wg.conf
/etc/pf.rules
And in /etc/rc.conf, wireguard, pf, and gateway are enabled. I also checked to make sure net.inet.ip.forwarding=1.
Configuration on LAN B is the same, except some port number, and IP addresses.
I have been fooling with wireguard on FreeBSD and succeeded for the most part. But I cannot get the part of connecting two LANs to work. I need some help.
I have no problem installing and configuring wireguard on FreeBSD. A mobile device can connect to my LAN through wireguard without any problem. I did the same for my other LAN and it also worked fine.
The problem is connecting the two LANs. I would like my mobile device to be able to access both LANs, but there is only partial success.
Here is a diagram of the network topology, and what happened:
- A mobile device can connect to LAN A’s wireguard server. It then can have access LAN A without any problem.
- The mobile device can also do the same on LAN B.
- I set up a wireguard tunnel between the two wireguard servers. On the wireguard server, it is possible to ping all devices on the other LAN. But the mobile device cannot. If it is connected to LAN A, it cannot ping any device on LAN B. The error message is "Redirect Host (New nexthop: ..."
My guess is that it is related to routing configuration on the two wireguard servers? Something to do with pf?
For your information, the goal is actually achieved with wireguard on Debian 11, with the PostUp and PostDown lines in the wireguard configuration file. But I just cannot figure out the equivalence in FreeBSD due to my limited knowledge of FreeBSD. Any help will be greatly appreciated.
Configuration details of LAN A’s wireguard server (192.168.1.10, FreeBSD 13):
/usr/local/etc/wireguard/lana_wg.conf
Code:
[Interface]
### Wireguard on LAN A FreeBSD server
PrivateKey = [Private Key]
Address = 10.0.1.10/24
ListenPort = 51111
[Peer]
### Wireguard on LAN B FreeBSD server
PublicKey = [Public Key]
Endpoint = lanb.example.com:52222
AllowedIPs = 10.0.1.20/32, 172.16.1.0/24
[Peer]
# Mobile device
PublicKey = [Public Key]
AllowedIPs = 10.0.1.30/32
/etc/pf.rules
Code:
# Interfaces
ext_if = "re0"
wireguard_if = "lana_wg"
# Wireguard Settings
wireguard_net_v4 = "10.0.1.0/24"
# Options
set skip on lo
# Nat all wireguard to non-wireguard traffic
nat on $ext_if inet from $wireguard_net_v4 to { any, !$wireguard_net_v4 } -> ($ext_if)
# Filtering
pass inet all
And in /etc/rc.conf, wireguard, pf, and gateway are enabled. I also checked to make sure net.inet.ip.forwarding=1.
Configuration on LAN B is the same, except some port number, and IP addresses.