[0.14.x] [cube] Command-line options for IP and port bindings

This subforum contains all the issues which we already resolved.
Post Reply
Revenge282
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Jul 05, 2016 6:14 am
Contact:

[0.14.x] [cube] Command-line options for IP and port bindings

Post by Revenge282 »

As a server host, these are invaluable options to have. Currently, Factorio will bind to all available addresses on a port specified in config.ini. Command-line options would make this more secure for the hosters (unable to be modified), as well as allow servers to be bound to unique addresses so that other servers may utilize the default ports.

Also, related to the issue of IP binding. Clients who do not have DMZ enabled on their router for their computer are unable to connect to a Factorio server that binds to multiple addresses. I expected this issue to be resolved with the roll out of the new networking system, but it seems it still is around from the 0.13 branch. Currently, if a client tries to direct connect to the server using an address that is not the primary address, the connection will fail, unless DMZ is enabled.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.14.x] Command-line options for IP and port bindings

Post by kovarex »

What do you mean by all available addresses? It just opens the port on the local computer. I just don't get network stuff.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: [0.14.x] Command-line options for IP and port bindings

Post by DaveMcW »

tldr; Factorio does not support multiple IP addresses.

Factorio must run on the primary IP address of the server. Factorio listens on ALL IP addresses, which can cause bad things to happen on those other IP addresses.

Possible fix: Do not listen on non-primary IP addresses.
Better fix: Allow choosing IP address in config.ini.

Revenge282
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Jul 05, 2016 6:14 am
Contact:

Re: [0.14.x] Command-line options for IP and port bindings

Post by Revenge282 »

DaveMcW wrote:tldr; Factorio does not support multiple IP addresses.

Factorio must run on the primary IP address of the server. Factorio listens on ALL IP addresses, which can cause bad things to happen on those other IP addresses.

Possible fix: Do not listen on non-primary IP addresses.
Better fix: Allow choosing IP address in config.ini.
Best fix: Allow IP address and port to be set via command-line. Config files are a security risk when it comes to server hosting.
kovarex wrote:What do you mean by all available addresses? It just opens the port on the local computer. I just don't get network stuff.
For example, my server I run Factorio on has 6 IP addresses associated with it. When I run Factorio, Factorio will listen on *all* those IP addresses. Ideally, Factorio should only listen on one specific IP address.

Below is what netstat shows on Linux with two Factorio servers running, and a TeamSpeak server:

Code: Select all

udp        0      0 0.0.0.0:34197                           8592/factorio
udp        0      0 0.0.0.0:34198                           11671/factorio
udp        0      0 192.99.180.20:9987                           18642/ts3server_lin
See how Factorio is set to 0.0.0.0? That means it is listening on all available IP addresses. Meanwhile, TeamSpeak is bound to only 192.99.180.20.

bk5115545
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Apr 03, 2016 7:00 pm
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by bk5115545 »

This becomes revalent when one is trying to host factorio in a more controlled environment.
While it's not required for the game to work, most other online games either allow only binding to a single IP (commonly set through config or ini file) or do so by default.

I really enjoy that factorio binds to multiple IPs so that my local friends can use my local IP (avoids router and my PFSense box) and my remote friends can use my VPN IP.
If you decide that binding to multiple addresses is a bug then please have some way of asking the game to bind to multiple IPs.

Revenge282
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Jul 05, 2016 6:14 am
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by Revenge282 »

bk5115545 wrote:This becomes revalent when one is trying to host factorio in a more controlled environment.
While it's not required for the game to work, most other online games either allow only binding to a single IP (commonly set through config or ini file) or do so by default.

I really enjoy that factorio binds to multiple IPs so that my local friends can use my local IP (avoids router and my PFSense box) and my remote friends can use my VPN IP.
If you decide that binding to multiple addresses is a bug then please have some way of asking the game to bind to multiple IPs.
It's a general rule of thumb that when 0.0.0.0 is specified, that it would bind on all addresses. However, with an application such as a game server, it is not standard practice to bind on all addresses. I cannot actually think of an instance where that is a standard procedure, outside of a badly configured Apache instance.

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by cube »

So I've made a simple version of this -- when hosting a dedicated server you can use the option --bind to bind to the address. If this option is not given, then 0.0.0.0 and ::0 are used both. Also I've limited the scope of other sockets used in game.

Revenge282
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Jul 05, 2016 6:14 am
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by Revenge282 »

cube wrote:So I've made a simple version of this -- when hosting a dedicated server you can use the option --bind to bind to the address. If this option is not given, then 0.0.0.0 and ::0 are used both. Also I've limited the scope of other sockets used in game.
Awesome news, thank you!

Could you also look into adding a parameter for specifying the port? Trying to guarantee the config file is not modified is a difficult, and not as convenient.

Perhaps if no port parameter is specified, default to 34197, removing the config line all together?

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by daniel34 »

Revenge282 wrote:Could you also look into adding a parameter for specifying the port? Trying to guarantee the config file is not modified is a difficult, and not as convenient.
Factorio already has a parameter for specifying the port:

Code: Select all

Server options:
  --port N                           network port to use
Running factorio --help will give you a list of all parameters.
quick links: log file | graphical issues | wiki

Revenge282
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Jul 05, 2016 6:14 am
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by Revenge282 »

daniel34 wrote:
Revenge282 wrote:Could you also look into adding a parameter for specifying the port? Trying to guarantee the config file is not modified is a difficult, and not as convenient.
Factorio already has a parameter for specifying the port:

Code: Select all

Server options:
  --port N                           network port to use
Completely unaware of that. Thank you.

bk5115545
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Apr 03, 2016 7:00 pm
Contact:

Re: [0.14.x] [cube] Command-line options for IP and port bindings

Post by bk5115545 »

Revenge282 wrote: However, with an application such as a game server, it is not standard practice to bind on all addresses. I cannot actually think of an instance where that is a standard procedure, outside of a badly configured Apache instance.
Here's a few that I've had the pleasure of hosting.
All Paradox games that support local co-op (EU4, Magicka I/II, and Stellaris just to name a few big ones).
Battlefield 2 local co-op binds to public addresses as well
Warframe II Battle.Net Edition and Warcraft III RoC/tFT.

Aside from Warcraft II/III, all of these games have the option to only host on specific addresses.

Thanks cube for the quick change. Now I can easily have multiple persistent servers for different game versions or mod configurations.

Post Reply

Return to “Resolved Problems and Bugs”