natbox-netperf.rcS revision 1648:4214fd0ea44d
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
14echo "262144" > /proc/sys/net/ipv4/ip_conntrack_max
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
24echo "1" > /proc/sys/net/ipv4/ip_forward
25
26echo "waiting for netserver..."
27/usr/bin/netcat -c -l -p 8000
28
29echo "setting up iptables..."
30IPTABLES=/sbin/iptables
31EXTIF=eth0
32INTIF=eth1
33
34$IPTABLES -P INPUT ACCEPT
35$IPTABLES -F INPUT
36$IPTABLES -P OUTPUT ACCEPT
37$IPTABLES -F OUTPUT
38$IPTABLES -P FORWARD DROP
39$IPTABLES -F FORWARD
40$IPTABLES -t nat -F
41
42$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
43$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
44$IPTABLES -A FORWARD -j LOG
45
46$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
47
48echo "informing client..."
49sleep 5
50echo "server ready" | /usr/bin/netcat -c $CLIENT 8000
51
52echo "starting bash..."
53exec /bin/bash
54