--- # Install VPN client(s). - name: Workstation | Software | VPN | Mullvad block: # https://mullvad.net/en/help/install-mullvad-app-linux - name: Workstation | Software | VPN | Mullvad | Add Repo [apt] ansible.builtin.shell: "{{ item }}" loop: - sudo curl -fsSLo /usr/share/keyrings/mullvad-keyring.asc https://repository.mullvad.net/deb/mullvad-keyring.asc - echo "deb [signed-by=/usr/share/keyrings/mullvad-keyring.asc arch=$( dpkg --print-architecture )] https://repository.mullvad.net/deb/stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mullvad.list - apt update when: ansible_pkg_mgr == "apt" register: shell_check changed_when: shell_check.rc == 0 - name: Workstation | Software | VPN | Mullvad | Add Repo [dnf] ansible.builtin.shell: "{{ item }}" loop: - sudo dnf config-manager --add-repo https://repository.mullvad.net/rpm/stable/mullvad.repo when: ansible_pkg_mgr == "dnf" register: shell_check changed_when: shell_check.rc == 0 - name: Workstation | Software | VPN | Install ansible.builtin.package: name: - mullvad-vpn state: present - name: Workstation | Software | VPN | Install (Artix, runit) ansible.builtin.package: name: - mullvad-vpn-runit state: present when: ansible_pkg_mgr == "pacman" and ansible_service_mgr == "runit" when: ansible_distribution in ("Debian", "Ubuntu") or ansible_pkg_mgr in ("pacman", "dnf") ## Specific Distros ## - name: Workstation | Software | VPN | Mullvad | Devuan (runit) block: - name: Workstation | Software | VPN | Mullvad | Devuan | Facts 01 ansible.builtin.set_fact: devuan_mullvad_dir: "{{ global_src }}/mullvad-installer" mullvad_deb_url: https://mullvad.net/en/download/app/deb/latest mullvad_repack_url: https://github.com/sys-fs/mullvad-repack - name: Workstation | Software | VPN | Mullvad | Devuan | Facts 02 ansible.builtin.set_fact: mullvad_repack_dir: "{{ devuan_mullvad_dir }}/mullvad_repack" - name: Workstation | Software | VPN | Mullvad | Devuan | Check ansible.builtin.stat: path: '/opt/Mullvad VPN' register: mullvad_installed - name: Workstation | Software | VPN | Mullvad | Devuan | Install ansible.builtin.shell: "{{ item }}" loop: - "mkdir -pv {{ devuan_mullvad_dir }}" - "curl -L -o {{ devuan_mullvad_dir }}/Mullvad.deb {{ mullvad_deb_url }}" - "rm -rfv {{ mullvad_repack_dir }}" - "git clone {{ mullvad_repack_url }} {{ mullvad_repack_dir }}" - "cd {{ mullvad_repack_dir }} && ./repack.sh ../Mullvad.deb" - "apt-get install -y --reinstall {{ devuan_mullvad_dir }}/Mullvad_repack.deb" when: not mullvad_installed.stat.exists register: shell_check changed_when: shell_check.rc == 0 when: ansible_pkg_mgr == "apt" and ansible_service_mgr != "systemd" ## Link & Enable ## - name: Workstation | Software | VPN | Mullvad | PATH | Facts 01 ansible.builtin.set_fact: mullvad_exe: 'mullvad-vpn' mullvad_exe_dir: '/opt/Mullvad\ VPN' - name: Workstation | Software | VPN | Mullvad | PATH | Facts 02 ansible.builtin.set_fact: mullvad_exe_new: "{{ global_bin }}/{{ mullvad_exe }}" - name: Workstation | Software | VPN | Mullvad | PATH | Facts (pacman) ansible.builtin.set_fact: mullvad_exe_dir: '/usr/bin' when: ansible_pkg_mgr == "pacman" - name: Workstation | Software | VPN | Mullvad | PATH | Install ansible.builtin.shell: "{{ item }}" loop: - rm {{ mullvad_exe_new }} || echo "File does not exist." - echo "#!/usr/bin/env sh" > {{ mullvad_exe_new }} - echo "cd {{ mullvad_exe_dir }}" >> {{ mullvad_exe_new }} - echo "./{{ mullvad_exe }}" >> {{ mullvad_exe_new }} - chmod +x {{ mullvad_exe_new }} register: shell_check changed_when: shell_check.rc == 0 - name: Workstation | Software | VPN | Mullvad | runit | Enable Service (mullvad-daemon) ansible.builtin.file: src: "{{ runit_script_dir }}/mullvad-daemon" dest: "{{ runit_service_dir }}/mullvad-daemon" state: link force: true when: ansible_service_mgr == "runit" - name: Workstation | Software | VPN | Mullvad | runit | Remove Old Service (mullvad) ansible.builtin.file: path: "{{ runit_service_dir }}/mullvad" state: absent when: ansible_service_mgr == "runit" - name: Workstation | Software | VPN | DNS Servers ansible.builtin.set_fact: # https://mullvad.net/en/help/dns-over-https-and-dns-over-tls dns_mullvad_all: "" # DEPRECATED 2026-11-02 # https://docs.quad9.net/services/ dns_quad9_malware: 9.9.9.9 149.112.112.112 # dns.quad9.net dns_quad9_noblock: 9.9.9.10 149.112.112.10 # dns10.quad9.net dns_quad9_malware_ecs: 9.9.9.11 149.112.112.11 # dns11.quad9.net, geo-location based servers # https://adguard-dns.io/en/public-dns.html dns_adguard_ads: 94.140.14.14 94.140.15.15 # tls://dns.adguard-dns.com dns_adguard_noblock: 94.140.14.140 94.140.14.141 # tls://unfiltered.adguard-dns.com dns_adguard_family: 94.140.14.15 94.140.15.16 # tls://family.adguard-dns.com # https://developers.cloudflare.com/1.1.1.1/ip-addresses/ dns_cloudflare_noblock: 1.1.1.1 1.0.0.1 dns_cloudflare_malware: 1.1.1.2 1.0.0.2 # Blocks malware. dns_cloudflare_family: 1.1.1.3 1.0.0.3 # Blocks malware and adult content. # https://controld.com/free-dns#quick-setups dns_controld_noblock: 76.76.2.0 76.76.10.0 # p0.freedns.controld.com, DNS only, no blocking. dns_controld_malware: "" # These guys block my subdomains, lol. Filed a false positive report 2026-11-23. # 76.76.2.1 76.76.10.1 # p1.freedns.controld.com, malware only. dns_controld_ads: "" # These guys block my subdomains, lol. Filed a false positive report 2026-11-23. # 76.76.2.2 76.76.10.2 # p2.freedns.controld.com, malware and ads. dns_controld_social: "" # These guys block my subdomains, lol. Filed a false positive report 2026-11-23. # 76.76.2.3 76.76.10.3 # p3.freedns.controld.com, ONLY does social, not ads or anything. dns_controld_family: "" # These guys block my subdomains, lol. Filed a false positive report 2026-11-23. # 76.76.2.4 76.76.10.4 # family.freedns.controld.com, still allows socials but blocks most everything else. dns_controld_all: "" # 76.76.2.11 is just the bootstrap IP, not a real server, use subdomain: # no-ads-porn-dating-gov-gambling-drugs-malware-typo-social.freedns.controld.com2 - name: Workstation | Software | VPN | Mullvad | Settings ansible.builtin.copy: dest: "{{ user_user.home }}/.mullvadrc" content: | # This file is managed by Ansible. # env-ansible/tasks/workstation/linux/software/vpn.yml # Mute STDOUT, saving it in FD3. if [[ -z $DEBUG && -z $VERBOSE ]]; then exec 3>&1 1>/dev/null fi export DNS_SERVERS_ALL="{{ dns_controld_all }} {{ dns_adguard_family }} {{ dns_controld_family }} {{ dns_cloudflare_family }} {{ dns_controld_ads }} {{ dns_adguard_ads }} {{ dns_quad9_malware }} {{ dns_controld_malware }} {{ dns_cloudflare_malware }} {{ dns_quad9_noblock }} {{ dns_adguard_noblock }} {{ dns_controld_noblock }} {{ dns_cloudflare_noblock }}" export DNS_SERVERS="{{ dns_controld_all }} {{ dns_adguard_family }} {{ dns_controld_family }} {{ dns_cloudflare_family }}" mullvad lan set allow # This allows Docker to forward ports to localhost! mullvad tunnel set ipv6 on # 2026-11-22 # Mullvad closed their DNS servers November 2nd 2026, and mid November # the internal DNS stopped recognizing my subdomains, so switching from # Mullvad DNS completely to test out a few other providers. #mullvad dns set default --block-ads --block-trackers --block-malware --block-gambling --block-adult-content --block-social-media mullvad dns set custom $DNS_SERVERS mullvad auto-connect set on mullvad lockdown-mode set on mullvad beta-program set off # Ensure system is connected if network is available. #mullvad disconnect #wifi off #reconnect >/dev/null 2>&1 & mullvad reconnect # Unmute STDOUT by restoring with FD3. if [[ -z $DEBUG && -z $VERBOSE ]]; then exec 1>&3 fi function dns_test() { dns_servers="${1:-$DNS_SERVERS}" echo " Using servers '$dns_servers'." domains="${2:-hyperling.com}" echo " Using domains '$domains'." loops="${3:-3}" echo " Looping '$loops' time(s)." echo -e "\n Starting Loop! \n" echo "| DNS IP | DNS Name | Domain Tested | Time (ms) | Loop# |" echo "| -----: | -------: | ------------: | --------: | ----: |" results="" for dns_server in $dns_servers; do # Allow the DNS server to be accessed. mullvad dns set custom $dns_server 1>/dev/null 2>&1 sleep 1 mullvad disconnect sleep 1 mullvad connect sleep 3 for domain in $domains; do loop=1 while (( loop <= loops )); do echo -n "| $dns_server" name=`dig -x $dns_server +short +time=5 +tries=1 2>/dev/null` status=$? if [[ $status != 0 ]]; then name="FAILED" fi echo -n " | $name" local query_time query_time=$(dig "$domain" @"$dns_server" +time=5 +tries=1 2>/dev/null \ | grep -oP 'Query time:\s+\K[0-9]+') if [[ -z "$query_time" ]]; then echo -n " | $domain | FAILED" else echo -n " | $domain | ${query_time}" fi results="${results}\n $query_time $dns_server $name" echo " | $loop |" (( loop++ )) done unset loop done done if [[ -n "$results" ]]; then echo -e "\n Sorted Results" echo -e "$results" | sort -rg fi echo -e "\n Resetting Mullvad DNS" mullvad dns set custom ${DNS_SERVERS:-9.9.9.9} } alias dns-test="dns_test " function dns_test_all() { dns-test "$DNS_SERVERS_ALL" "$2" "$3" } alias dns-test-all="dns_test_all " [[ $(whoami) != "root" ]] && echo "`date` - Ansible .mullvadrc loaded successfully!" owner: "{{ user }}" backup: false mode: "0755"