Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

How to Run Zone Server Behind Router

Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
This is not the prettiest fix but it does the trick of running zoneserver behind router.
I assume you have gone through the trouble of setting up the server and making login and world servers WAN accessible.

The Conflict
Zone server IP ext_address from FFDB1 > serverstatus table is used by clients connecting to the zone server and by the zone server itself when it is starting. So we have two cases:

Case 1: ext_address is set to LAN IP
Zone server will start and will listen on ext_address LAN IP successfully.
When client selects the character to enter the game it will attempt to connect to ext_address LAN IP and in result it will fail.

Case 2: ext_address is set to WAN IP
Zone server will start but fail to listen on WAN IP because there won't be network interface with that IP available.
However, when client selects the character to enter the game it will attempt to connect to ext_address WAN IP.

Edit zoneserver
Open zoneserver with hex editor and do following:

Code:
Find: 0F 84 94 01 00 00 BF 18  00 00 00 4C 8D A4 24 E0
Replace with: 0F 85 94 01 00 00 BF 18  00 00 00 4C 8D A4 24 E0

Start the server

  1. Change FFDB1 > serverstatus > ext_address for zone server to WAN IP
  2. Start world server
  3. Change FFDB1 > serverstatus > ext_address for zone server to LAN IP
  4. Start zone server


The Workaround
My workaround simply tricks world server into sending WAN IP for the zone server, and because it loads that WAN IP address at startup we can change it in database for zone server to start with proper LAN IP.
Without the patch zone server will complain about ticket mismatch, and that is what patch does. It makes server ignore mismatched tickets.

Warning
The patch simply replaces jz (jump if zero) with jnz (just not zero). As a result this will make server think that tickets mismatch if zone server WAN IP that clients connects to and zone server LAN IP that server listens on do infact match.

Before
Code:
if ( v5 != ResolveTicket.ServerIP || lapis::CGlobalInfo::ZoneServerPort != ResolveTicket.ServerPort )

After
Code:
if ( v5 == ResolveTicket.ServerIP || lapis::CGlobalInfo::ZoneServerPort != ResolveTicket.ServerPort )

Disclaimer
Use at your own cost and risk. I do not guarantee this to work nor be safe or secure.
 
Last edited:
Skilled Illusionist
Joined
Dec 21, 2013
Messages
392
Reaction score
181
Seems like you do need to have the wan ip setup to the router ip and not the local vm ip. Just tried it out and the game can't connect to my local server without reverting back the changes.

Also your patch has been included in my program for easy patching. Good job.
 
Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
Seems like you do need to have the wan ip setup to the router ip and not the local vm ip. Just tried it out and the game can't connect to my local server without reverting back the changes.

Is your local VM on a different subnet than router?
 
Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
If that means no internet connection then yes. I run the vm locally.

So I think there is double routing/natting or something along those lines. I guess you have 192.168.0.0/24 as your primary lan at home and your VM is on different subnet setup by VMware, like 192.168.200.0/24 If so, why bother with it and not just bridge interfaces? Have VM on the same subnet as your home lan.
 
Skilled Illusionist
Joined
Dec 21, 2013
Messages
392
Reaction score
181
So I think there is double routing/natting or something along those lines. I guess you have 192.168.0.0/24 as your primary lan at home and your VM is on different subnet setup by VMware, like 192.168.200.0/24 If so, why bother with it and not just bridge interfaces? Have VM on the same subnet as your home lan.

Ah, I see! The subnet is actually on 192.168.128.x. I'll give it a go later. Thanks man!
 
Junior Spellweaver
Joined
Mar 22, 2016
Messages
192
Reaction score
32
Some terminology is getting misused and it's causing issues in trying to follow this conversation along.

The subnet is not the IP address of the machine, that's just the IP. The subnet is the portion of the IP that determines where the network begins and ends. When you see X.X.X.X/24, that's called CIDR notation (Classless Inter-Domain Routing). CIDR notation is used when creating a custom subnet for a network that does not fit within the confines of the class networks.

