How to run server behind firewall?

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
Figster
Engineer
Engineer
Posts: 17
Joined: 21 Feb 2005 10:03
Location: Stockholm, Sweden
Contact:

How to run server behind firewall?

Post by Figster »

I'm trying to run a dedicated OpenTTD server behind a firewall with NAT. My inside address is 192.168.0.3, and this is the only address which OpenTTD can detect. I *think* it announces this address to the public server list too. Since no one can connect to my local IP, no one can connect to my game.

I've tried to set the IP address to my external address in the cfg-file, but then the server won't start.

I can configure the firewall myself, so opening ports isn't a problem, but I can't turn off NAT.
---
Real mail address: fredrik bob ramsberg.net (but @ instead of bob)
User avatar
kwiatysta
Engineer
Engineer
Posts: 4
Joined: 27 Jun 2005 11:47
Location: Warsaw, Poland

How about port forwarding?

Post by kwiatysta »

Have you tried port forwarding?
You can open a port on your firewall and then forward it to OTTD server :wink:
4AM? Push forward!!
Figster
Engineer
Engineer
Posts: 17
Joined: 21 Feb 2005 10:03
Location: Stockholm, Sweden
Contact:

Post by Figster »

Did that. The port forwarding works fine.

The problem is that when I launch OpenTTD dedicated server, it detects the server machine's IP address, and since the machine is on a LAN with a firewall and NAT (Network Address Translation), it finds only the machine's local address, which is 192.168.0.3. OpenTTD then advertises the game and tells everybody to connect to 192.168.0.3. Since this isn't my public IP address, no one can connect. So my question is: How can I tell OpenTTD to advertise a different IP address than the one it detects?
---
Real mail address: fredrik bob ramsberg.net (but @ instead of bob)
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

if you forwarded it correctly it should work. basicly what it does is anything coming in on that port, adressed either to your PC, or to your router, will go directly to your computer. works for me. you'll likely need to farward both the TCP and UDP ports. if you only forward TCP it doesn't work.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
Figster
Engineer
Engineer
Posts: 17
Joined: 21 Feb 2005 10:03
Location: Stockholm, Sweden
Contact:

Post by Figster »

You're right!

The UDP port forwarding was exactly what was missing!

After reading the following in the docs, I was certain I didn't need UDP forwarding:

"OpenTTD has a function which can detect LAN-servers. This is done via UDP. At the moment you select LAN-mode on the server, the server also starts an UDP-listener. When a client on the same LAN presses Find Server in LAN-mode, it sends an UDP-broadcast. This is one of the best things UDP has: broadcast. The server receives it, and sends his game_info back to the client. This way the client can discover a server on the local LAN. This is the only place where UDP is used."

( http://wiki.openttd.org/index.php/Network_Protocol )

Anyway, it's solved now. Thanks a bunch!
---
Real mail address: fredrik bob ramsberg.net (but @ instead of bob)
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

You shouldn't need to forward the UDP ports, I dunno really why that has solved anything but heh. The proper way of fixing this would be to set "connect_to_ip" in the config, but for me it has just worked automatically without changing anythng. Ah well, if it works for you don't change it. :P
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
Figster
Engineer
Engineer
Posts: 17
Joined: 21 Feb 2005 10:03
Location: Stockholm, Sweden
Contact:

Post by Figster »

I can't quite understand why I have to open up for UDP traffic either, but there is indeed a note about it in the docs:

"What port does OpenTTD use?

the default port is 3979, but you can change it to anything you like when you start a server. If you set up your own server behind a router, you need to forward both TCP and UDP on that port.

communication with the master-server goes via port 3979 over UDP (outbound only) "

( http://wiki.openttd.org/index.php/FAQ_multiplayer )

I had already set connect_to_ip to my public address, and that didn't seem to change anything.
---
Real mail address: fredrik bob ramsberg.net (but @ instead of bob)
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests