How do I set up a wireguard configuration that acts like a nat?
How do I set up a wireguard configuration that acts like a nat?
I have a server with wireguard in a container with host networking. I want to assign an ipv6 subnet for each peer (eg: fd42:413d:a91f:dd37::/64
) that the client (my laptop) can freely use all the addresses in that subnet and corresponding port ranges as a separate network interface. Meanwhile on the server, that exact same ip and port is routed to that specific client but through the tunnel.
Here's an example:
- Server config
ini
[Interface] Address = fd42::1/128 ListenPort = 51820 PrivateKey = <key> [Peer] PublicKey = <key> AllowedIPs = fd42:413d:a91f:dd37::/64
- Client config
ini
[Interface] PrivateKey = <key> Address = fd42:413d:a91f:dd37::1/64 [Peer] PublicKey = <key> Endpoint = server.local:51820 AllowedIPs = fd42:413d::/32, fd42:413d:a91f:dd37::/64
- Run a server on the client
sh
python -m http.server 8080 --bind fd42:413d:a91f:dd37::1 -d dist
- Access on the server
sh
curl -svL http://[fd42:413d:a91f:dd37::1]:8080/
I can't get step 4 to work. It's also entirely possible that my lack of knowledge in networking is making me think this is even possible in the first place. Any help is appreciated!