Trying to get a Torchlight 2 multiplayer session going recently I decided to forgo the internet mode, as previously it has always been notoriously unstable for my group. So, using a cheap closely located VPS armed with a simple OpenVPN road warrior setup, I attempted to use the LAN option with the players connecting to the VPN.
However, Torchlight 2 doesn’t allow direct IP connections, instead utilizing UDP broadcast to locate and negotiate with the game hosts on the network without any additional setup (the same is true for some other games like Titan Quest Anniversary Edition, Borderlands 2 or Grim Dawn). The road warrior script setup from the earlier link won’t support that by default, as broadcasts won’t work over network layer 3 (the tun
device), and client-to-client connections will also be disabled.
To deal with that, after going through with the basic installation (run the openvpn-install.sh
script and answer a few questions) change dev tun
to dev tap
and add the client-to-client
option in /etc/openvpn/server/server.conf
on the VPS:
local <your-vps-public-ip>
port 1194
proto udp
dev tap
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
client-to-client
script-security 3
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1 bypass-dhcp"
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
verb 3
crl-verify crl.pem
explicit-exit-notify
Also change tun
to tap
in /etc/openvpn/server/client-common.txt
, and add the route-nopull
option so the VPN connection would only be used for the virtual LAN bound traffic:
client
dev tap
proto udp
remote 45.135.164.46 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
route-nopull
ignore-unknown-option block-outside-dns
verb 3
Then, restart the OpenVPN service and create the client config files to distribute among the players as needed:
$ /etc/init.d/openvpn restart
$ bash openvpn-install.sh
...
This alone won’t be enough for the Windows 10 using players to discover each other though, as Windows will only send the UDP broadcast packets to the network adapter having the lowest interface metric. To fix this, go to Network Connections
(Win+S
-> type network
), choose Properties
from the context menu of the default connection and delve into Internet Protocol Version 4 (TCP/IPv4)
-> Properties
-> Advanced
. Uncheck the Automatic metric
option and enter something like 10
in the Interface metric
field:
The lower the metric, the higher the interface priority, so repeat the same process for the OpenVPN connection and enter 5
. This combined with the tap
based OpenVPN setup will ensure the UDP broadcast packets reach the other players.
After doing this and logging into the VPN with your config, you should be able to see and join Torchlight 2 sessions hosted by other clients in the LAN mode (just don’t forget to let the connections through the firewall on the client machines); same goes for Titan Quest, Grim Dawn and probably any game using a similar method of communicating with LAN hosts.
Notes: in our case, sometimes Torchlight 2 wouldn’t allow a player to join after another specific player had joined, which we didn’t want to investigate and bypassed by connecting in a different order (the connection though kept admirably fast and stable, as opposed to the usual Internet multiplayer experience). The Titan Quest games in certain cases could not be discovered (while the clients would send the broadcast packets, the server won’t answer), which could usually be resolved by restarting the game for everyone. I’m not exactly sure at the moment if these problems belong to the actual games or some particular facet of the setup.