setup_ip 1.1 KB

1234567891011121314151617181920212223242526
  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. echo "nameserver $gateway" > /etc/resolv.conf
  13. echo "nameserver $secondary_dns" >> /etc/resolv.conf
  14. network=$(/usr/bin/xenstore-read qubes_netvm_network 2>/dev/null)
  15. if [ "x$network" != "x" ]; then
  16. gateway=$(/usr/bin/xenstore-read qubes_netvm_gateway)
  17. netmask=$(/usr/bin/xenstore-read qubes_netvm_netmask)
  18. secondary_dns=$(/usr/bin/xenstore-read qubes_netvm_secondary_dns)
  19. echo "NS1=$gateway" > /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. [ -x /rw/config/qubes_ip_change_hook ] && /rw/config/qubes_ip_change_hook
  23. fi
  24. fi