Class A IP - 1 ~ 126 Subnet - 255.0.0.0 /8
Class B IP - 128 ~ 191 Subnet - 255.255.0.0 /16
Class C IP - 192 ~ 223 Subnet - 255.255.255.0 /24
Class D IP - 224 ~ 229 Subnet - 255.255.255.255 /32

These are the classic Classed networks and their CIDR notations. The left side of the network is the "Network mask" segment and the right side is the "Host mask" segment. In the Class C subnet 255.255.255.0, you can see that the first three octets are for the network (255.255.255) and the last octet is for the hosts (.0) A class C IP range will allow 253 hosts. If you stack the IP range on top of the subnet, any IP octet that is above a 255 does not change, and is outside of your network. Any IP octet that is above a 0 in the subnet is dynamic, and is part of your network. You will always need to subtract two from the hosts. One for the gateway, and one for the broadcast. In typical network setups, the gateway is the first address in the network (192.168.0.1) and the broadcast is the last (192.168.0.255).

When you need more hosts than a network allows, that is when CIDR comes into play, as using subnetting math allows you to create a custom classless subnet that would allow you to stay within a Class C IP range, however have more than 253 hosts.

If you're not using a custom network, using the CIDR notation is unnecessary, as the IP address you provide tells you that it's a class C address range and that the subnet is going to be 255.255.255.0
 
Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
Here is a second note about using this workaround. For those that run multiple world&zone servers, be careful when you restart because once second world server is stopped and started again it will force first world server to reload zone server IPs from world table. So when restarting second world&zone server change ext_address for all zone servers to WAN IP and only then start second zone server. Wait it out a bit, and change that IP back to LAN IP and start second zone server.
 
