cd /etc/NetworkManager/dispatcher.d/ cat > cs << 'EOF' #!/bin/bash case $2 in vpn-up) iptables -t nat -A OUTPUT -p udp -m udp --dport 53 -j DNAT --to-destination 10.31.33.7 iptables -t nat -A OUTPUT -p tcp -m tcp --dport 53 -j DNAT --to-destination 10.31.33.7 ip6tables -t nat -A OUTPUT -p udp -m udp --dport 53 -j DNAT --to-destination 2001:db8::7 ip6tables -t nat -A OUTPUT -p tcp -m tcp --dport 53 -j DNAT --to-destination 2001:db8::7 ;; vpn-down) iptables -t nat -D OUTPUT -p udp -m udp --dport 53 -j DNAT --to-destination 10.31.33.7 iptables -t nat -D OUTPUT -p tcp -m tcp --dport 53 -j DNAT --to-destination 10.31.33.7 ip6tables -t nat -D OUTPUT -p udp -m udp --dport 53 -j DNAT --to-destination 2001:db8::7 ip6tables -t nat -D OUTPUT -p tcp -m tcp --dport 53 -j DNAT --to-destination 2001:db8::7 ;; esac EOF chmod +x cs
cd /etc/NetworkManager/dispatcher.d/ cat > cs << 'EOF' #!/bin/bash case $2 in vpn-up) nft add rule ip nat output udp dport 53 dnat to 10.31.33.7 nft add rule ip nat output tcp dport 53 dnat to 10.31.33.7 nft add rule ip6 nat output udp dport 53 dnat to 2001:db8::7 nft add rule ip6 nat output tcp dport 53 dnat to 2001:db8::7 ;; vpn-down) nft delete rule ip nat output udp dport 53 dnat to 10.31.33.7 nft delete rule ip nat output tcp dport 53 dnat to 10.31.33.7 nft delete rule ip6 nat output udp dport 53 dnat to 2001:db8::7 nft delete rule ip6 nat output tcp dport 53 dnat to 2001:db8::7 ;; esac EOF chmod +x cs
sudo tee /etc/NetworkManager/dispatcher.d/cs > /dev/null << 'EOF' #!/bin/bash case $2 in vpn-up) cp /etc/resolv.conf /etc/resolv.conf.bak echo nameserver 10.31.33.7 > /etc/resolv.conf echo nameserver 2001:db8::7 >> /etc/resolv.conf ;; vpn-down) mv -f /etc/resolv.conf.bak /etc/resolv.conf ;; esac EOF sudo chmod +x /etc/NetworkManager/dispatcher.d/cs
VPN_FIREWALL=1then save/close the file.
User=tunnel Group=tunneland change the line:
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SETPCAP CAP_SYS_CHROOT CAP_DAC_OVERRIDEto:
AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SETPCAP CAP_SYS_CHROOT CAP_DAC_OVERRIDE(so just change the text CapabilityBoundingSet to AmbientCapabilities)
persist-tun persist-keyand change the line (near the top):
dev tunto:
dev tun0then remove any remote lines that have an IPv6 address (since Whonix has no IPv6 support), then save/close the file.
After=network.targetto:
After=network.target openvpn-client@Singapore_TCP.servicethen save/close the file, then run the command: sudo systemctl daemon-reload
WORKSTATION_FIREWALL=1 TUNNEL_FIREWALL_ENABLE=truethen save/close the file.
User=tunnel Group=tunneland change the line:
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SETPCAP CAP_SYS_CHROOT CAP_DAC_OVERRIDEto:
AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SETPCAP CAP_SYS_CHROOT CAP_DAC_OVERRIDE(so just change the text CapabilityBoundingSet to AmbientCapabilities)
After=network-online.target Wants=network-online.targetto:
After=network-online.target tor.service Wants=network-online.target tor.service
persist-tun persist-key script-security 2 up "/etc/openvpn/cs-dns script_type=up dev=tun0" down "/etc/openvpn/cs-dns script_type=down dev=tun0"and change the line (near the top):
dev tunto:
dev tun0then save/close that file.
#!/bin/bash case "$script_type" in up) echo "nameserver 10.31.33.7" > /etc/resolv.conf ;; down) echo "nameserver 10.152.152.10" > /etc/resolv.conf ;; esac
sudo tee -a /rw/config/rc.local > /dev/null << 'EOF' CSVPN_DNS="/rw/config/csvpn/csdns" if [[ -f $CSVPN_DNS ]]; then cp -f $CSVPN_DNS /etc/NetworkManager/dispatcher.d/ fi EOF sudo tee /rw/config/csvpn/csdns > /dev/null << 'EOF' #!/usr/bin/sh CSDNS="10.31.33.7" ORIGINAL_RULES="/rw/config/csvpn/original.rules" if ! [ -f "$ORIGINAL_RULES" ]; then nft list chain ip qubes dnat-dns > $ORIGINAL_RULES fi if [[ ( "$DEVICE_IFACE" == cs-* || "$DEVICE_IFACE" == tun* ) && ( "$2" == "up" || "$2" == "vpn-up" ) ]]; then nft flush chain ip qubes dnat-dns nft add rule ip qubes dnat-dns ip daddr 10.139.1.1 udp dport 53 dnat to $CSDNS nft add rule ip qubes dnat-dns ip daddr 10.139.1.1 tcp dport 53 dnat to $CSDNS nft add rule ip qubes dnat-dns ip daddr 10.139.1.2 udp dport 53 dnat to $CSDNS nft add rule ip qubes dnat-dns ip daddr 10.139.1.2 tcp dport 53 dnat to $CSDNS chmod -x /etc/NetworkManager/dispatcher.d/qubes-nmhook fi if [[ ( "$DEVICE_IFACE" == cs-* || "$DEVICE_IFACE" == tun* ) && ( "$2" == "down" || "$2" == "vpn-down" ) ]]; then nft flush chain ip qubes dnat-dns chmod +x /etc/NetworkManager/dispatcher.d/qubes-nmhook if [ -f $ORIGINAL_RULES ]; then nft -f $ORIGINAL_RULES rm -f $ORIGINAL_RULES fi fi EOF sudo chmod +x /rw/config/csvpn/csdns sudo /rw/config/rc.local
sudo nft flush chain qubes custom-forward sudo nft flush chain ip6 qubes custom-forward sudo nft insert rule qubes custom-forward oifname eth0 counter drop sudo nft insert rule ip6 qubes custom-forward oifname eth0 counter drop sudo nft insert rule qubes custom-forward iifname eth0 counter drop sudo nft insert rule ip6 qubes custom-forward iifname eth0 counter drop
sudo tee /etc/NetworkManager/dispatcher.d/cs > /dev/null << 'EOF' #!/bin/bash case $2 in up) cp /etc/resolv.conf /etc/resolv.conf.bak echo nameserver 10.31.33.7 > /etc/resolv.conf echo nameserver 2001:db8::7 >> /etc/resolv.conf ;; down) mv /etc/resolv.conf.bak /etc/resolv.conf ;; esac EOF sudo chmod +x /etc/NetworkManager/dispatcher.d/cs
sudo tee /etc/NetworkManager/dispatcher.d/cs > /dev/null << 'EOF' #!/bin/bash case $2 in up) cp /etc/resolv.conf /etc/resolv.conf.bak echo nameserver 10.31.33.7 > /etc/resolv.conf echo nameserver 2001:db8::7 >> /etc/resolv.conf ;; down) mv /etc/resolv.conf.bak /etc/resolv.conf ;; esac EOF sudo chmod +x /etc/NetworkManager/dispatcher.d/cs
sudo tee /etc/NetworkManager/dispatcher.d/cs > /dev/null << 'EOF' #!/bin/bash case $2 in up) cp /etc/resolv.conf /etc/resolv.conf.bak echo nameserver 10.31.33.7 > /etc/resolv.conf echo nameserver 2001:db8::7 >> /etc/resolv.conf ;; down) mv -f /etc/resolv.conf.bak /etc/resolv.conf ;; esac EOF sudo chmod +x /etc/NetworkManager/dispatcher.d/cs
sudo tee -a /rw/config/rc.local > /dev/null << 'EOF' CSVPN_DNS="/rw/config/csvpn/csdns" if [[ -f $CSVPN_DNS ]]; then cp -f $CSVPN_DNS /etc/NetworkManager/dispatcher.d/ fi EOF sudo tee /rw/config/csvpn/csdns > /dev/null << 'EOF' #!/usr/bin/sh CSDNS="10.31.33.7" ORIGINAL_RULES="/rw/config/csvpn/original.rules" if ! [ -f "$ORIGINAL_RULES" ]; then nft list chain ip qubes dnat-dns > $ORIGINAL_RULES fi if [[ ( "$DEVICE_IFACE" == cs-* || "$DEVICE_IFACE" == tun* ) && ( "$2" == "up" || "$2" == "vpn-up" ) ]]; then nft flush chain ip qubes dnat-dns nft add rule ip qubes dnat-dns ip daddr 10.139.1.1 udp dport 53 dnat to $CSDNS nft add rule ip qubes dnat-dns ip daddr 10.139.1.1 tcp dport 53 dnat to $CSDNS nft add rule ip qubes dnat-dns ip daddr 10.139.1.2 udp dport 53 dnat to $CSDNS nft add rule ip qubes dnat-dns ip daddr 10.139.1.2 tcp dport 53 dnat to $CSDNS chmod -x /etc/NetworkManager/dispatcher.d/qubes-nmhook fi if [[ ( "$DEVICE_IFACE" == cs-* || "$DEVICE_IFACE" == tun* ) && ( "$2" == "down" || "$2" == "vpn-down" ) ]]; then nft flush chain ip qubes dnat-dns chmod +x /etc/NetworkManager/dispatcher.d/qubes-nmhook if [ -f $ORIGINAL_RULES ]; then nft -f $ORIGINAL_RULES rm -f $ORIGINAL_RULES fi fi EOF sudo chmod +x /rw/config/csvpn/csdns sudo /rw/config/rc.local
sudo nft flush chain qubes custom-forward sudo nft insert rule qubes custom-forward oifname eth0 counter drop sudo nft insert rule ip6 qubes custom-forward oifname eth0 counter drop sudo nft insert rule qubes custom-forward iifname eth0 counter drop sudo nft insert rule ip6 qubes custom-forward iifname eth0 counter drop