network-proxy-setup.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # Source Qubes library.
  3. # shellcheck source=init/functions
  4. . /usr/lib/qubes/init/functions
  5. # Setup gateway for all the VMs this NetVM is servicing...
  6. network=$(qubesdb-read /qubes-netvm-network 2>/dev/null)
  7. if [ "x$network" != "x" ]; then
  8. if [ -e /proc/sys/kernel ] && ! [ -e /proc/sys/kernel/modules_disabled ]; then
  9. readonly modprobe_fail_cmd='true'
  10. else
  11. readonly modprobe_fail_cmd='false'
  12. fi
  13. gateway=$(qubesdb-read /qubes-netvm-gateway)
  14. gateway6=$(qubesdb-read /qubes-netvm-gateway6 ||:)
  15. #netmask=$(qubesdb-read /qubes-netvm-netmask)
  16. primary_dns=$(qubesdb-read /qubes-netvm-primary-dns 2>/dev/null || echo "$gateway")
  17. secondary_dns=$(qubesdb-read /qubes-netvm-secondary-dns)
  18. modprobe netbk 2> /dev/null || modprobe xen-netback || "${modprobe_fail_cmd}"
  19. echo "NS1=$primary_dns" > /var/run/qubes/qubes-ns
  20. echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
  21. /usr/lib/qubes/qubes-setup-dnat-to-ns
  22. echo "1" > /proc/sys/net/ipv4/ip_forward
  23. # enable also IPv6 forwarding, if IPv6 is enabled
  24. if [ -n "$gateway6" ]; then
  25. echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
  26. fi
  27. /sbin/ethtool -K "$(get_qubes_managed_iface)" sg off || true
  28. fi