4 # Copyright (C) 2011, 2012 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 if [ -z "$INTERFACE" ]; then
22 echo "No network interface specified"
26 if [ -z "$MODE" ]; then
27 echo "MODE not specified"
31 # Execute the user-supplied network script, if applicable
32 if [ -x "@SYSCONFDIR@/ganeti/kvm-vif-bridge" ]; then
33 exec @SYSCONFDIR@/ganeti/kvm-vif-bridge
36 ip link set $INTERFACE up
38 if [ "$MODE" = "bridged" ]; then
39 ip link set $INTERFACE mtu $(</sys/class/net/${BRIDGE}/mtu)
41 # Connect the interface to the bridge
42 brctl addif $BRIDGE $INTERFACE
45 echo "Routed NIC but no IP address specified"
49 # Route traffic targeted at the IP to the interface
50 if [ -n "$LINK" ]; then
51 while ip rule del dev $INTERFACE; do :; done
52 ip rule add dev $INTERFACE table $LINK
53 ip route replace $IP table $LINK proto static dev $INTERFACE
56 ip route replace $IP proto static dev $INTERFACE
59 if [ -d "/proc/sys/net/ipv4/conf/$INTERFACE" ]; then
60 echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/proxy_arp
61 echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
64 if [ -d "/proc/sys/net/ipv6/conf/$INTERFACE" ]; then
65 echo 1 > /proc/sys/net/ipv6/conf/$INTERFACE/proxy_ndp
66 echo 1 > /proc/sys/net/ipv6/conf/$INTERFACE/forwarding