Set your server's IP addresses
The server usually finds its own IP address. On a machine with more than one, you may need to set the address it listens on and the address it puts in access keys.
How the server finds its address
By default, the server listens on every address of the machine, on TCP port 443.
For the keys, it looks its address up through its own outgoing traffic: it asks a web service which address that traffic comes from.
That finds the right address on most machines. Set it yourself when:
- The machine sends its traffic from another address than the one users should connect to, such as a separate outgoing IP. The lookup would find the outgoing one.
- The machine has more than one public IP address, and the keys should carry a particular one.
- The lookup fails, for example because the machine cannot reach the web service. A standalone server then does not start, and its log says
PublicEndPoints has not been configured properly.
On a standalone server
The server reads its settings from /opt/VpnHoodServer/storage/appsettings.json. A new install has no such file: create it, and from then on the server uses it in place of the settings it was installed with. Two settings under FileAccessManager decide the addresses:
TcpEndPointslists the addresses and ports the server listens on.PublicEndPointslists the addresses and ports that go into access keys. Use real addresses only:0.0.0.0or[::]here stops the server from starting.
The whole file: the server listens on every address and puts 203.0.113.10 in the keys
{
"FileAccessManager": {
"TcpEndPoints": [ "0.0.0.0:443", "[::]:443" ],
"PublicEndPoints": [ "203.0.113.10:443" ],
"SslCertificatesPassword": null
},
"ServerConfig": {
"LogAnonymizer": true,
"AddListenerIpsToNetwork": "*"
},
"LogLevel": "Information"
}To listen on one address only, as with a separate outgoing IP, put that address in TcpEndPoints as well. Outside Docker, the server adds an address it listens on to the machine's network by itself, if the machine does not have it yet.
On a cloud where the machine has only private addresses, such as AWS, Google Cloud, Azure or Oracle Cloud, listen on the private address, or on every address, and put the public IP in PublicEndPoints.
Then restart the server with sudo systemctl restart VpnHoodServer, or with sudo docker restart VpnHoodServer in Docker. To check, create a key with vhserver gen: the line HostEndPoints: shows the addresses it carries.
UDP
UDP listens on the addresses of TCP by default. If you set UdpEndPoints or QuicEndPoints yourself, give them the same address as TCP.
Devices set to UDP need the server's UDP port open too, in the machine's firewall and your hosting provider's. The server picks the port at its first start, and its log names it.
Keys you have already given out
A key carries the addresses it was made with, so an app holding an older key keeps trying the old address. Each app picks up the current key by itself whenever it connects, so after a change, keep the server listening on the old address for a few days, then remove it.
Keep the old address in TcpEndPoints only, so the server still listens on it but no longer puts it in the keys.
An app that can no longer reach the old address needs a new key from you, unless its key carries a server token URL. Behind a reverse proxy, apps connect to the proxy, so your server's address can change without breaking their keys.
Server token URLs
The server token is the part of an access key that tells apps how to reach your server. With a server token URL, an app that cannot connect reads the current token from a file on the web and tries again.
VpnHood! MANAGER calls the same thing a farm token, because there it covers every server in a farm. That page shows what it holds and how apps get a new one. On a standalone server, only the setup differs.
Choose a URL on a site or a CDN your users can reach. List it in ServerTokenUrls in /opt/VpnHoodServer/storage/appsettings.json, then restart the server.
One URL, beside your other settings under FileAccessManager
{
"FileAccessManager": {
"ServerTokenUrls": [ "https://www.example.com/enc-server-token" ]
}
}After the restart, copy /opt/VpnHoodServer/storage/access/server-token/enc-server-token to that URL, and do so again after every change to the server's addresses or certificate, as nothing uploads it for you. The file is encrypted so that only your server's keys can read it.
To check, create a key with vhserver gen: the URLs it carries appear under TokenUpdateUrls:.
A key carries the URLs the server had when you made it, so add them before you give out keys. An app holding an older key gets them as it connects, through ReplyAccessKey, which is on by default and does what Push token to clients does in MANAGER.