Mullvad VPN App 4.2 setup guide revisions

Go back to topic: Mullvad VPN App 4.2 setup guide

  1. v7 anchor; v7 full version
  2. v6 anchor; v6 full version
  3. v5 anchor; v5 full version
  4. v4 anchor; v4 full version
  5. v3 anchor; v3 full version
  6. v2 anchor; v2 full version

Revision #7

Edited on
2024-09-15
Edited by user
solene
Add this to `/usr/local/bin/mullvad-dns.sh` Edit the file `/usr/local/bin/mullvad-dns.sh` to put the following content:

Revision #6

Edited on
2024-04-08
Edited by user
DVM
> :information_source: The App uses a custom DNS by default (10.64.0.1) but this won't propagate to qubes behind it, leading to long waiting time for resolving hostnames. This command forces all DNS requests to go through a given DNS server, you can change the value to your favorite DNS server. Add this to `/rw/config/qubes-firewall-user-script` > :information_source: The App uses several custom DNS that change based on the options selected by the user, but this doesn't propagate to the qubes behind it, resulting in long latency times for resolving hostnames. The following script forces all DNS requests to automatically go through the selected custom DNS server. > :warning: The script depends on `inotify`, which can be installed with the `inotify-tools` package. Add this to `/usr/local/bin/mullvad-dns.sh`
# Redirect all the DNS traffic to the preferred DNS server DNS=10.64.0.1 nft add chain qubes nat { type nat hook prerouting priority dstnat\; } nft add rule qubes nat iifname == "vif*" tcp dport 53 dnat "$DNS" nft add rule qubes nat iifname == "vif*" udp dport 53 dnat "$DNS #! /usr/bin/env bash update_dns() { # mullvad_on: 0 -> off, 1 -> on mullvad_on=$([[ $(grep -v -c "nameserver \+10.139" /etc/resolv.conf) -gt 0 ]] && echo 1 || echo 0) if [[ $mullvad_on -eq 1 ]]; then echo "Mullvad is on" # get the mullvad dns ip address. First one is used if there is more than one. mullvad_dns_ip=$(grep "nameserver" < /etc/resolv.conf| awk '{print $2}' | head -n 1) # delete all the lines defined in dnat-dns sudo nft flush chain ip qubes dnat-dns # forward all dns requests to mullvad dns servers sudo nft add rule ip qubes dnat-dns meta l4proto { tcp, udp } ip daddr { 10.139.1.1, 10.139.1.2 } th dport 53 dnat to "$mullvad_dns_ip" else echo "Mullvad is off" # get qubes nameserver ip addresses nameserver_ips=$(grep "nameserver" < /etc/resolv.conf| awk '{print $2}') # delete all the lines defined in dnat-dns sudo nft flush chain ip qubes dnat-dns # add rule to forward dns requests to qubes nameservers for ip in $nameserver_ips; do sudo nft add rule ip qubes dnat-dns ip daddr "$ip" udp dport 53 dnat to "$ip" sudo nft add rule ip qubes dnat-dns ip daddr "$ip" tcp dport 53 dnat to "$ip" done fi } update_dns # check for /etc/resolv.conf content change inotifywait -m -q -e close_write /etc/resolv.conf | while read -r; do update_dns done
Make the script executable ``` sudo chmod +x /usr/local/bin/mullvad-dns.sh ``` And add this to run the script at boot time to `/rw/config/rc.local` ``` /usr/local/bin/mullvad-dns.sh & ```

Revision #5

Edited on
2024-04-07
Edited by user
apparatus
Add this to `/rw/config/qubes-firewall-user-script`

Revision #4

Edited on
2024-04-07
Edited by user
solene
DNS=10.64.01 DNS=10.64.0.1

Revision #3

Edited on
2024-03-15
Edited by user
solene
nft add rule qubes nat iifname == "vif*" udp dport 53 dnat "$DNS nft add rule qubes nat iifname == "vif*" udp dport 53 dnat "$DNS ```
``` "

Revision #2

Edited on
2024-03-15
Edited by user
solene
# Fix DNS > :information_source: The App uses a custom DNS by default (10.64.0.1) but this won't propagate to qubes behind it, leading to long waiting time for resolving hostnames. This command forces all DNS requests to go through a given DNS server, you can change the value to your favorite DNS server. ``` # Redirect all the DNS traffic to the preferred DNS server DNS=10.64.01 nft add chain qubes nat { type nat hook prerouting priority dstnat\; } nft add rule qubes nat iifname == "vif*" tcp dport 53 dnat "$DNS" nft add rule qubes nat iifname == "vif*" udp dport 53 dnat "$DNS
``` # Optional hardening: Avoid DNS leaks > :information_source: You may also want to force using a defined DNS server (9.9.9.9 in the current example) and blocking all other DNS servers (this avoids dns leaks)
# Redirect all the DNS traffic to the preferred DNS server DNS=9.9.9.9 nft add chain qubes nat { type nat hook prerouting priority dstnat\; } nft add rule qubes nat iifname == "vif*" tcp dport 53 dnat "$DNS" nft add rule qubes nat iifname == "vif*" udp dport 53 dnat "$DNS" "