Multiple LAN servers on same linux box
Moderator: OpenTTD Developers
Multiple LAN servers on same linux box
Hi there.
I would like to host two OpenTTD LAN servers on my linux box. I set the port on both servers to different ports (nightly has 3979, official has 3980). Both servers start just fine but I can only see the nightly server in the server browser.
Is it not possible to host two LAN servers on the same linux box or do I have to add another IP address to my network interface and bind both servers to different IP adresses?
Thanks for your help.
Kind regards.
Zombie
I would like to host two OpenTTD LAN servers on my linux box. I set the port on both servers to different ports (nightly has 3979, official has 3980). Both servers start just fine but I can only see the nightly server in the server browser.
Is it not possible to host two LAN servers on the same linux box or do I have to add another IP address to my network interface and bind both servers to different IP adresses?
Thanks for your help.
Kind regards.
Zombie
Just set server_port in [network] section of openttd.cfg (a different port for each server), and it should work like you want.
[edit]
I just tried, and I can start 2 servers (using different port) and it works.
But as you said, only one server is visible in network game list.
To see the other server, just "add server" and type "server_ip:other_port" and it will appear in the list.
[edit]
I just tried, and I can start 2 servers (using different port) and it works.
But as you said, only one server is visible in network game list.
To see the other server, just "add server" and type "server_ip:other_port" and it will appear in the list.
Last edited by glx on 17 Apr 2006 13:54, edited 1 time in total.
ever tried
there it showes
with 2 config files you can setup different servers on the same machine with using the same game files (only different config files).
To the openttd.cfg where you need to change the port, take a look @ http://wiki.openttd.org/index.php/Openttd.cfg
You also can use the -n parameter to start a network server, but i'll think the best is you try it yourself.
Code: Select all
me@mybox:~/openttd$ ./openttd --help
Code: Select all
-c config_file = Use 'config_file' instead of 'openttd.cfg'
To the openttd.cfg where you need to change the port, take a look @ http://wiki.openttd.org/index.php/Openttd.cfg
You also can use the -n parameter to start a network server, but i'll think the best is you try it yourself.
This works but I have to tell everone the IP and port of the server. That's not really an option.glx wrote:I just tried, and I can start 2 servers (using different port) and it works. But as you said, only one server is visible in network game list. To see the other server, just "add server" and type "server_ip:other_port" and it will appear in the list.
As I want to start to different versions of OpenTTD both versions have their own directory and their own config file. And that does not help a bit. The "-n" parameter is used to start OpenTTD as a client for a network game and not as a server.gigajum wrote:ever triedthere it showesCode: Select all
me@mybox:~/openttd$ ./openttd --help
with 2 config files you can setup different servers on the same machine with using the same game files (only different config files).Code: Select all
-c config_file = Use 'config_file' instead of 'openttd.cfg'
To the openttd.cfg where you need to change the port, take a look @ http://wiki.openttd.org/index.php/Openttd.cfg
You also can use the -n parameter to start a network server, but i'll think the best is you try it yourself.
Kind regards.
Zombie
There's no problem whatever in running more than one server on a Linux box. If you want them both to appear on the browse list for LAN games, by far the simplest way to do it is to give the Linux server another IP address for each game server you want to run.
You need to be root to do this. The following instructions will give your Linux machine an extra IP address until the machine is rebooted. If you want a permanent extra IP address, the means of (properly) making it permanent will vary from distribution to distribution.
OK, here we go.
You need to be root to do this. The following instructions will give your Linux machine an extra IP address until the machine is rebooted. If you want a permanent extra IP address, the means of (properly) making it permanent will vary from distribution to distribution.
OK, here we go.
- First, identify a spare IP address on your network. I'm going to assume for the purposes of this demonstration that your server has the address 192.168.0.2, and your workstations(s) are being given addresses like 192.168.0.3, 192.168.0.4 etc by your router. I'm also assuming that your netmask is 255.255.255.0 and your broadcast address is 192.168.0.255. You can use the ifconfig to determine your IP address settings:
Note that your network card is the one labelled eth0 (and there's also an eth1 if you have a second one).
Code: Select all
# ifconfig eth0 Link encap:Ethernet HWaddr 00:21:83:FE:4F:15 inet addr:192.168.0.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::230:84ff:feee:4f05/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:34806 errors:0 dropped:0 overruns:0 frame:0 TX packets:26603 errors:0 dropped:0 overruns:5 carrier:0 collisions:0 txqueuelen:1000 RX bytes:31640314 (30.1 Mb) TX bytes:7714251 (7.3 Mb) Interrupt:10 Base address:0xaf00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:78 errors:0 dropped:0 overruns:0 frame:0 TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5948 (5.8 Kb) TX bytes:5948 (5.8 Kb)
We grab an arbitrary IP address in the 192.168.0.* range that we don't think will already be in use. In this case, I'm going to nearly randomly choose 192.168.0.42 (you can choose addresses as high as .254). - Now we have chosen an IP address, we need to tell Linux to use it.
The following command will add it:There is no feedback at all, so we repeat the ifconfig comand to see the result:Code: Select all
# ifconfig eth0:0 192.168.0.42 netmask 255.255.255.0 broadcast 192.168.0.255
That's it. You don't need to reboot anything or restart anything, and you can now ping that IP address from anywhere on the network.Code: Select all
# ifconfig eth0 Link encap:Ethernet HWaddr 00:21:83:FE:4F:15 inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::230:84ff:feee:4f05/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:38719 errors:0 dropped:0 overruns:0 frame:0 TX packets:29989 errors:0 dropped:0 overruns:5 carrier:0 collisions:0 txqueuelen:1000 RX bytes:34694084 (33.0 Mb) TX bytes:8504493 (8.1 Mb) Interrupt:10 Base address:0xaf00 eth0:0 Link encap:Ethernet HWaddr 00:21:83:FE:4F:15 inet addr:192.168.0.42 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:10 Base address:0xaf00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:78 errors:0 dropped:0 overruns:0 frame:0 TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5948 (5.8 Kb) TX bytes:5948 (5.8 Kb)
To add even more IP addresses, just repeat the above, but keep adding to the number after the colon - eth0:1, eth0:2 etc. - You don't need to be root for any of the rest of this. In the network section of your different openttd.cfg files you need to tell each openttd server to use a different IP address...
Change the server_bind_ip value to one of your IP addresses. Give each server a different one, as in this example:
Code: Select all
[network] max_join_time = 500 pause_on_join = true server_bind_ip = 0.0.0.0 server_port = 3979 server_advertise = false
They can all use the same port, which is an added bonus.Code: Select all
[network] max_join_time = 500 pause_on_join = true server_bind_ip = 192.168.0.42 server_port = 3979 server_advertise = false
- Now, simply start each server with the openttd -D command or variant that you already use.
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
Hi there.
Thanks for your extensive help Brianetta. My linux box already has multiple IP adresses on the same network. But I set it up with multiple network cards (3) using advanced routing to have a dedicated NIC for games, samba/ftp and other services.
I will try to add another ip address to the gaming interface (can be challenging with advanced routing) or I will set up one of the OpenTTD servers to use my spare NIC.
Kind regards.
Zombie
Thanks for your extensive help Brianetta. My linux box already has multiple IP adresses on the same network. But I set it up with multiple network cards (3) using advanced routing to have a dedicated NIC for games, samba/ftp and other services.
I will try to add another ip address to the gaming interface (can be challenging with advanced routing) or I will set up one of the OpenTTD servers to use my spare NIC.
Kind regards.
Zombie
Linux should route as well as it ever does - just bear in mind that regardless of how carefully you set it up, if different physical network cards are on the same network you can't guarantee which one Linux will send outgoing packets through. This only matters if your network isn't "normal" (for example, if you have a managed switch with port based QoS).
Just adding extra IP addresses (aliases) to your existing eth devices should pose no problems.
Just adding extra IP addresses (aliases) to your existing eth devices should pose no problems.
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
Nice job, Brianetta. But now a special question. What to do, if you host two servers on the same LAN, but someone from the internet wants to join one of the games? Then you have to set up different Port because port-forwarding doesn't know if it should forward to IP (A) or IP (B), right?
moe moe pipebomb
Almost right. Port forwarding can only be done from ONE IP:Port -> IP:Port and not to 2 IPs. You need to set on the router two different ports. They can be forwarded both to the same port but on different computer. You also can forward both to the same port on the same machine. But you cannot set up one IP:Port on which you get access to two servers.CharlyHRO wrote:Nice job, Brianetta. But now a special question. What to do, if you host two servers on the same LAN, but someone from the internet wants to join one of the games? Then you have to set up different Port because port-forwarding doesn't know if it should forward to IP (A) or IP (B), right?
As I said. But keep in mind -> not every router is able to forward a packet, incoming on port 3989 to the servers port 3979. most routers only forward to the same port at wich the packet is coming in... got it?gigajum wrote:Almost right. Port forwarding can only be done from ONE IP:Port -> IP:Port and not to 2 IPs. You need to set on the router two different ports. They can be forwarded both to the same port but on different computer. You also can forward both to the same port on the same machine. But you cannot set up one IP:Port on which you get access to two servers.
moe moe pipebomb
now a question to the developers: if I start two servers on my LAN (hidden behind a router) and both listen on port 3979 AND I tell the router to forward port 3979 to server A port 3979 AND to forward port 3989 to server B port 3979 and both servers are set to advertise themselves, what happens? do both servers get listed with port 3979???
moe moe pipebomb
Try it and see. I'd guess that server B advertises itself as being at port 3979, which isn't the case, meaning that players connecting to server B might find themselves on server A. Of course, I'm quite prepared to be wrong.CharlyHRO wrote:now a question to the developers: if I start two servers on my LAN (hidden behind a router) and both listen on port 3979 AND I tell the router to forward port 3979 to server A port 3979 AND to forward port 3989 to server B port 3979 and both servers are set to advertise themselves, what happens? do both servers get listed with port 3979???
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
Server A: 3979CharlyHRO wrote:now a question to the developers: if I start two servers on my LAN (hidden behind a router) and both listen on port 3979 AND I tell the router to forward port 3979 to server A port 3979 AND to forward port 3989 to server B port 3979 and both servers are set to advertise themselves, what happens? do both servers get listed with port 3979???
Server B: 3979
Router 3979 A
Router 3989 B
Right? Server A will work correctly, server B will not show up on the master server list because it is on the wrong port. That is at least my idea. However you can connect to server B directly if you specify port 3989 in the connection string.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Who is online
Users browsing this forum: No registered users and 29 guests