2010-05-19 16:19:01 +02:00
|
|
|
#!/bin/sh
|
|
|
|
addrule()
|
|
|
|
{
|
|
|
|
if [ $FIRSTONE = yes ] ; then
|
|
|
|
FIRSTONE=no
|
2010-06-04 13:44:18 +02:00
|
|
|
RULE1="-A PREROUTING -d $NS1 -p udp --dport 53 -j DNAT --to $1"
|
2010-05-19 16:19:01 +02:00
|
|
|
else
|
2010-06-04 13:44:18 +02:00
|
|
|
RULE2="-A PREROUTING -d $NS2 -p udp --dport 53 -j DNAT --to $1"
|
2010-05-19 16:19:01 +02:00
|
|
|
NS=$NS2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
export PATH=$PATH:/sbin:/bin
|
|
|
|
source /var/run/qubes_ns
|
|
|
|
if [ "X"$NS1 = "X" ] ; then exit ; fi
|
|
|
|
iptables -t nat -F PREROUTING
|
|
|
|
FIRSTONE=yes
|
2010-06-04 13:44:18 +02:00
|
|
|
grep ^nameserver /etc/resolv.conf | head -2 |
|
|
|
|
(
|
|
|
|
while read x y z ; do
|
|
|
|
addrule "$y"
|
|
|
|
done
|
|
|
|
(echo "*nat"; echo $RULE1; echo $RULE2; echo COMMIT) | iptables-restore -n
|
|
|
|
)
|
|
|
|
|