network-proxy-setup.sh 1.1 KB

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