debuggers.hg

view tools/examples/network-nat @ 3630:b3c74ea53d8a

bitkeeper revision 1.1159.223.53 (41fc0c19tGe1rM62SUQk8WYZjH-D1Q)

Add iptables modules to the default xen0 kernel, and add example configuration files for a NAT setup.
author iap10@labyrinth.cl.cam.ac.uk
date Sat Jan 29 22:20:09 2005 +0000 (2005-01-29)
parents
children 3a17f2625dc3
line source
1 #!/bin/sh
2 #============================================================================
3 # Default Xen network start/stop script.
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-route (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 yes).
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:-yes}
35 echo "network-nat $OP netdev=$netdev antispoof=$antispoof"
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}
75 echo 'Valid commands are: start, stop, status'
76 exit 1
77 esac