setup-ip 1.2 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. ip=`/usr/bin/xenstore-read qubes-ip 2> /dev/null`
  3. if [ x$ip != x ]; then
  4. netmask=`/usr/bin/xenstore-read qubes-netmask`
  5. gateway=`/usr/bin/xenstore-read qubes-gateway`
  6. secondary_dns=`/usr/bin/xenstore-read qubes-secondary-dns`
  7. /sbin/ifconfig $INTERFACE $ip netmask 255.255.255.255
  8. /sbin/ifconfig $INTERFACE up
  9. /sbin/route add -host $gateway dev $INTERFACE
  10. /sbin/route add default gw $gateway
  11. /sbin/ethtool -K $INTERFACE sg off
  12. /sbin/ethtool -K $INTERFACE tx off
  13. echo "nameserver $gateway" > /etc/resolv.conf
  14. echo "nameserver $secondary_dns" >> /etc/resolv.conf
  15. network=$(/usr/bin/xenstore-read qubes-netvm-network 2>/dev/null)
  16. if [ "x$network" != "x" ]; then
  17. gateway=$(/usr/bin/xenstore-read qubes-netvm-gateway)
  18. netmask=$(/usr/bin/xenstore-read qubes-netvm-netmask)
  19. secondary_dns=$(/usr/bin/xenstore-read qubes-netvm-secondary-dns)
  20. echo "NS1=$gateway" > /var/run/qubes/qubes-ns
  21. echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
  22. /usr/lib/qubes/qubes-setup-dnat-to-ns
  23. [ -x /rw/config/qubes-ip-change-hook ] && /rw/config/qubes-ip-change-hook
  24. # XXX: Backward compatibility
  25. [ -x /rw/config/qubes_ip_change_hook ] && /rw/config/qubes_ip_change_hook
  26. fi
  27. fi