core-agent-linux/network/setup-ip

53 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2013-06-07 05:20:55 +02:00
ip=`/usr/bin/qubesdb-read /qubes-ip 2> /dev/null`
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`
/sbin/ifconfig $INTERFACE $ip netmask 255.255.255.255
/sbin/ifconfig $INTERFACE up
/sbin/route add -host $gateway dev $INTERFACE
/sbin/route add default gw $gateway
/sbin/ethtool -K $INTERFACE sg off
/sbin/ethtool -K $INTERFACE tx off
echo "nameserver $gateway" > /etc/resolv.conf
echo "nameserver $secondary_dns" >> /etc/resolv.conf
if [ -f /var/run/qubes-service/network-manager ]; then
cat > /etc/NetworkManager/system-connections/qubes-uplink-$INTERFACE <<__EOF__
[802-3-ethernet]
duplex=full
[ethernet]
mac-address=`ip l show dev $INTERFACE |grep link|awk '{print $2}'`
[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
__EOF__
2014-11-13 23:19:34 +01:00
chmod 600 /etc/NetworkManager/system-connections/qubes-uplink-$INTERFACE
fi
network=$(qubesdb-read /qubes-netvm-network 2>/dev/null)
if [ "x$network" != "x" ]; then
gateway=$(qubesdb-read /qubes-netvm-gateway)
netmask=$(qubesdb-read /qubes-netvm-netmask)
secondary_dns=$(qubesdb-read /qubes-netvm-secondary-dns)
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
[ -x /rw/config/qubes_ip_change_hook ] && /rw/config/qubes_ip_change_hook
fi
fi