PDA

View Full Version : [TUTORIAL] How to setup L2 OFF server with dynamic ip


MoSs
16.07.2005, 18:35
Let me make some things clear first
what this is NOT:
- tutorial for setting up L2 off server
- tutorial for troubleshooting a non working L2 off server

I assume that you are already familiar with the processes of L2 server
and you know the database the l2 uses well...
I assume that your L2 server works well ( you can connect and play on your server )
I assume that the l2authd.exe program runs on the same machine as the MSSQL Database
I also assume that your internet connection is on the machine where the l2authd program runs.

First of all you need a dynamic domain, dont worry, there are hundreds free out there. I recommend http://www.dyndns.org.
For the purpose of this tutorial i will assume you registered l2serv.dyndns.org domain

After you made your account and created a Dynamic DNS domain you need a program that can update your ip to the domain every time it changes. Use this one: http://www.directupdate.net/download.html i will explain why. (this is not freeware, expires in 60 days, but i'm sure you will find ways :D )

Install it on the machine where the DSN files reside. ( you will need the lin2db.dsn that you already created. By default it is in: C:\Program Files\Common Files\ODBC\Data Sources\lin2db.dsn)

After installation, setup your account that you made at the DynDNS site in the DirectUpdate program.

After you make sure that the DirectUpdate updates your ip to the domain correctly every time it changes. You will need the following javascript script that i made for this purpose:

var args = WScript.Arguments;
var Wsh = new ActiveXObject("WScript.Shell");
//Terminates the l2authd program
Wsh.Exec("taskkill /F /IM l2authd.exe");
//Wait 3 seconds
WScript.Sleep(3000);

//Connect to MSSQL
var conn = new ActiveXObject("ADODB.Connection");
//Change this path to whatever path you have the lin2db.dsn file
conn.Open("File Name=C:\\Program Files\\Common Files\\ODBC\\Data Sources\\lin2db.dsn")
//Update the ip taken from the argument to the server with world id 1
conn.Execute("UPDATE server SET ip='"+args(0)+"' WHERE id=1");
conn.Close();
WScript.Sleep(3000);
//Run again the l2authd server
/* Change the command to your settings
for example cmd /D /C DRIVE & CD DRIVE:\\path\\to\\l2authd\\ & l2authd.exe
*/
Wsh.Run("cmd /D /C D: & CD D:\\ProjectC2-Beta3-Final\\NewAuth & l2authd.exe");

//This should work just fine, otherwise you did something wrong, double check paths...


Save the above code to a file: updateip.js

Now you need to open the administration module of direct update and select Actions and do the following:
"When a new Ip is detected..."
check: Launch the external application
click modify
Full path: %windir%\system32\wscript.exe
Parameters: \your\path\to\updateip.js *IP*
Sample image follows:

http://users.otenet.gr/~moss/l2/duexample.jpg

You can click test to see if it works correctly.
If it doesn't then you did something wrong!

Let me assure you that terminating and restarting the l2authd server does not crash neither the L2server nor the L2npc and the l2server will always try to reconnect to the l2authd.

Now all you need to do is to put the address you registered
on the dyndns site to your l2.ini
ServerAddr=l2serv.dyndns.org

After that you should be able to connect to your server anytime after the ip changes and no further actions should be required ;)


Feel free to modify the javascript code and improve it if you like :)
It's kind of quick and dirty solution but works :)

Give me feedback of success/failure stories :)

Hope that tutorial helps :D cheers

(excuse my english, I'm greek :P)

MoSs
16.07.2005, 19:04
I have to add a few comments...
First of all I have seen people requesting this on ragezone but from ragezone I am really dissapointed people are NOT willing to share there... So there is no way to post this at ragezone...
Definately I hate replies of the type: "Use search you noob" and the like
when you do search and there is nothing to find. (I am almost convinced that they are deleting usefull posts there, for reasons I cant imagine)

I am glad people contribute stuff here so I would like to add my little thing as well :)

Keep sharing/contributing, I sure will as much as I can!

YOU CANNOT COPY MY POST AND PASTE IT ON RAGEZONE
I WILL BE PISSED IF I SEE SOMEONE DO THAT....

You can simply add a link to this post if you wanna help someone there...

Thank you (i got it out of my system ) :P

Metalmurphy
16.07.2005, 20:26
Well i can tell you that someone will do that. And for u to say DONT DO IT its only one more reason for them to actually DO it.

Anyway thanks for that java script. The update in the db is the only thing i actually needed but thks anyway ;)

mrw00ter
16.07.2005, 22:12
lol wow thats alota stuff, i just had to go into my router admin area and set it so it doesnt change ips auto. ><

MoSs
16.07.2005, 22:26
lol wow thats alota stuff, i just had to go into my router admin area and set it so it doesnt change ips auto. ><

Well this tutorial is mainly for those that have dialup connections or DSL connections with not a static ip.
Its not intended for those that use DHCP (duhh omg!)

