Score:0

Forward Wireguard traffic to another port

cn flag

I have installed Wireguard on server A with below configuration:

[Interface]
Address = 172.16.0.1/24
ListenPort = 51820
PrivateKey = <server private key>
# Firewall rules
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ens160 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ens160 -j MASQUERADE


[Peer]
# Client #1 details
PublicKey = <client public key>
AllowedIPs = 172.16.0.2/32

And also I have opened a tcp port (port: 6060) on localhost of server A that if anyone connect to this port, all of it's traffic will forward to internet through server B.(something like dynamic port forwarding)

How can I forward all of my Wiregurad VPN clients traffic to this port (6060) so that if anyone connect to my VPN server, they can access internet trough server B.

My OS is: Ubuntu 20.04

drookie avatar
za flag
This network setup is just wrong. You should avoid port-forwarding when possible, and when using VPN - this is always possible, because this is one of the goals of VPN - to get you the clear and simple internal network connectivity.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.