ia64/xen-unstable
view tools/examples/vif-nat @ 4895:24dfd18ea63e
bitkeeper revision 1.1159.258.120 (42848bfe8kMyWWcBA64rq7h7l7AyoA)
Shadow code bug fix (found by Ian) that was breaking refcounts, and subsequently
causing migration problems.
Shadow code bug fix (found by Ian) that was breaking refcounts, and subsequently
causing migration problems.
author | mafetter@fleming.research |
---|---|
date | Fri May 13 11:14:06 2005 +0000 (2005-05-13) |
parents | d2e0edbc060d |
children | b11e02124f71 0dc3b8b8c298 |
line source
1 #!/bin/sh
2 #============================================================================
3 # /etc/xen/vif-nat
4 #
5 # Script for configuring a vif in routed-nat mode.
6 # Xend calls a vif script when bringing a vif up or down.
7 # This script is the default - but it can be configured for each vif.
8 #
9 # Example invocation:
10 #
11 # vif-nat up domain=VM1 vif=vif1.0 ip="192.168.0.10/31"
12 #
13 # Usage:
14 # vif-nat (up|down) {VAR=VAL}*
15 #
16 # Vars:
17 #
18 # domain name of the domain the interface is on (required).
19 # vif vif interface name (required).
20 # ip list of IP networks for the vif, space-separated (required).
21 #============================================================================
23 # Exit if anything goes wrong
24 set -e
26 echo "vif-nat $*"
28 # Operation name.
29 OP=$1
30 shift
32 # Pull variables in args into environment
33 for arg ; do export "${arg}" ; done
35 # Required parameters. Fail if not set.
36 domain=${domain:?}
37 vif=${vif:?}
38 ip=${ip:?}
40 # strip /netmask
41 vif_ip=`echo ${ip} | awk -F/ '{print $1}'`
43 main_ip=`ifconfig eth0 | grep "inet addr:" | sed -e 's/.*inet addr:\(\w\w*\.\w\w*\.\w\w*\.\w\w*\).*/\1/'`
45 # Are we going up or down?
46 case $OP in
47 up)
48 ifconfig ${vif} ${vif_ip} netmask 255.255.255.0 up
49 echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
50 iptcmd='-A'
51 ipcmd='a'
52 ;;
53 down)
54 ifconfig ${vif} down
55 iptcmd='-D'
56 ipcmd='d'
57 ;;
58 *)
59 echo 'Invalid command: ' $OP
60 echo 'Valid commands are: up, down'
61 exit 1
62 ;;
63 esac
65 ip r ${ipcmd} ${ip} dev ${vif} src ${main_ip}
66 # iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -p udp --sport 68 --dport 67 -j ACCEPT