MoSs
16.07.2005, 22:29
Well i can tell you that someone will do that. And for u to say DONT DO IT its only one more reason for them to actually DO it.

Anyway thanks for that java script. The update in the db is the only thing i actually needed but thks anyway ;)
Well whatever :(
If people believe that getting credit by using someone elses tutorial actually makes them something, are morons... and of course worthless pieces of shit :P

(sorry i cannot control my self :roll: )

wton
04.08.2005, 10:19
thanks for guia for noobs moss, but, uny question..

http://img215.imageshack.us/my.php?image=errorjava8ua.jpg

please, helpme..
thanks :D

MoSs
05.08.2005, 11:51
maybe you edited something that you should not...

flakka
22.08.2005, 00:49
Very cool. :) Thought I'd give it a whirl, and got this error.

http://img398.imageshack.us/img398/6092/error5hm.jpg

Here's my script edited with my paths.

var args = WScript.Arguments;
var Wsh = new ActiveXObject("WScript.Shell");
//Terminates the l2authd program
Wsh.Exec("taskkill /F /IM C2AuthD_0500623.exe");
//Wait 3 seconds
WScript.Sleep(3000);

//Connect to MSSQL
var conn = new ActiveXObject("ADODB.Connection");
//Change this path to whatever path you have the lin2db.dsn file
conn.Open("File Name=C:\\Program Files\\Common Files\\ODBC\\Data Sources\\lin2db.dsn");
//Update the ip taken from the argument to the server with world id 1
conn.Execute("UPDATE server SET ip='"+args(0)+"' WHERE id=1");
conn.Close();
WScript.Sleep(3000);
//Run again the l2authd server
/* Change the command to your settings
for example cmd /D /C DRIVE & CD DRIVE:\\path\\to\\l2authd\\ & l2authd.exe
*/
Wsh.Run("C:\\server\\NewAuth\\C2AuthD_0500623.exe");

//This should work just fine, otherwise you did something wrong, double check paths...

It's mind boggling because paths are fine. Checked line 11 for the error and looks fine to me. Even changed it to FileDSN=C: and I still got the same error. It's driving me mad. :tard:

And yes, server is up and fully functional with no errors.

MoSs
23.08.2005, 00:58
hmm!

My guess is that the .dsn file has some kind of a problem...
Open your lin2db.dsn file with a text editor...
it should look like this:
[ODBC]
DRIVER=SQL Server
UID=MoSs
Trusted_Connection=Yes
DATABASE=lin2db
WSID=LOCALHOST
APP=Microsoft Data Access Components
SERVER=LOCALHOST
Description=lin2db

edit:
I also noticed that you changed the last Run() function
I have a reason for running the authd with a cmd...
That is because windows scripting Run() function does not support a working path argument... If you run directly the .exe the working path is not where the executable is placed, this will produce an error in your authd program...
Running with cmd first changes drive, then changes directory and then runs the authd... Otherwise it will not work.

Wsh.Run("cmd /D /C D: & CD D:\\ProjectC2-Beta3-Final\\NewAuth & l2authd.exe");

aseren
23.08.2005, 01:12
OR!
you could just make a account on www.noip.com
and be done in 5 minutes.

MoSs
23.08.2005, 01:18
OR!
you could just make a account on www.noip.com
and be done in 5 minutes.
Heheh as I said there are hundreds of sites out there providing free domains for dynamic ip update purpose, choose your favorite :P

flakka
23.08.2005, 01:38
OK, my lin2db.dsn looks like that save for the UID and server names.


I also noticed that you changed the last Run() function
I have a reason for running the authd with a cmd...


I found out that my AuthD.exe didn't work after I posted that code. So you were right on that one. Fixed it back and changed the path name and it works fine.

The problem I'm getting is exactly what it says in the screenshot. "It's not a valid compund file." I even tried to compile the different parts of the javascript to see where the error was. So I tried this:


//Connect to MSSQL
var conn = new ActiveXObject("ADODB.Connection");
//Change this path to whatever path you have the lin2db.dsn file
conn.Open("File Name=C:\\Program Files\\Common Files\\ODBC\\Data Sources\\lin2db.dsn")
//Update the ip taken from the argument to the server with world id 1
conn.Execute("UPDATE server SET ip='"+args(0)+"' WHERE id=1");
conn.Close();
WScript.Sleep(3000);

Exact same problem. Only instead of line 11, it's on line 4. So it has something to do with the dsn I assume. I just don't understand it. I've set up the servers many times without a problem whatsoever. It just doesn't like my lin2db.dsn file or something.

:banghead:

MoSs
23.08.2005, 02:05
I understand your frustration about this, honestly I could not expect a problem like this... I 'll figure out another way to connect to MSSQL and I will post it!

flakka
23.08.2005, 02:21
Cool. Will be waiting for your update! :)

athlon64
22.09.2005, 05:30
Isn't possible to make a script that connects directly to MSSQL not through ODBC ?