3

Suppose I have two servers: A and B. On both I have installed WireGuard.

On server A, wg0 is routed with IP 10.8.0.0/24 and on server B, wg0 is routed with IP 10.7.0.0/24.

Let's say server A's WireGuard is listening on port 4000 and server B's WireGuard is listening on port 5000.

I only want to forward all incoming traffic to server A on port 5000. There are other applications listening on another ports and I do not to forward them.

What I want is:

  1. client connects to --> server A
  2. let's say client says to server A open google.com for me
  3. server A connects to --> server B
  4. let's say server A says to server B open google.com for me
  5. server B reaches google.com
  6. sends data of received from google.com to --> server A
  7. server A sends the received data to --> client

What should be done? The OS is Ubuntu on both servers.

Update 1

S-B's /etc/wireguard/wg0.conf file:

[Interface]
Address = 10.7.0.1/24
PrivateKey = SOME_KEY
ListenPort = PORT_NUMBER

S-A's /etc/wireguard/wg0.conf file:

[Interface]
Address = 10.8.0.1/24
PrivateKey = SOME_KEY
ListenPort = PORT_NUMBER

I connected to S-A's VPN, ping on my cmd 8.8.8.8, it worked. SSHed into S-A while connecting to VPN, ping 8.8.8.8, it worked.

I did the same for S-B and it worked.

I can SSH from S-A to S-B and vice-versa.

One client conf file on S-A:

[Interface]
Address = 10.8.0.2/24
DNS = 8.8.8.8
PrivateKey = PRIVATE

[Peer]
PublicKey = PUBLIC
PresharedKey = PRESHARED
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = IP:PORT
PersistentKeepalive = 25

One client conf file on S-B:

[Interface]
Address = 10.7.0.2/24
DNS = 8.8.8.8
PrivateKey = PRIVATE

[Peer]
PublicKey = PUBLIC
PresharedKey = PRESHARED
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = IP:PORT
PersistentKeepalive = 25
15
  • 1
    it looks for me similar to serverfault.com/questions/1066524/…
    – djdomi
    Jun 13, 2021 at 19:17
  • 1
    @djdomi thanks, I saw that but I do not see the answer there or hint to help me, or at least if it exists I cannot find
    – 1nted
    Jun 14, 2021 at 3:46
  • 1
    Does this answer your question? Forward VPN traffic to another server
    – djdomi
    Jun 14, 2021 at 4:18
  • 1
    I am unaware of your Setup but did it worked before and did you used NAT?
    – djdomi
    Jun 14, 2021 at 4:40
  • 1
    then revert the changes first
    – djdomi
    Jun 14, 2021 at 4:49

0

You must log in to answer this question.

Browse other questions tagged .