我正在設定 Wireguard 以從雲端虛擬機器到我們的內部網路建立隧道。本地伺服器正在使用 OPNSense 的 Wireguard 外掛程式。
OPNSense 充當防火牆、dhcp 等。
伺服器:
interface: wg0
public key: redacted
private key: (hidden)
listening port: 42001
peer: redacted
endpoint: CLOUD_VM_PUBLIC_IP:42001
allowed ips: 10.0.1.42/32
latest handshake: 48 seconds ago
transfer: 184.23 KiB received, 186.37 KiB sent
persistent keepalive: every 21 seconds
客戶:
public key: redacted
private key: (hidden)
listening port: 42001
peer: redacted
endpoint: LOCAL_PUBLIC_IP:42001
allowed ips: 10.0.0.0/16
latest handshake: 2 minutes, 14 seconds ago
transfer: 1.30 KiB received, 1.20 KiB sent
persistent keepalive: every 21 seconds
客戶端配置:
[Interface]
# set address to next address
Address = 10.0.1.42/16
ListenPort = 42001
PrivateKey = redacted
DNS = 1.1.1.1
[Peer]
PublicKey = redacted
Endpoint = LOCAL_PUBLIC_IP:42001
AllowedIPs = 10.0.0.0/16
PersistentKeepalive = 21
透過此配置,我可以使用 OPNSense 上的內部 IP 位址連接到虛擬機10.0.1.42
,但其他任何內容都顯示「目標主機無法存取」。嘗試10.0.0.0/16
從雲端虛擬機器 ping 任何內部 IP 都會逾時。