#!/bin/bash set -e if [ ! -e /var/run/qubes-service/vpn-exclude-domains ]; then rm -f /etc/dnsmasq.d/50-qubes-vpn-exclude.conf exit 0 fi if [ ! -e /rw/config/qubes-vpn-exclude.list ]; then echo "# List of domains that should be excluded from the VPN proxy." \ > /rw/config/qubes-vpn-exclude.list fi temp="$(mktemp)" trap 'rm "$temp"' EXIT cat > "$temp" <> "$temp" for dns in $NS1 $NS2; do echo "server=/$domain/$dns" >> "$temp" done echo >> "$temp" fi done < /rw/config/qubes-vpn-exclude.list if [ -z "$domains" ]; then rm -f /etc/dnsmasq.d/50-qubes-vpn-exclude.conf exit 0 fi # For all other domains that are not excluded we fall back to the DNS provided # by the VPN. for dns in $(cat /var/run/qubes/qubes-vpn-ns); do echo "server=$dns" >> "$temp" done cp "$temp" /etc/dnsmasq.d/50-qubes-vpn-exclude.conf