Wireguard no internet after enablling Kill Switch

Everything worked smoothly until a few days ago when on Linux Mint (Ubuntu / xfce) while enabling the kill switch on Wireguard, I couldn’t access the internet.

[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

I have tried to enable/disable the Firewall, but it didn’t help, although I can ping 8.8.8.8 via the terminal while the PostUp and PreDown code is active.

The firewall is UFW.

When activating looks like this:

~$ 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

when deactivating like that:

$ 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

Can someone please give me some clues?

Asked By: Milan Grujić

||

There was some misconfiguration in UFW, I have reset it and everything went as normal, all works great now…

Answered By: Milan Grujić
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.