network: use qubes-primary-dns QubesDB entry if present

For a long time the DNS address was the same as default gateway. This is
still the case in R3.x, but using `qubes-gateway` configuration
parameter for it is misleading. It should be up to dom0 to provide DNS
address (whether the value is the same as gateway or not).

Fixes QubesOS/qubes-issues#1817
This commit is contained in:
Marek Marczykowski-Górecki 2016-03-07 13:37:45 +01:00
parent d181cf5cff
commit fb9b3b62c0
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 9 additions and 5 deletions

View File

@ -13,6 +13,7 @@ ip=`/usr/bin/qubesdb-read /qubes-ip 2> /dev/null`
if [ x$ip != x ]; then
netmask=`/usr/bin/qubesdb-read /qubes-netmask`
gateway=`/usr/bin/qubesdb-read /qubes-gateway`
primary_dns=`/usr/bin/qubesdb-read /qubes-primary-dns 2>/dev/null || echo $gateway`
secondary_dns=`/usr/bin/qubesdb-read /qubes-secondary-dns`
/sbin/ethtool -K $INTERFACE sg off
/sbin/ethtool -K $INTERFACE tx off
@ -39,7 +40,7 @@ method=manual
may-fail=false
__EOF__
if [ "x$disabledns" != "x1" ]; then
echo "dns=$gateway;$secondary_dns" >> $nm_config
echo "dns=$primary_dns;$secondary_dns" >> $nm_config
fi
if [ "x$disablegw" != "x1" ]; then
echo "addresses1=$ip;32;$gateway" >> $nm_config
@ -58,7 +59,7 @@ __EOF__
if ! grep -rq "^/etc/resolv[.]conf$" "${PROTECTED_FILE_LIST}" 2>/dev/null; then
echo > /etc/resolv.conf
if [ "x$disabledns" != "x1" ]; then
echo "nameserver $gateway" > /etc/resolv.conf
echo "nameserver $primary_dns" > /etc/resolv.conf
echo "nameserver $secondary_dns" >> /etc/resolv.conf
fi
fi
@ -67,8 +68,9 @@ __EOF__
if [ "x$network" != "x" ] && [ "x$disabledns" != "x1" ]; then
gateway=$(qubesdb-read /qubes-netvm-gateway)
netmask=$(qubesdb-read /qubes-netvm-netmask)
primary_dns=$(qubesdb-read /qubes-netvm-primary-dns 2>/dev/null || echo $gateway)
secondary_dns=$(qubesdb-read /qubes-netvm-secondary-dns)
echo "NS1=$gateway" > /var/run/qubes/qubes-ns
echo "NS1=$primary_dns" > /var/run/qubes/qubes-ns
echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
/usr/lib/qubes/qubes-setup-dnat-to-ns
fi

View File

@ -26,9 +26,10 @@ start()
if [ "x$network" != "x" ]; then
gateway=$(/usr/bin/qubesdb-read /qubes-netvm-gateway)
netmask=$(/usr/bin/qubesdb-read /qubes-netvm-netmask)
primary_dns=$(/usr/bin/qubesdb-read /qubes-netvm-primary-dns || echo $gateway)
secondary_dns=$(/usr/bin/qubesdb-read /qubes-netvm-secondary-dns)
modprobe netbk 2> /dev/null || modprobe xen-netback
echo "NS1=$gateway" > /var/run/qubes/qubes-ns
echo "NS1=$primary_dns" > /var/run/qubes/qubes-ns
echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
/usr/lib/qubes/qubes-setup-dnat-to-ns
echo "1" > /proc/sys/net/ipv4/ip_forward

View File

@ -12,9 +12,10 @@ if [ "x$network" != "x" ]; then
gateway=$(qubesdb-read /qubes-netvm-gateway)
netmask=$(qubesdb-read /qubes-netvm-netmask)
primary_dns=$(qubesdb-read /qubes-netvm-primary-dns 2>/dev/null || echo $gateway)
secondary_dns=$(qubesdb-read /qubes-netvm-secondary-dns)
modprobe netbk 2> /dev/null || modprobe xen-netback || "${modprobe_fail_cmd}"
echo "NS1=$gateway" > /var/run/qubes/qubes-ns
echo "NS1=$primary_dns" > /var/run/qubes/qubes-ns
echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
/usr/lib/qubes/qubes-setup-dnat-to-ns
echo "1" > /proc/sys/net/ipv4/ip_forward