#!/bin/sh addrule() { if [ $FIRSTONE = yes ] ; then NS=$NS1 FIRSTONE=no else NS=$NS2 fi iptables -A PREROUTING -t nat -d $NS -p udp --dport 53 -j DNAT \ --to "$1" } export PATH=$PATH:/sbin:/bin source /var/run/qubes_ns if [ "X"$NS1 = "X" ] ; then exit ; fi iptables -t nat -F PREROUTING FIRSTONE=yes grep ^nameserver /etc/resolv.conf | head -2 | while read x y z ; do addrule "$y" done