From my host with hostname
localhost, I would like to reach an external host with hostname
exthost through the internet. The public IP address of
exthost is dynamically assigned by the Internet Provider.
I would like to refer to
exthost using always its name, and mapping this name to its actual IP address, according to the value assigned by the Provider, which may change.
To do so, I would like to use
/etc/hosts, properly updating the IP address value of the line related to
For example, the line in
/etc/hosts in Linux may look like:
<ip_address> exthost.domain exthost
I am using Ubuntu 18.04, but this surely applies also to other distros/Unix-like systems.
Is it possible to do this, avoiding to set up a DNS (and also a dynamic DNS, which sometimes is not a free service) just for this purpose?
For example, is it possible to use, instead of an explicit
<ip_address>, a reference to another file containing only the desired IP as a string? So that this file can be accessed and modified by a user, according to the IP value, which may vary.
Note: this question seems not to be the same case, because it is about the local machine. I am instead referring to an external host.