Experienced Elementalist
Joined
Jul 5, 2012
Messages
272
Reaction score
32
Must Try this + Eperty123's cool app... :)
Also i was thinking of working on a Startup script to Read the Public IP... modify the Files. then Do the Majic with the DB etc....
I have seen some scripts here to minipulate some of the other files.
So must give this a Go (Learning Experiance + Learn some Tricks with Running Postgres Querry's from command Line.

If i get anything working i'll share it with the Comunity.

Great work guys.
 
Experienced Elementalist
Joined
Jul 5, 2012
Messages
272
Reaction score
32
I am getting a Error with my Zone Server...

What i Have
Accounts : Sites : LAN IP
---
FFDB1: serverstatus : WAN IP untill Worldserver is done.
Then LAN IP : Load Zoneserver

I still can't login from WAN Side (VPN)
Zoneserver Shows this in the Log
Code:
286,2016/10/13 14:25:49,[ZoneServerDB.cc:115],Connected to database [192.168.1.6].
   393,2016/10/13 14:25:49,Service OK
   395,2016/10/13 14:25:49,Service OK
   398,2016/10/13 14:25:49,Service OK
   400,2016/10/13 14:25:50,RSA size(n) = 256 size(e) = 2
   401,2016/10/13 14:25:50,RSA size(n) = 256 size(e) = 2
   402,2016/10/13 14:25:50,Cannot assign requested address 122.59.28.166:10021
   403,2016/10/13 14:25:50,SOCKET 33: closed.
   404,2016/10/13 14:25:50,[SJFramework.cc:111],ERROR: #Network# CSJFramework::InitNetwork -- Network Initial Error
 
Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
I am getting a Error with my Zone Server...

What i Have
Accounts : Sites : LAN IP
---
FFDB1: serverstatus : WAN IP untill Worldserver is done.
Then LAN IP : Load Zoneserver

I still can't login from WAN Side (VPN)
Zoneserver Shows this in the Log
Code:
286,2016/10/13 14:25:49,[ZoneServerDB.cc:115],Connected to database [192.168.1.6].
   393,2016/10/13 14:25:49,Service OK
   395,2016/10/13 14:25:49,Service OK
   398,2016/10/13 14:25:49,Service OK
   400,2016/10/13 14:25:50,RSA size(n) = 256 size(e) = 2
   401,2016/10/13 14:25:50,RSA size(n) = 256 size(e) = 2
   402,2016/10/13 14:25:50,Cannot assign requested address 122.59.28.166:10021
   403,2016/10/13 14:25:50,SOCKET 33: closed.
   404,2016/10/13 14:25:50,[SJFramework.cc:111],ERROR: #Network# CSJFramework::InitNetwork -- Network Initial Error

Zone server log is showing that you did not change ext_address for zone server to LANIP after starting world server.
If you are using navicat or alike software to change IP, make sure yo apply the change because I had that happen to me.
 
Experienced Elementalist
Joined
Jul 5, 2012
Messages
272
Reaction score
32
Zone server log is showing that you did not change ext_address for zone server to LANIP after starting world server.
If you are using navicat or alike software to change IP, make sure yo apply the change because I had that happen to me.

it was my Sleep 60 statment in the wrong place...
still can't login from Wan but i get the Login screen ok... so have a feeling its port related or my cfg files... i'll go click the Clean files. and see whats different.

Thanks again for you're help... :)
 
Skilled Illusionist
Joined
Dec 21, 2013
Messages
392
Reaction score
181
Zone server log is showing that you did not change ext_address for zone server to LANIP after starting world server.
If you are using navicat or alike software to change IP, make sure yo apply the change because I had that happen to me.

Another option might be creating a new row in the SQL spefically for the LAN then make sure ZS's original IP lookup is set to it.

Don't know if WS actually does anything with the ext_address though, but worth a try.

The thing is that once using your patch, Bimmer, I assume you must have the WAN to LAN setup for this to work? Since the error 6 occurs if applying the patch.
 
Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
Another option might be creating a new row in the SQL spefically for the LAN then make sure ZS's original IP lookup is set to it.

Don't know if WS actually does anything with the ext_address though, but worth a try.

The thing is that once using your patch, Bimmer, I assume you must have the WAN to LAN setup for this to work? Since the error 6 occurs if applying the patch.

WS doesn't seem to do anything with its own ext_address, it is using ZS ext_address to send to clients so they can connect after character selection.

Ohh by the way, for this to work server files must be patched for correct LAN IP and WAN patch must be applied, and only then zone server is patched with this patch.
 
Skilled Illusionist
Joined
Dec 21, 2013
Messages
392
Reaction score
181
WS doesn't seem to do anything with its own ext_address, it is using ZS ext_address to send to clients so they can connect after character selection.

Ohh by the way, for this to work server files must be patched for correct LAN IP and WAN patch must be applied, and only then zone server is patched with this patch.

I see. In theory you can actually use another row specifically for the patch since in your tut, you have to edit the ext_address for ZS to your LAN IP efter WS has started, right? So that ZS loads IP from that row instead.

You mention patching the files to the correct LAN IP, that means all files in general, right? My program already does this since in the beginning, but just gotta have this confirmed.
 
Newbie Spellweaver
Joined
Jul 17, 2016
Messages
24
Reaction score
9
I see. In theory you can actually use another row specifically for the patch since in your tut, you have to edit the ext_address for ZS to your LAN IP efter WS has started, right? So that ZS loads IP from that row instead.

You mention patching the files to the correct LAN IP, that means all files in general, right? My program already does this since in the beginning, but just gotta have this confirmed.

Yes, that is what I meant by patching the files to the correct LAN IP.

How would you make it load from different row? I tried added additional column wan_address and making world server load zone server's wan ip from there, but did work out.
 
Skilled Illusionist
Joined
Dec 21, 2013
Messages
392
Reaction score
181
Yes, that is what I meant by patching the files to the correct LAN IP.

How would you make it load from different row? I tried added additional column wan_address and making world server load zone server's wan ip from there, but did work out.

Just search for ext_address and replace it using a hex editor.
 
Back
Top