processone / eturnal

STUN / TURN standalone server
https://eturnal.net
Apache License 2.0
237 stars 22 forks source link

Can relay_ipv4_addr and relay_ipv6_addr be set as an FQDN? #58

Closed NagaseYami closed 11 months ago

NagaseYami commented 11 months ago

I often switch between multiple VPS providers because some of them offer better deals. This leads to frequent changes in my IP address, and I don't want to modify configuration files or environment variables each time. Of course, I could also try writing a shell script to make a DNS request each time before starting Eturnal and then output the response to environment variable.

licaon-kter commented 11 months ago

this is covered in https://eturnal.net/doc/

weiss commented 11 months ago

I often switch between multiple VPS providers because some of them offer better deals. This leads to frequent changes in my IP address, and I don't want to modify configuration files or environment variables each time.

Can't you just omit the relay_ipv4_addr and relay_ipv6_addr options altogether? eturnal should figure out the correct relay address(es) by default, unless the server is behind NAT or has multiple public addresses (check the startup [info] messages in the eturnal log).

Of course, I could also try writing a shell script to make a DNS request each time before starting Eturnal and then output the response to environment variable.

You could create an /etc/eturnalctl.cfg file such as the following:

export ETURNAL_RELAY_IPV4_ADDR=$(curl -4fsS 'https://ifconfig.co/ip')
export ETURNAL_RELAY_IPV6_ADDR=$(curl -6fsS 'https://ifconfig.co/ip')

(The eturnalctl.cfg file isn't documented so far, but we have no plans to remove support for it.)

NagaseYami commented 11 months ago

unless the server is behind NAT or has multiple public addresses

Yes, I use multiple VPS servers for reverse proxy (port forwarding) in order to conceal the actual IP address of the real server. Therefore, I cannot run the automatic IP detection feature on the real server.

You could create an /etc/eturnalctl.cfg file such as the following:

Thank you very much, this is exactly what I wanted!

NagaseYami commented 11 months ago

In my case, it should be

export ETURNAL_RELAY_IPV4_ADDR=$(dig +short example.com A)
export ETURNAL_RELAY_IPV6_ADDR=$(dig +short example.com AAAA)