core-agent-linux/network/setup-ip
Marek Marczykowski-Górecki 4ef785a016 network: use the same gateway IP generation method as backend
Backend domain generates its IP address based on frontend IP, not
settings given from dom0. So change frontend method to the same (for
DispVM it makes a difference). Now "qubes-gateway" xenstore entry is
basically primary DNS address only.
2014-08-13 08:12:37 +02:00

47 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
if [ -x /usr/sbin/xenstore-read ]; then
XENSTORE_READ="/usr/sbin/xenstore-read"
else
XENSTORE_READ="/usr/bin/xenstore-read"
fi
ip=`$XENSTORE_READ qubes-ip 2> /dev/null`
if [ x$ip != x ]; then
netmask=`$XENSTORE_READ qubes-netmask`
primary_dns=`$XENSTORE_READ qubes-gateway`
secondary_dns=`$XENSTORE_READ qubes-secondary-dns`
/sbin/ifconfig $INTERFACE $ip netmask 255.255.255.255
/sbin/ifconfig $INTERFACE up
gw_ip=${ip%.*}.1
/sbin/route add -host $gw_ip dev $INTERFACE
/sbin/route add default gw $gw_ip
/sbin/ethtool -K $INTERFACE sg off
/sbin/ethtool -K $INTERFACE tx off
echo "nameserver $primary_dns" > /etc/resolv.conf
echo "nameserver $secondary_dns" >> /etc/resolv.conf
network=$($XENSTORE_READ qubes-netvm-network 2>/dev/null)
if [ "x$network" != "x" ]; then
gateway=$($XENSTORE_READ qubes-netvm-gateway)
netmask=$($XENSTORE_READ qubes-netvm-netmask)
secondary_dns=$($XENSTORE_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
if [ -f /var/run/qubes-service/network-manager ]; then
cat > /etc/sysconfig/network-scripts/ifcfg-$INTERFACE <<__EOF__
DEVICE=$INTERFACE
IPADDR=$ip
NETMASK=255.255.255.255
NETWORK=$ip
ONBOOT=yes
GATEWAYDEV=$INTERFACE
GATEWAY=$gateway
__EOF__
fi
fi