Thanks, but could you please elaborate ? What post up scripts do you have for the wg0 interface ?
Basically I’ve simply created the /etc/wireguard/wg0.conf
file and ran wg-quick up wg0
. I’m pretty sure the conf file is correct as it was auto generated by pivpn. Also I have a fedora machine running in the same network that is also a wireguard client of the same server, that uses a similar config file (with different keys / IPs of course)
Troubleshooting:
- Output of
wg-quick up wg0
root@truenas[~]# wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 1.1.1.1/24 dev wg0 (redacted IP of the client)
[#] ip link set mtu 1420 up dev wg0
[#] resolvconf -a wg0 -m 0 -x
[#] wg set wg0 fwmark 51820
[#] ip -6 route add ::/0 dev wg0 table 51820
[#] ip -6 rule add not fwmark 51820 table 51820
[#] ip -6 rule add table main suppress_prefixlength 0
[#] nft -f /dev/fd/63
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] nft -f /dev/fd/63
interface: wg0
public key: XTtTxZi94CJoZjHHmarkKiz6q2RoM4CBw3C8NS+kRCM=
private key: (hidden)
listening port: 59755
fwmark: 0xca6c
peer: iiek4/zu+yuWiqd/xxQ26Rrlp15Txwkg1MdJHw8kKzo=
preshared key: (hidden)
endpoint: <REDACTED>
allowed ips: 0.0.0.0/0, ::/0
transfer: 0 B received, 8.67 KiB sent
Endpoint is reachable when VPN is down.
sudo dmesg -wT
(after enabling wireguard verbose logging):
[Tue Jul 23 23:23:02 2024] wireguard: wg0: Interface created
[Tue Jul 23 23:23:02 2024] wireguard: wg0: Peer 2 created
[Tue Jul 23 23:23:03 2024] wireguard: wg0: Sending handshake initiation to peer 2 (<REDACTED>)
[Tue Jul 23 23:23:08 2024] wireguard: wg0: Handshake for peer 2 (<REDACTED>) did not complete after 5 seconds, retrying (try 2)
[Tue Jul 23 23:23:08 2024] wireguard: wg0: Sending handshake initiation to peer 2 (<REDACTED>)
[Tue Jul 23 23:23:13 2024] wireguard: wg0: Handshake for peer 2 (<REDACTED>) did not complete after 5 seconds, retrying (try 2)
[Tue Jul 23 23:23:13 2024] wireguard: wg0: Sending handshake initiation to peer 2 (<REDACTED>)
[Tue Jul 23 23:23:18 2024] wireguard: wg0: Handshake for peer 2 (<REDACTED>) did not complete after 5 seconds, retrying (try 3)
[Tue Jul 23 23:23:18 2024] wireguard: wg0: Sending handshake initiation to peer 2 (<REDACTED>)
[Tue Jul 23 23:23:23 2024] wireguard: wg0: Handshake for peer 2
tcpdump -env -i any icmp
when pinging wireguard server (IPs redacted 1.1.1.1 is the client, 2.2.2.2 is the server)
23:58:27.333868 wg0 Out ifindex 13 ethertype IPv4 (0x0800), length 104: (tos 0x0, ttl 64, id 62365, offset 0, flags [DF], proto ICMP (1), length 84)
1.1.1.1 > 2.2.2.2: ICMP echo request, id 25149, seq 1, length 64
23:58:28.365650 wg0 Out ifindex 13 ethertype IPv4 (0x0800), length 104: (tos 0x0, ttl 64, id 62386, offset 0, flags [DF], proto ICMP (1), length 84)
1.1.1.1 > 2.2.2.2: ICMP echo request, id 25149, seq 2, length 64
23:58:29.389600 wg0 Out ifindex 13 ethertype IPv4 (0x0800), length 104: (tos 0x0, ttl 64, id 62621, offset 0, flags [DF], proto ICMP (1), length 84)
1.1.1.1 > 2.2.2.2: ICMP echo request, id 25149, seq 3, length 64
23:58:30.413599 wg0 Out ifindex 13 ethertype IPv4 (0x0800), length 104: (tos 0x0, ttl 64, id 62713, offset 0, flags [DF], proto ICMP (1), length 84)
1.1.1.1 > 2.2.2.2: ICMP echo request, id 25149, seq 4, length 64
23:58:31.437648 wg0 Out ifindex 13 ethertype IPv4 (0x0800), length 104: (tos 0x0, ttl 64, id 62966, offset 0, flags [DF], proto ICMP (1), length 84)
1.1.1.1 > 2.2.2.2: ICMP echo request, id 25149, seq 5, length 64
So only packages going out, no replies. On the server, I don’t see anything arriving. Not sure where the packages are dropped.
root@truenas[~]# ip r
default via 192.168.178.1 dev enp2s0
10.23.23.0/24 dev wg0 proto kernel scope link src 1.1.1.1
172.16.0.0/16 dev kube-bridge proto kernel scope link src 172.16.0.1
192.168.178.0/24 dev enp2s0 proto kernel scope link src 192.168.178.50
192.168.178.0/24 dev enp1s0 proto kernel scope link src 192.168.178.46 linkdown
root@truenas[~]# netstat -tunlp | grep 59755
udp 0 0 0.0.0.0:59755 0.0.0.0:* -
udp6 0 0 :::59755 :::* -
So yeah, not sure what I’m missing but I can’t seem to make it work at the moment. Any help appreciated ! Thanks