Commit 9909ea70 authored by glucas's avatar glucas

ganeti/kvm-vif-bridge: now supports bridged mode.

parent 5d1c7ba9
......@@ -16,68 +16,86 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Include ARN variables
. /etc/ganeti/common-arn-vars
# exit on error so ganeti is aware and outputs the message to the user
set -e
VMNETCONF=$CONFDIR/$INSTANCE/net.conf
[ -r $VMNETCONF ] || exit 1
. $VMNETCONF
if [ "$MODE" = "routed" ]; then
# Include ARN variables
. /etc/ganeti/common-arn-vars
# Next-hop to route VM's IPs and subnets
NHIPv4=169.254.42.2
NHIPv6=fe80::42:2
VMNETCONF=$CONFDIR/$INSTANCE/net.conf
MYV4=$(/bin/ip -4 a s dev loopback1 | grep -Po "(?<=inet )[0-9\.]+(?=/32 scope global loopback1$)")
MYV6=$(/bin/ip -6 a s dev loopback1 | grep -Po "(?<=inet6 )[0-9a-f:]+(?=/128 scope global)")
[ -n $MYV4 ] || exit 2
[ -n $MYV6 ] || exit 2
[ -r $VMNETCONF ] || exit 1
. $VMNETCONF
# exit on error so ganeti is aware and outputs the message to the user
set -e
# Next-hop to route VM's IPs and subnets
NHIPv4=169.254.42.2
NHIPv6=fe80::42:2
MYV4=$(/bin/ip -4 a s dev loopback1 | grep -Po "(?<=inet )[0-9\.]+(?=/32 scope global loopback1$)")
MYV6=$(/bin/ip -6 a s dev loopback1 | grep -Po "(?<=inet6 )[0-9a-f:]+(?=/128 scope global)")
[ -n $MYV4 ] || exit 2
[ -n $MYV6 ] || exit 2
# Set name to VM's iface (tap)
ip link set dev $INTERFACE alias $INSTANCE-$INTERFACE_INDEX
# Set name to VM's iface (tap)
ip link set dev $INTERFACE alias $INSTANCE-$INTERFACE_INDEX
# Disabling IPv6 autoconfiguration from guest
/sbin/sysctl -w net.ipv6.conf.$INTERFACE.accept_ra=0
/sbin/sysctl -w net.ipv6.conf.$INTERFACE.autoconf=0
# Disabling IPv6 autoconfiguration from guest
/sbin/sysctl -w net.ipv6.conf.$INTERFACE.accept_ra=0
/sbin/sysctl -w net.ipv6.conf.$INTERFACE.autoconf=0
ip link set $INTERFACE up
ip link set $INTERFACE up
# Addressing VM's iface (tap)
ip address add 169.254.42.1/24 dev $INTERFACE scope link
ip address add fe80::42:1/112 dev $INTERFACE
# Addressing VM's iface (tap)
ip address add 169.254.42.1/24 dev $INTERFACE scope link
ip address add fe80::42:1/112 dev $INTERFACE
# Routing VM's IPs and subnets
if [ -n "$VIA" ]; then
viav4="via $NHIPv4"
viav6="via $NHIPv6"
fi
for ip in $IPV4_NET; do
ip route replace $ip dev $INTERFACE $viav4 src $MYV4 proto ganeti
done
# Routing VM's IPs and subnets
if [ -n "$VIA" ]; then
viav4="via $NHIPv4"
viav6="via $NHIPv6"
fi
for ip in $IPV4_NET; do
ip route replace $ip dev $INTERFACE $viav4 src $MYV4 proto ganeti
done
for ip in $IPV6_NET; do
ip route replace $ip dev $INTERFACE $viav6 src $MYV6 proto ganeti
done
# DDNS to allow VNC usage
if [[ $INSTANCE == *"vps-"* ]]; then
echo "server 89.234.141.65
zone arn-fai.net
update delete $INSTANCE-vnc.arn-fai.net CNAME
update add $INSTANCE-vnc.arn-fai.net 60 CNAME `hostname -f`
show
send" | nsupdate -v
fi
elif [ "$MODE" = "bridged" ]; then
# Fix the autogenerated MAC to have the first octet set to "fe"
# to discourage the bridge from using the TAP dev's MAC
FIXED_MAC=$(ip link show $INTERFACE | \
awk '{if ($1 == "link/ether") printf("fe%s",substr($2,3,15))}')
for ip in $IPV6_NET; do
ip route replace $ip dev $INTERFACE $viav6 src $MYV6 proto ganeti
done
# in case of a vif (xen_netback device) this action is not allowed
ip link set $INTERFACE address $FIXED_MAC || true
ip link set $INTERFACE up
ip link set $INTERFACE mtu $(</sys/class/net/${LINK}/mtu)
# DDNS to allow VNC usage
if [[ $INSTANCE == *"vps-"* ]]; then
echo "server 89.234.141.65
zone arn-fai.net
update delete $INSTANCE-vnc.arn-fai.net CNAME
update add $INSTANCE-vnc.arn-fai.net 60 CNAME `hostname -f`
show
send" | nsupdate -v
# Connect the interface to the bridge
brctl addif $LINK $INTERFACE
fi
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment