
試圖讓wireguard vpn 測試工作,但我陷入困境。任何有關下一步檢查內容的建議將不勝感激。
伺服器是運行 Ubuntu(具有 3.13.0-141 核心)的 DO Droplet,客戶端是運行 Mint(具有 4.4.0-112 核心)的桌面 kvm guest 虛擬機,並在 nat 路由器後面進行橋接網路連接。客戶端可以正常 ping 伺服器,但任何其他資料包類型似乎都會遺失,儘管 tcpdump 顯示大量資料包到達伺服器上的 wg0。依照建議在伺服器上啟用 ip_forward 和 proxy_arp在這篇文章中。伺服器上的 ufw 已開啟隧道連接埠。伺服器也會在其他連接埠上執行 openvpn。
將 wg-quick 與這些設定檔一起使用。
客戶:
[Interface]
Address = 10.0.0.200
DNS = 8.8.8.8
PrivateKey = UJeiJJvi5NdqiBrgBfsim+ZS4c69M5EP5fUNNIXMy08=
[Peer]
PublicKey = MreTtFUDB5bQfkegxX2cvz3BLC9sybK4y0loTKhVunU=
AllowedIPs = 0.0.0.0/0
Endpoint = 159.203.227.235:51820
sudo wg-quick up ./wg0.conf
[sudo] password for jim:
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip address add 10.0.0.200 dev wg0
[#] ip link set mtu 1420 dev wg0
[#] ip link set wg0 up
[#] resolvconf -a tun.wg0 -m 0 -x
[#] wg set wg0 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
伺服器:
[Interface]
Address = 10.0.0.201
SaveConfig = true
ListenPort = 51820
PrivateKey = 6GBAE7bFjrOfEp1uWiPvoW+5CyfpjsBmK0/vCIWbGl0=
[Peer]
PublicKey = furwAmh4vbKrLAGZG/QDIUT2a1GLi0WxDY6YdQKzIHE=
AllowedIPs = 10.0.0.200/32
sudo wg-quick up ./wg0.conf
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip link set mtu 1420 dev wg0
[#] ip link set wg0 up
[#] ip route add 10.0.0.200/32 dev wg0
ip route show table all
default via 159.203.224.1 dev eth0
10.0.0.200 dev wg0 scope link
10.12.0.0/16 dev eth0 proto kernel scope link src 10.12.0.5
159.203.224.0/20 dev eth0 proto kernel scope link src 159.203.227.235
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
broadcast 10.12.0.0 dev eth0 table local proto kernel scope link src 10.12.0.5
local 10.12.0.5 dev eth0 table local proto kernel scope host src 10.12.0.5
broadcast 10.12.255.255 dev eth0 table local proto kernel scope link src 10.12.0.5
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 159.203.224.0 dev eth0 table local proto kernel scope link src 159.203.227.235
local 159.203.227.235 dev eth0 table local proto kernel scope host src 159.203.227.235
broadcast 159.203.239.255 dev eth0 table local proto kernel scope link src 159.203.227.235
broadcast 172.17.0.0 dev docker0 table local proto kernel scope link src 172.17.0.1
local 172.17.0.1 dev docker0 table local proto kernel scope host src 172.17.0.1
broadcast 172.17.255.255 dev docker0 table local proto kernel scope link src 172.17.0.1
fe80::/64 dev eth0 proto kernel metric 256
fe80::/64 dev veth215195c proto kernel metric 256
fe80::/64 dev docker0 proto kernel metric 256
unreachable default dev lo table unspec proto kernel metric 4294967295 error -101
local ::1 dev lo table local proto none metric 0
local fe80::42:2fff:fec9:400 dev lo table local proto none metric 0
local fe80::601:d8ff:febf:4701 dev lo table local proto none metric 0
local fe80::84ce:13ff:feaf:f628 dev lo table local proto none metric 0
ff00::/8 dev eth0 table local metric 256
ff00::/8 dev veth215195c table local metric 256
ff00::/8 dev docker0 table local metric 256
unreachable default dev lo table unspec proto kernel metric 4294967295 error -101
答案1
我在這個非常有用的幫助下得到了這個工作部落格文章 其中也介紹如何設定 dns 伺服器以防止客戶端 dns 流量洩漏到隧道之外。
主要問題是伺服器上的過濾器/nat 設定不完整。這篇文章涵蓋了必要的 iptables 命令。由於 ufw 已經用於 ssh 等簡單的事情,並且我不想嘗試將所有內容轉換為一種格式,所以我只是將它們組合起來。這適用於執行 Ubuntu 16.04 的新 Droplet。還在我原來的 Ubuntu 14.04 系統上進行了測試,我必須添加一個額外的 ufw 規則:
ufw 路由允許從 10.200.200.2 在 eth0 上進入 wg0
顯然是因為由於某種原因輸入和轉送的預設策略已設定為 DROP。