core-agent-linux/vm-systemd/network-proxy-setup.sh

33 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/sh
# Source Qubes library.
# shellcheck source=init/functions
. /usr/lib/qubes/init/functions
2020-01-16 20:12:01 +01:00
# Setup gateway for all the VMs this NetVM is servicing...
network=$(qubesdb-read /qubes-netvm-network 2>/dev/null)
if [ "x$network" != "x" ]; then
if [ -e /proc/sys/kernel ] && ! [ -e /proc/sys/kernel/modules_disabled ]; then
2016-03-19 16:26:29 +01:00
readonly modprobe_fail_cmd='true'
else
2016-03-19 16:26:29 +01:00
readonly modprobe_fail_cmd='false'
fi
gateway=$(qubesdb-read /qubes-netvm-gateway)
gateway6=$(qubesdb-read /qubes-netvm-gateway6 ||:)
#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=$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
# enable also IPv6 forwarding, if IPv6 is enabled
if [ -n "$gateway6" ]; then
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
fi
/sbin/ethtool -K "$(get_qubes_managed_iface)" sg off || true
fi