我设置了 Wireguard。我可以连接到10.200.200.1
Peer 1 上的地址,Peer 2。但是,我无法连接到10.200.200.1
Peer 1。我该怎么做?
对等体 1 的配置:
[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
给我
* 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
不过我可以ping10.200.200.1
通。
好的,我想通了——这有两个部分:
要连接到本地工作:
相关答案:https ://stackoverflow.com/a/70310399/15436715