Wireguard VPN setup (4.2 and 4.3)

I would like to use a different vpn provider for the port forwarding.

Like it used to be on Mullvad to no weird port leasing.

Just forwarding the port from the vpn qube to the client qube. There shouldn’t be anything special when using network-manager ?

Sorry, I thought it was the proton VPN topic :sweat_smile:

You need to use a few nftables to forward the traffic to the right place, and open the port in the appvm. My guide for forwarding ports (or the firewall documentation) is what you need. This is unrelated to network manager.

I can confirm it’ll work fine, I used such setup last year.

Everything works correctly but not the /rw/config/rc.local script i tried to delete the template-dispvm two times and restart again from scratch and it’s the same result any help please ? I’m using the last version on fedora on 4.3

What i have done so far is put the command of solene in /rw/config/rc.local > sudo chmod +x /rw/config/rc.local

(I noticed that every script i put in /rw/config/rc.local do not work even on debian based vm) and by doing some research i’v seen other people had problem with /rw/config/rc.local in the past

Can you share the content of your /rw/config/rc.local file?

Why are you referring to disposable templates? I don’t see the connection between this and the rc.local script.

The content of my /rw/config/rc.local

#!/bin/sh

# This script will be executed at every VM startup, you can place your own
# custom commands here. This includes overriding some configuration in /etc,
# starting services etc.
#
# Executable scripts located in /rw/config/rc.local.d with the extension
# '.rc' are executed immediately before this rc.local.
# Example:
#  /rw/config/rc.local.d/custom.rc
#
# Example for overriding the whole CUPS configuration:
#  rm -rf /etc/cups
#  ln -s /rw/config/cups /etc/cups
#  systemctl --no-block restart cups

RANDOM_VPN=$(nmcli connection show | awk '/wireguard/ { print $1 }' | sort -R | head -n 1)
nmcli connection up "$RANDOM_VPN"

I said that to give more information but anyway i can’t see where the problem is coming from

Does the script work if you start it manually?

Manual start works yes this is so strange… it looks like the vm ignore the script

Can you add sleep 5 before the two commands?

1 Like

The “sleep 5” commands worked ! Thanks you’re amazing but… why i have to do that and not you ?

I’m not sure why it’s needed here, something might have changed since the guide, maybe network manager isn’t ready yet now at this stage?

If you want i can do some other test for you just tell me what i have to do

To permanently fix this timing issue, I changed in the sys-vpn template the systemd requirement for qubes-misc-post.service , so that it starts after “network-online.target”, not “network-pre.target”:

[deb-12m-vpn]# sed -ie 's/network-pre.target/network-online.target/g' /lib/systemd/system/qubes-misc-post.service

Notes:

  1. this qubes-misc-post.service is running /usr/lib/qubes/init/misc-post.sh which in turn runs any /rw/config/rc.local.d/* scripts and /rw/config/rc.local;
  2. for the impatient users: after the change, the template must be shut down and only then the changes will show up upon further sys-vpn (re)starts :smile:
1 Like

First of all I want to thank you, Solene, for this guide who enabled me to set up a sys-vpn service Qube for wireguard based VPN (by Proton)!

Since I’ll not only want to use this but also understand the underlying concepts and settings I’m asking the following regarding this statement from you:

Why is that?

I don’t really remember the certainly good reason I had when writing this, but by pinning sys-firewall you are sure that the netvm will not change.

If you put sys-whonix as the default netvm, the VPN would not establish and firewall rules would not be applied.

1 Like

I think this is it.

I just wanted to inform about a low severity information disclosure security vulnerability happening on Qubes 4.3 when following these suggested Wireguard VPN guidelines, at least when using debian-13-xfce template for the VPN gateway qube.

I found it during a routine security audit, and have reported it to the bug tracker, but it may as well be a configuration flaw rather than software bug. If anyone is able to help replicate or prevent this leak, it would be appreciated.

2 Likes

Hey @ryrona I’ve noticed your impeccable work here, as well as debunking that Qubes OS is not secure on the grapheneOS forums, a while back. I also noticed you troubleshooted with Wireshark a USB problem of not being able to attach a pixel running graphene OS on qubes. I would like to ask you, (since there is no DM option), how did you achieve such mastery? Who thinks of running Wireshark on sys-usb and then have enough skill to actually find the problem? This is very inspiring and I hope you get a chance to reply as I’d like to learn and reach your level.

Okay I have been trying for a while now but I can’t get VPN port forwarding to work.

Netcat can’t get a connection at all when listening in the vpn-qube-2 with nc -l $port.
Did not have this issue with wg-quick…

I don’t think any firewall rules should block it.

My setup is vpn-qube-2 > vpn-qube-1 > sys-firewall > sys-net
qvm-firewall blocks everything but the udp port for vpn-qube-1 but no rules at all for vpn-qube-2

Could somebody pls help out?

If I understand correctly, you want to have a service in vpn-qube-2 listening on a port, and the other side of the VPN should be able to connect, right?

Indeed, sys-firewall and vpn-qube-1 firewalls have nothing to do with this because they all see WireGuard tunnel. You might already know this, but I’m summarizing to be sure we both talk about the same thing :slight_smile:

Can vpn-qube-2 and its remote peer able to ping each other?

Did you allow the incoming port in vpn-qube-2 on the WireGuard interface? By default, qubes block all incoming traffic on all interfaces, so it would be the expected behavior to have incoming connections through a VPN to be blocked.

1 Like

Thanks,

I want to run a service in vpn-qube-2 that should be reachable by the public VPN address and the port. (Like mullvad port forwarding)

I can ping the endpoint.

I tried to set this rule in vpn-qube-2:

nft insert rule qubes custom-input udp dport "$port" accept
nft insert rule qubes custom-input tcp dport "$port" accept

But I though this should not even be necessary and just be tunneled via the normal udp port
Are these the right rules