一切都很顺利,直到几天前,当我在 Linux Mint (Ubuntu / xfce) 上启用 Wireguard 上的终止开关时,我无法访问互联网。
[Interface]
PrivateKey = ************ # The comp_private.key value.
Address = 10.0.0.2/24 # Internal IP address of the VPN server.
ListenPort = 51820 # Previously, we opened this port to listen for incoming connections in the firewall.
#kill swich
PostUp = iptables -I OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT && ip6tables -I OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT
PreDown = iptables -D OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT && ip6tables -D OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT
[Peer]
PublicKey = *******
Endpoint = *******
AllowedIPs = 0.0.0.0/0
我尝试启用/禁用防火墙,但没有帮助,尽管在 PostUp 和 PreDown 代码处于活动状态时我可以通过终端 ping 8.8.8.8。
防火墙是UFW。
激活时看起来像这样:
~$ wg-quick up wg1
[#] ip link add wg1 type wireguard
[#] wg setconf wg1 /dev/fd/63
[#] ip -4 address add 10.0.0.2/24 dev wg1
[#] ip link set mtu 1420 up dev wg1
[#] wg set wg1 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg1 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] iptables-restore -n
[#] iptables -I OUTPUT ! -o wg1 -m mark ! --mark $(wg show wg1 fwmark) -m addrtype ! --dst-type LOCAL -j REJECT && ip6tables -I OUTPUT ! -o wg1 -m mark ! --mark $(wg show wg1 fwmark) -m addrtype ! --dst-type LOCAL -j REJECT
当这样停用时:
$ wg-quick down wg1
[#] iptables -D OUTPUT ! -o wg1 -m mark ! --mark $(wg show wg1 fwmark) -m addrtype ! --dst-type LOCAL -j REJECT && ip6tables -D OUTPUT ! -o wg1 -m mark ! --mark $(wg show wg1 fwmark) -m addrtype ! --dst-type LOCAL -j REJECT
[#] ip -4 rule delete table 51820
[#] ip -4 rule delete table main suppress_prefixlength 0
[#] ip link delete dev wg1
[#] iptables-restore -n
有人可以给我一些线索吗?
答案1
UFW 中存在一些配置错误,我已重置它,一切正常,现在一切正常......