natbox-netperf.rcS revision 1362:88a3afa44545
1#!/bin/sh
2EXTIF=192.168.0.2
3INTIF=10.0.0.1
4CLIENT=10.0.0.2
5
6echo "setting up network..."
7ifconfig lo 127.0.0.1
8ifconfig eth0 $EXTIF txqueuelen 1000
9ifconfig eth1 $INTIF txqueuelen 1000
10
11echo "0" > /proc/sys/net/ipv4/tcp_timestamps
12echo "0" > /proc/sys/net/ipv4/tcp_sack
13echo "1" > /proc/sys/net/ipv4/tcp_vegas_cong_avoid
14
15echo "5000000 5000000 5000000" > /proc/sys/net/ipv4/tcp_rmem
16echo "5000000 5000000 5000000" > /proc/sys/net/ipv4/tcp_wmem
17echo "5000000 5000000 5000000" > /proc/sys/net/ipv4/tcp_mem
18echo "262143" > /proc/sys/net/core/rmem_max
19echo "262143" > /proc/sys/net/core/wmem_max
20echo "262143" > /proc/sys/net/core/rmem_default
21echo "262143" > /proc/sys/net/core/wmem_default
22echo "262143" > /proc/sys/net/core/optmem_max
23echo "100000" > /proc/sys/net/core/netdev_max_backlog
24
25echo "1" > /proc/sys/net/ipv4/ip_forward
26
27echo "waiting for netserver..."
28/usr/bin/netcat -c -l -p 8000
29
30echo "setting up iptables..."
31IPTABLES=/sbin/iptables
32EXTIF=eth0
33INTIF=eth1
34
35$IPTABLES -P INPUT ACCEPT
36$IPTABLES -F INPUT
37$IPTABLES -P OUTPUT ACCEPT
38$IPTABLES -F OUTPUT
39$IPTABLES -P FORWARD DROP
40$IPTABLES -F FORWARD
41$IPTABLES -t nat -F
42
43$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
44$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
45$IPTABLES -A FORWARD -j LOG
46
47$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
48
49echo "informing client..."
50echo "server ready" | /usr/bin/netcat -c $CLIENT 8000
51
52echo "starting bash..."
53exec /bin/bash
54