core-agent-linux/netvm/qubes_setup_dnat_to_ns
Rafal Wojtczuk 952d2f1d8e Get rid of dnsmasq in netvm.
qubes_setup_dnat_to_ns script sets up DNAT rules for DNS traffic; it is
triggered by dhclient or NetworkManager, and manually (in case there is
a static resolv.conf).

Put IP-dependent rules in qubes-core, after local ip is known. It could be
further improved by introducing custom chains, to enable iptables save.

Restrict FORWARD.
2010-05-30 15:45:35 +02:00

21 lines
490 B
Bash
Executable File

#!/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