/[LeafOK_CVS]/pvpgn-1.7.4/scripts/bnetmasq.sh
ViewVC logotype

Contents of /pvpgn-1.7.4/scripts/bnetmasq.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:37 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-sh
no message

1 #!/bin/sh
2
3 # Author: Marco Ziech (mmz@gmx.net)
4 # Date: Jan-24-2000
5 #
6 # Bnetd UDP masquerade for Linux
7 #
8 # NOTE:
9 # This script is not needed if you have "loose UDP" turned
10 # on. It was a patch around the 2.2 series. It automates
11 # all of this for any "well behaved" peer-to-peer games,
12 # not just for Battle.net clients.
13 #
14 # Kernel:
15 # This script should work fine with 2.2 kernels but I don't
16 # know if it works with older kernels too.
17 #
18 # Installation:
19 # Copy this file into your local init.d directory.
20 # The position of this directory may vary with diffrent
21 # linux distributions.
22 # On Debian/GNU Linux it's /etc/init.d
23 # On S.u.S.E. Linux it's /sbin/init.d (I guess)
24 # To start the script on system startup you have to
25 # make a symlink to this file from a filename like
26 # "S99bnetmasq.sh" in the rc2.d directory. To stop it
27 # on system shutdown do the same with "K01bnetmasq.sh"
28 # in the rc0.d, rc1.d and rc6.d directories. These
29 # directories are usually in the same as the init.d
30 # directory.
31 # If you have a dial-up connection and want to start the
32 # script on dial-in you have to put a script which starts
33 # or stops this script in /etc/ppp/ip-up.d and
34 # /etc/ppp/ip-down.d .
35 #
36 # Using on original Bnet:
37 # This script should also work with the original Battle.net.
38 #
39 # Using on servers not running on your masquerading gateway:
40 # Outside servers like the real Battle.net will not
41 # know your correct address, only your internal IP:port.
42 # to fix it, either bnproxy needs to be improved to
43 # be used instead of ipmasq or this need to do some
44 # content altering like with the ftp script.
45 # --- Thanks to Ross Combs for these corrections.
46
47 # This is the destination port on the clients. It is usually 6112.
48 BNET_PORT=6112
49
50 # This is the list of the destination hosts with their ports on
51 # the firewall. The list should look like this:
52 # client1IP:GW1port client2IP:GW2port ... clientNIP:GWNport
53 # Remember that each port can only be allocated by one client.
54 # Some ports may already be reserved by some programs.
55 # I recomment using ports between 5000 and 7000. See
56 # /etc/services on information about assigned ports.
57 REDIR_LIST="192.168.1.1:5000 192.168.1.2:5001"
58
59 # This is the external interface i.e. the interface which is
60 # connected to the Internet. On dial-up links this is usually
61 # ppp0 or ippp0 (for ISDN).
62 EXTERNAL_IF=eth0
63
64 # ------------------- END OF CONFIG SECTION -----------------
65
66 # This determines the ip of the external interface
67 EXTERNAL_IP=`LANGUAGE="C" LC_ALL="C" ifconfig $EXTERNAL_IF | grep 'inet addr:' | sed 's/.*inet addr:\([0-9.]*\).*/\1/g'`
68
69 case "$1" in
70 start)
71 echo -n "Starting bnet masquerading: "
72 for i in $REDIR_LIST; do
73 echo -n "$i "
74 D_HOST="`echo $i | sed -e 's/:/ /g' | awk '{ print $1 }'`"
75 D_PORT="`echo $i | sed -e 's/:/ /g' | awk '{ print $2 }'`"
76 ipmasqadm portfw -a -P udp -L $EXTERNAL_IP $D_PORT -R $D_HOST $BNET_PORT
77 # FIXME: according to: http://www.mail-archive.com/masq@tori.indyramp.com/msg01538.html
78 #> setting up a single machine would look like:
79 #> # ipmasqadm portfw -a -P tcp -L $1 6112 -R $2 6112
80 #> # ipmasqadm portfw -a -P tcp -L $3 6112 -R $2 6112
81 #> # ipmasqadm portfw -a -P udp -L $1 6112 -R $2 6112
82 #> # ipmasqadm portfw -a -P udp -L $3 6112 -R $2 6112
83 #> Replace $1 with the internal IP address of your gateway machine, $2
84 #> with the address (internal again, but it should be the only) of the
85 #> machine you're playing starcraft on and $3 with the external IP ad-
86 #> dress of the gateway machine.
87 # This implies that
88 # inside_gw --> client
89 # outside_gw --> inside_gw
90 # this script doesn't do the gw --> gw setup.... does it need to?!
91
92 done
93 echo "."
94 ;;
95 stop)
96 echo -n "Stopping bnet masquerading: "
97 for i in $REDIR_LIST; do
98 echo -n "$i "
99 D_PORT="`echo $i | sed -e 's/:/ /g' | awk '{ print $2 }'`"
100 ipmasqadm portfw -d -P udp -L $EXTERNAL_IP $D_PORT
101 done
102 echo "."
103 ;;
104
105 *)
106 echo "Usage: $0 {start|stop}"
107 exit 1
108 ;;
109 esac

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1