Forward packets Wireguard to local subnet, with Nftables. [ solved ]
Hi,
I would like to forward packets that come from a wireguard connection to a local subnet
environment
- Client: connected to server trough wireguard IP 192.168.X.2
- server: connected to Client trough wireguard IP 192.168.X.1 and 192.168.Y.1 ( it's not systemd free ¯\(ツ)/¯ )
- aMachine: on the same subnet as server IP 192.168.Y.2
on the server I've done
#I don't know if this is necessary ?
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl --system
I've added the following rule to the nftables config on server but it seem the packet get lost ?
#added inside existing table `table ip Tip {}`
chain chPreRoute {
type nat hook prerouting priority 0; policy accept;
iif wg0 icmp type echo-request dnat to 192.168.Y.2
}
Here's mine, if this helps? I have WireGuard running on an Alpine LXC on my LAN, and use it to connect back home. I can SSH to or use resources from any other machine on the LAN while connected. You'll need to amend the include rules to match whatever distro you're using (the paths will be different), and you can add whatever rules you wish under the LAN section to allow local access to the WireGuard 'host' for other services (eg SSH).
There's also a lot of useful info on the Pro Custodibus blog.
I wanted to do the exact same thing and found this extremely helpful blog post.
It works with iptables, and not nftables though, I don't know enough about iptables and networking to translate it to nftables.
(web archive link because the blogger is migrating their blogs, and this one is currently unavailable on their site)
Dunno if this helps, but it sounds like you're trying to do something similar (?) to what's described in this article:
https://www.procustodibus.com/blog/2022/10/wireguard-in-podman/
They also have this guide:
https://www.procustodibus.com/blog/2021/11/wireguard-nftables/#point-to-site
Good luck!
Hi, Thank to all of you.
I made a test environment with the following.
The goal is to send a ping A to B, B forward to C
So
ping -4c 1 192.168.y.2from A, should ping B fw CI've set the following rule in /etc/nftables.conf
but is not working :'(
I see B receive the package
but it seem C receive nothing..
Any ideas ?
SOLVED
The following works !
I guess one of my others rules was blocking