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