0

I have Wireguard set up. I can connect to 10.200.200.1, the address on Peer 1, on Peer 2. However, I can't connect to 10.200.200.1 on Peer 1. How can I do that?

Peer 1's config:

[Interface]
Address = 10.200.200.1/24
ListenPort = 51820
PrivateKey = ************

# substitute eth0 in the following lines to match the Internet-facing interface
# if the server is behind a router and receives traffic via NAT, these iptables rules are not needed
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o enp0s2 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o enp0s2 -j MASQUERADE

[Peer]
# foo
PublicKey = ***************
#PresharedKey = PRE-SHARED_KEY
AllowedIPs = 10.200.200.2/8

#PersistentKeepalive = 25

curl 10.200.200.1:2001 gives me

*   Trying 10.200.200.1:2001...
* connect to 10.200.200.1 port 2001 failed: Connection refused
* Failed to connect to 10.200.200.1 port 2001 after 0 ms: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 10.200.200.1 port 2001 after 0 ms: Connection refused

I can ping 10.200.200.1 though.

1 Answer 1

0

Ok, I figured it out -- there's two parts to this:

sysctl

sudo sysctl -w net.ipv4.conf.all.route_localnet=1

sudo sysctl -w net.ipv4.ip_forward=1

For connection to work locally:

sudo iptables -t nat -A OUTPUT -d 10.200.200.1 -j DNAT --to-destination 127.0.0.1

Related answer: https://stackoverflow.com/a/70310399/15436715

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .