Go Back   BWHacks > StarCraft > Starcraft / Broodwar Gaming

Starcraft / Broodwar Gaming Topics relating to typical Starcraft gaming.

Reply
 
LinkBack Thread Tools

Old 07-16-2007, 05:40 PM   #1 (permalink)
TheTempest
Arbiter
Senior Member
Retired Staff Member

Blessed
 
TheTempest's Avatar
 
Join Date: Apr 2004
Posts: 2,092
TheTempest is a glorious beacon of lightTheTempest is a glorious beacon of lightTheTempest is a glorious beacon of light
Default How to play SC with friends behind same router: NO VPN Needed!!

Howdy,

So I finally learned how to program my router this weekend so I could test a theory I had about making SC work from behind the same router, without having the need for a VPN. I tested my theory this weekend with some friends of mine, and WALA! ****ing works =D

I have gotten two computers behind the same router to work in the same starcraft game with NO LAG! The solution to this problem is simple, have the router do NAT (Network Address Translation) for starcraft (since SC doesn't do it on it's own, like wc3).

DISCLAIMER:
Upgrading your firmware on your router is not something to be taken lightly. Please read all directions on OpenWRT (or where ever you get your bin from) for installation instructions. This is all at your own risk. I take no responsibility for anything. Please, if you don't understand this article...please do not attempt this without professional help.
Ok, that being said, I've flashed my router 6 times in the last 3 days, with different version from linksys, hyperwrt and openwrt. I can read directions, and therefore...no problem :-)

The problem:
Here's the deal, when two of you are in the same game, you both are comming from the same address...so when that information comes back and it's then up for the router to deliver that information to both of you, since you both are on the same WAN IP and same port number, the router doesnt know how to distuinguish between the two of you. So only one of you ends up getting the data, the other player is left in the dark (ie. gets NO information). Thus, the lag...

The solution:
NAT is simple. It basicly uses a port number to ID each computer behind the router so the router knows who to deliver the information to. You can think of this like WC3, going in the game settings and setting your port to 6114 (Computer A) and 6115 (Computer B) then all you have to do is tell the router, ok, if you see port 6114, you know that belongs to computer A, so forward the information there. Starcraft is a little more tricky than WC3, but it's simple:

Basicly, you give each IP address behind your router a SPECIAL # for a port (make up a nice high number like 64000-65535), and when you send packets from your network going to the WAN (Internet), you have the router change make it look like the packet came from the router. This way, the information comes back to the router. Now, all you have to do is change the port number so you can identify which computer sent the information. Then, once your router gets information that's on that speical port number, it knows which computer it's ment for...so all you have to do, is deliever it to that computer by chaning it's DESTINATION Address to match the local IP of your computer (ie. 192.168.1.1).


Maybe not that easy
Ok, there is one catch. You need to be able to program your router. No, I'm not talking about the ****ing http web gui (ie. port forwarding and triggering). You need to be able to login to the router with remote access (ie. telnet, ssh, etc...)

Ok, how do I do that:
Take your routers' make and model and look at openwrt. If they dont support your model (rare) then put your routers information into a google search. Then look for articles that are related to telnet, ssd (some good key words are: "root 192.168.1.(what ever your last number is for the router).

If you have any questions, and i have some free time, post up your modelnumber/router and I'll see if I can find you some way to do that.

Easiest Way:
Goto openWRT and see if they have a version for your router. Just use your version number. Simply download the correct *.bin file. Then use the linksys firmware update mechinism (you need to login to the router via http). Once the router returns. You'll be able to ssh to the router (use putty if your on windows). In putty, simply put: "root@192.168.1.1" for your username, the pass will be what ever you set the pass to be once the firmware update is complete.

Setup NAT for SC:
Once you got that all setup. Use putty (ssh) to login to the router. rembemer this is just like telnet (ie. having a remote DOS prompt), except it's linux. once in the router, do the following commands:

Code:
cd /etc
cp firewall.user firewall.user.bak
vi firewall.user
Ok, at this point, you should have the file open in VI (a linux text editor). Use wiki on vi to find out how to use it, it's really amazing, just kinda hard to start using. basicly, you move around using the keys on the keyboard. Once you find a place where you want to start typing, push 'i' on the keyboard, this turns vi into TEXT_INSERT mode. Once your done typing and you want to move around again. Just push ESC once. Then you can move around. Once your done making all your changes, simply press ESC a few times, to make sure your not in edit mode. Then type ":wq<enter>" This saves and exits. Now, all that's left to do, is put in the text that will make SC work:

Ok, 1.2.3.4 is the WAN address for your network (to get this, goto myipaddress.com, use what ever number is there). The other information is about LOCAL address (to get this information, use ipconfig). Each computer should have something different, ie. 192.168.1.4 for computer A, and 192.168.1.5 for computer B).

Put this into the end of the firewall.user file on the router:
remember: 1.2.3.4 needs to be replaced by your WAN address, see above
Also, 64001 == portNUMBER for 192.168.1.4 and 64002 == 192.168.1.5 (i picked those two numbers 64001,64002 to ID each computer)
Code:
#NAT for client1
iptables -t nat -I PREROUTING -p udp -d 1.2.3.4 --dport 64001 -j DNAT --to-destination 192.168.1.4:6112
iptables -t nat -I POSTROUTING -p udp -s 192.168.1.4 --sport 6112 -j SNAT --to-source 1.2.3.4:64001

#NAT for client2
iptables -t nat -I PREROUTING -p udp -d 1.2.3.4 --dport 64002 -j DNAT --to-destination 192.168.1.5:6112
iptables -t nat -I POSTROUTING -p udp -s 192.168.1.5 --sport 6112 -j SNAT --to-source 1.2.3.4:64002
That code makes any 6112 udp traffic comming from 192.168.1.4 or 192.168.1.5 "look" to everyone on the internet that it's comming from your router, so they reply to the router. The router then checks incomming information to see if it matches that speical port number, if it does, it knows that information is suposed to be routed to an internal computer, and so it changes the destination IP accordingly.

Post up here, if you have any REAL questions. ie. read up on google for a bit, then ask.

Also, please post some feedback.

Thanks.
TT

As Requested - Screenshots:
1) putty open with login information for a linksys router
2) this is what you should see after you have already gone to the web interface (ie. http://192.168.1.1) and clicked on system (this asks you to set the password)
3) this is what happens after you enter the correct password
4) this is the command to change directories to were the firewall.user file is stored (which is what you need to edit). For directions, see my 1st post in this thread.
5) this shows you how to restart the firewall (you do this after you've made your changes to the firewall.user file correctly).
Attached Images
File Type: jpg putty with login information.JPG (206.9 KB, 762 views)
File Type: jpg putty with login information - waiting for root passwd.JPG (172.8 KB, 503 views)
File Type: jpg 3-logged in.JPG (190.7 KB, 486 views)
File Type: jpg 4-cd etc.JPG (61.0 KB, 417 views)
File Type: jpg 5-firewall restart.JPG (41.9 KB, 453 views)
__________________

My signature is back!! Hell YES!

Click the link, I DEMAND YOU! :-D
http://www.bwhacks.com/forums/showthread.php?t=24873
TheTempest 15 0FF11|\|3   Reply With Quote
Advertisement
 
Advertisement
Advertisement Sponsored links


Old 07-16-2007, 06:12 PM   #2 (permalink)
YonderKnight
Senior Member
Gold Member

Evangelist
 
YonderKnight's Avatar
 
Join Date: Sep 2004
Location: USA, California
Posts: 1,392
YonderKnight is a name known to allYonderKnight is a name known to allYonderKnight is a name known to allYonderKnight is a name known to all
Send a message via AIM to YonderKnight
Default

O.o
Very nice TT!! Nice to see you still around! Wow, I never thought anyone could solve this problem =p.

I have a question that might be kind of dumb =p. If your router is using a "special port" for one of your computers, the other clients can still connect using that special port instead of the default one?

Also, it seems like this is a pretty "dangerous" process, maybe you should put a disclaimer or something. Instead of VI'ing firewall.user, would it be possible to do an ssh file transfer and edit it with windows? I think that would make things a tiny bit easier.
YonderKnight 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 06:16 PM   #3 (permalink)
AriZonaT

Disciple
 
AriZonaT's Avatar
 
Join Date: Apr 2007
Location: Vancouver, B.C.
Posts: 397
AriZonaT will become famous soon enough
Default

I have got to try this, sounds very interesting thanks for posting
AriZonaT 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 07:20 PM   #4 (permalink)
TheTempest
Arbiter
Senior Member
Retired Staff Member

Blessed
 
TheTempest's Avatar
 
Join Date: Apr 2004
Posts: 2,092
TheTempest is a glorious beacon of lightTheTempest is a glorious beacon of lightTheTempest is a glorious beacon of light
Default

I don't exactly understand your question.

What clients are you talking about? Perhaps this might help, any UDP traffic comming in from the internet on, going to destination port 64001 will be routed to 192.168.1.4:6112 (that means that 64001 is reserved for SC traffic)...This should never cause a problem, unless you tried running a UDP server on port 64001. In that case, simply change the port number in the router ie. 64001 -> (one of these 1024-65535)

edit:
added disclaimer...thanks!
__________________

My signature is back!! Hell YES!

Click the link, I DEMAND YOU! :-D
http://www.bwhacks.com/forums/showthread.php?t=24873
TheTempest 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 07:34 PM   #5 (permalink)
YonderKnight
Senior Member
Gold Member

Evangelist
 
YonderKnight's Avatar
 
Join Date: Sep 2004
Location: USA, California
Posts: 1,392
YonderKnight is a name known to allYonderKnight is a name known to allYonderKnight is a name known to allYonderKnight is a name known to all
Send a message via AIM to YonderKnight
Default

Sorry, I don't know much about networking stuff =p.

I meant like, the other players in the game. Aren't they designed to use port 6112 or whatever? How does that work?

Do you want us to talk about your thread in here or in the actual thread? =p
YonderKnight 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 07:38 PM   #6 (permalink)
TheTempest
Arbiter
Senior Member
Retired Staff Member

Blessed
 
TheTempest's Avatar
 
Join Date: Apr 2004
Posts: 2,092
TheTempest is a glorious beacon of lightTheTempest is a glorious beacon of lightTheTempest is a glorious beacon of light
Default

Quote:
Originally Posted by AriZonaT View Post
I have got to try this, sounds very interesting thanks for posting
Just curious, do you have any networking experience?
__________________

My signature is back!! Hell YES!

Click the link, I DEMAND YOU! :-D
http://www.bwhacks.com/forums/showthread.php?t=24873
TheTempest 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 08:29 PM   #7 (permalink)
rum
Administrator

Blessed
 
Join Date: Mar 2004
Location: Phoenix
Posts: 2,095
rum is a splendid one to beholdrum is a splendid one to beholdrum is a splendid one to beholdrum is a splendid one to beholdrum is a splendid one to beholdrum is a splendid one to behold
Send a message via AIM to rum
Default

I remember a while back I just changed the port number in the registry on one of the computers and it worked flawlessly.

Anyways, good information.
__________________
lol
rum 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 08:48 PM   #8 (permalink)
Zephyrix
Ereetu.
Senior Member
Game Hacking Staff

High Priest
 
Zephyrix's Avatar
 
Join Date: Oct 2005
Location: xor 1D27,1337
Posts: 1,565
Zephyrix is a name known to allZephyrix is a name known to allZephyrix is a name known to allZephyrix is a name known to all
Default

LLGW. +rep.
__________________


Zephyrix 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 09:36 PM   #9 (permalink)
TheTempest
Arbiter
Senior Member
Retired Staff Member

Blessed
 
TheTempest's Avatar
 
Join Date: Apr 2004
Posts: 2,092
TheTempest is a glorious beacon of lightTheTempest is a glorious beacon of lightTheTempest is a glorious beacon of light
Default

actually, in the thread would be fine. i'll move these posts over when i get back from school...but to answer your question.

when the packet is comming from the internet on that funny port 64001 or w/e it gets translated back to 6112, like starcraft expects once it hits the router before it gets to your computer.

I hope that helps
__________________

My signature is back!! Hell YES!

Click the link, I DEMAND YOU! :-D
http://www.bwhacks.com/forums/showthread.php?t=24873
TheTempest 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 09:52 PM   #10 (permalink)
YonderKnight
Senior Member
Gold Member

Evangelist
 
YonderKnight's Avatar
 
Join Date: Sep 2004
Location: USA, California
Posts: 1,392
YonderKnight is a name known to allYonderKnight is a name known to allYonderKnight is a name known to allYonderKnight is a name known to all
Send a message via AIM to YonderKnight
Default

Okay, I mean like this:

You have two computers on your LAN. Comps A and B. Each of them are using ports 6112. When you send out a packet on comp A, it hits the router and gets translated to port 64001, and when you send a packet with comp B, it stays on port 6112.

Now, a remote computer, comp C sees two active ports from the same IP, ports 64001 and ports 6112. If comp C wants to send a packet to comp A, it has to send the packet to your router on port 64001. Can it do this? (I'm guessing it can because your method works =p). I thought SC was only designed to use port 6112 though, how is it that comp C can send packets to port 64001?

Thanks =p.
YonderKnight 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 09:55 PM   #11 (permalink)
SC_Modder
Loading javascript...
Senior Member
Moderator

Inquisitor
 
SC_Modder's Avatar
 
Join Date: Nov 2004
Posts: 4,523
SC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond reputeSC_Modder has a reputation beyond repute
Send a message via AIM to SC_Modder
Default

I'll have to consider doing this. I have had OpenWRT on my WRTSL54GS for a while now and really like it.

TT: Any other cool tricks for your router? Sooner or later I'm going to install a fan and overclock my router, mostly for the hell of it, Lol.
__________________
AaronOpfer.com - My music
SC_Modder 15 0FF11|\|3   Reply With Quote

Old 07-16-2007, 10:37 PM   #12 (permalink)
gamepin126
Senior Member
Retired Staff Member

Celestial Entity
 
gamepin126's Avatar
 
Join Date: Oct 2004
Posts: 19,463
gamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond reputegamepin126 has a reputation beyond repute
Default

Quote:
Originally Posted by SC_Modder View Post
TT: Any other cool tricks for your router? Sooner or later I'm going to install a fan and overclock my router, mostly for the hell of it, Lol.
haha do et
__________________

Set a trashcan on fire and keep a bum warm for a night. Set the bum on fire, and keep him warm for the rest of his life.
gamepin126 15 0FF11|\|3   Reply With Quote

Old 07-17-2007, 12:27 AM   #13 (permalink)
TheTempest
Arbiter
Senior Member
Retired Staff Member

Blessed
 
TheTempest's Avatar
 
Join Date: Apr 2004
Posts: 2,092
TheTempest is a glorious beacon of lightTheTempest is a glorious beacon of lightTheTempest is a glorious beacon of light
Default

ok. To answer your question, it works.

SC is designed to use port 6112, and as far as SC knows, that's all that's being used. Because, when the packets are being created/recvd by your localmachine (ie. 192.168.1.xxx) the router has already translated the information.

Let me show you what's happening:

you send info from your LAN to someone on the internet. When the packet leaves, the following is the case:

Message leaving your computer going to the internet
Code:
Source IP: 192.168.1.100
Dest IP: some internet address
Source Port: 6112
Dest Port: 6112
Now, when that gets to the router the router goes, oh, I need to translate the source port (because when the target gets the message, it sends to the message back to the "sender" ie. source port).

So now it looks like this:
Code:
Source IP: WAN Address (same ip as "myipaddress.com")
Dest IP: some internet address
Source Port: 64001
Dest Port: 6112
Notice, the dest port is still 6112, so it gets to the target running SC correctly. Now, when they respond to your message, they will reply to the "source port" ie. the address of the sender (remember UDP has nothing to do with IP).

So when they reply it looks like this:
Code:
Source IP: some internet address
Dest IP: Your WAN Address
Source Port: 6112
Dest Port: 64001
The router gets the message (because your WAN is the address of your router on the internet) and sees that the dest port is 64001. So now it translates the dest address including the port (so instead of being your router, the router sets the destination ip address to 192.168.100:6112 and then forwards the packet to you).

So on your computer you get:
Code:
Source IP: some internet address
Dest IP: Your WAN Address
Source Port: 6112
Dest Port: 6112
__________________

My signature is back!! Hell YES!

Click the link, I DEMAND YOU! :-D
http://www.bwhacks.com/forums/showthread.php?t=24873
TheTempest 15 0FF11|\|3   Reply With Quote

Old 07-17-2007, 12:29 AM   #14 (permalink)
Mystic Videl
You're all idiots.
Retired Staff Member

Inquisitor
 
Mystic Videl's Avatar
 
Join Date: Aug 2006
Location: Oklahoma
Posts: 4,906
Mystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond reputeMystic Videl has a reputation beyond repute
Send a message via AIM to Mystic Videl Send a message via MSN to Mystic Videl
Default

Cisco 2800, I have no worries about any of this. But it looks like a very good guide!
__________________