ia64/xen-unstable

view tools/examples/network-nat @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3b25e1de5efb
children e47e953c9e10
line source
1 #!/bin/sh
2 #============================================================================
3 # Default Xen network start/stop script when using NAT.
4 # Xend calls a network script when it starts.
5 # The script name to use is defined in /etc/xen/xend-config.sxp
6 # in the network-script field.
7 #
8 # Usage:
9 #
10 # network-nat (start|stop|status) {VAR=VAL}*
11 #
12 # Vars:
13 #
14 # netdev The gateway interface (default eth0).
15 # antispoof Whether to use iptables to prevent spoofing (default no).
16 #
17 #============================================================================
21 # Exit if anything goes wrong.
22 set -e
24 # First arg is the operation.
25 OP=$1
26 shift
28 # Pull variables in args in to environment.
29 for arg ; do export "${arg}" ; done
31 netdev=${netdev:-eth0}
32 # antispoofing not yet implemented
33 antispoof=${antispoof:-no}
35 echo "*network-nat $OP netdev=$netdev antispoof=$antispoof" >&2
38 op_start() {
39 echo 1 >/proc/sys/net/ipv4/ip_forward
40 iptables -t nat -A POSTROUTING -o ${netdev} -j MASQUERADE
41 }
44 op_stop() {
45 iptables -t nat -D POSTROUTING -o ${netdev} -j MASQUERADE
46 }
49 show_status() {
50 echo '============================================================'
51 ifconfig
52 echo ' '
53 ip route list
54 echo ' '
55 route -n
56 echo '============================================================'
58 }
60 case ${OP} in
61 start)
62 op_start
63 ;;
65 stop)
66 op_stop
67 ;;
69 status)
70 show_status
71 ;;
73 *)
74 echo 'Unknown command: ' ${OP} >&2
75 echo 'Valid commands are: start, stop, status' >&2
76 exit 1
77 esac