As mentioned in the title, I am using a WireGuard Hub and Spoke configuration to connect my network at home to RoadWarrior peers. Unfortunately I have no public IPv4 and v6 address at home and on the road, so I need the hub. So far the routing of private IP addresses works, but I want to use the VPS (HUB and Host B) also as an exit point for normal traffic, because I am sometimes on the road with my mobile in insecure networks. So on my Host A (smartphone) I have set the Allowed-IPs to 0.0.0.0/0, but unfortunately this does not go through. I suspect that routing rules are missing on the VPS (HUB and Host B). Here you have how I thought about the whole thing.
RoadWarrior (Host A) <---> VPS HUB (Host B) <----> Home-net (Host C)
|
|
Internet
So here is my WireGuard configuration on the VPS:
# /etc/wireguard/wg0.conf
[Interface]
Address = 10.210.1.1/16
ListenPort = 51828
PrivateKey =
PreUp = sysctl -w net.ipv4.ip_forward=1
PreUp = sysctl -w net.ipv6.conf.all.forwarding=1
PreUp = nft -f /etc/nftables.wg
PostDown = nft -f /etc/nftables.conf
PostDown = sysctl -w net.ipv4.ip_forward=0
PostDown = sysctl -w net.ipv6.conf.all.forwarding=0
# Home-net (Host C)
[Peer]
PublicKey =
PresharedKey =
AllowedIPs = 10.211.1.1/24, 10.1.0.0/16, 10.2.0.0/16
#Road-Warrior Peers (Host A)
[Peer]
PublicKey =
PresharedKey =
AllowedIPs = 10.212.1.1/32
My nftables config when WireGuard is running:
#!/usr/sbin/nft -f
flush ruleset
define pub_iface = eth0
define wg_iface = wg0
define wg_port = 51828
table inet basic-filter {
chain input {
type filter hook input priority 0; policy drop;
ct state { established, related } accept
iif lo accept
ip protocol icmp accept
ip6 nexthdr ipv6-icmp accept
ct state new tcp dport 51829 log prefix "Neue SSH-Verbindung" accept
iif $pub_iface udp dport $wg_port accept
iifname $wg_iface accept
reject
}
chain forward {
type filter hook forward priority 0; policy drop;
iifname $wg_iface oifname $wg_iface accept
reject with icmpx type host-unreachable
}
chain output {
type filter hook output priority 0; policy accept;
}
}
And my WireGuard configuration when WireGuard is down:
#!/usr/sbin/nft -f
flush ruleset
table inet basic-filter {
chain input {
type filter hook input priority 0; policy drop;
ct state { established, related } accept
iif lo accept
ip protocol icmp accept
ip6 nexthdr ipv6-icmp accept
ct state new tcp dport 51829 log prefix "Neue SSH-Verbindung " accept
reject
}
}
Maybe you can also check out my nftables configuration, because it' relatively new to me :) Thank you :)