2014-08-13 08:58:10 +02:00
|
|
|
#!/bin/sh
|
2011-04-23 02:31:54 +02:00
|
|
|
|
2013-06-07 05:20:55 +02:00
|
|
|
ip=`/usr/bin/qubesdb-read /qubes-ip 2> /dev/null`
|
2011-04-23 02:31:54 +02:00
|
|
|
if [ x$ip != x ]; then
|
2013-06-07 05:20:55 +02:00
|
|
|
netmask=`/usr/bin/qubesdb-read /qubes-netmask`
|
|
|
|
gateway=`/usr/bin/qubesdb-read /qubes-gateway`
|
|
|
|
secondary_dns=`/usr/bin/qubesdb-read /qubes-secondary-dns`
|
2011-04-23 02:32:54 +02:00
|
|
|
/sbin/ifconfig $INTERFACE $ip netmask 255.255.255.255
|
|
|
|
/sbin/ifconfig $INTERFACE up
|
2014-08-13 08:58:10 +02:00
|
|
|
/sbin/route add -host $gateway dev $INTERFACE
|
|
|
|
/sbin/route add default gw $gateway
|
2011-08-02 19:27:45 +02:00
|
|
|
/sbin/ethtool -K $INTERFACE sg off
|
2013-01-08 03:03:44 +01:00
|
|
|
/sbin/ethtool -K $INTERFACE tx off
|
2014-08-13 08:58:10 +02:00
|
|
|
echo "nameserver $gateway" > /etc/resolv.conf
|
2011-04-23 02:31:54 +02:00
|
|
|
echo "nameserver $secondary_dns" >> /etc/resolv.conf
|
2013-06-07 05:20:55 +02:00
|
|
|
network=$(/usr/bin/qubesdb-read /qubes-netvm-network 2>/dev/null)
|
2011-08-01 15:06:01 +02:00
|
|
|
if [ "x$network" != "x" ]; then
|
2013-06-07 05:20:55 +02:00
|
|
|
gateway=$(/usr/bin/qubesdb-read /qubes-netvm-gateway)
|
|
|
|
netmask=$(/usr/bin/qubesdb-read /qubes-netvm-netmask)
|
|
|
|
secondary_dns=$(/usr/bin/qubesdb-read /qubes-netvm-secondary-dns)
|
2013-03-13 02:26:40 +01:00
|
|
|
echo "NS1=$gateway" > /var/run/qubes/qubes-ns
|
|
|
|
echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
|
|
|
|
/usr/lib/qubes/qubes-setup-dnat-to-ns
|
|
|
|
[ -x /rw/config/qubes-ip-change-hook ] && /rw/config/qubes-ip-change-hook
|
|
|
|
# XXX: Backward compatibility
|
2011-08-18 15:49:49 +02:00
|
|
|
[ -x /rw/config/qubes_ip_change_hook ] && /rw/config/qubes_ip_change_hook
|
2011-08-01 15:06:01 +02:00
|
|
|
fi
|
2014-05-22 01:36:15 +02:00
|
|
|
if [ -f /var/run/qubes-service/network-manager ]; then
|
2014-11-09 05:31:22 +01:00
|
|
|
cat > /etc/NetworkManager/system-connections/qubes-uplink-$INTERFACE <<__EOF__
|
|
|
|
[802-3-ethernet]
|
|
|
|
duplex=full
|
|
|
|
|
|
|
|
[connection]
|
|
|
|
id=VM uplink $INTERFACE
|
|
|
|
uuid=de85f79b-8c3d-405f-a652-cb4c10b4f9ef
|
|
|
|
type=802-3-ethernet
|
|
|
|
|
|
|
|
[ipv6]
|
|
|
|
method=ignore
|
|
|
|
|
|
|
|
[ipv4]
|
|
|
|
method=manual
|
|
|
|
dns=$gateway;$secondary_dns
|
|
|
|
address1=$ip/32,$gateway
|
|
|
|
may-fail=false
|
2014-05-22 01:36:15 +02:00
|
|
|
__EOF__
|
2014-11-13 23:19:34 +01:00
|
|
|
chmod 600 /etc/NetworkManager/system-connections/qubes-uplink-$INTERFACE
|
2014-05-22 01:36:15 +02:00
|
|
|
fi
|
2011-04-23 02:31:54 +02:00
|
|
|
fi
|