Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 42424  / 2 Years ago, thu, december 2, 2021, 3:36:45

I want to give two ip addresses for same host name.

Like in /etc/hosts file:



xx.x.x.x example     # if system is connected to dhcp  
y.y.yy.y example # if system is connected to VPN


So is it possible?


More From » networking

 Answers
4

It's not really possible as in this specific example. Your hosts file essentially forms part of your system's ability to map a hostname into an IP address. So when your system wants to know the IP address of "example", it'll get a single IP address in reply. The hosts file allows no way of distinguishing different "record types" for its resolution. So for hostname to IP address mapping, you only get one IP address per hostname (but multiple hostnames could resolve to the same IP address, which is the opposite).



Depending on what you're doing, might it be possible to use an external DNS service like dyndns.org to map a constant hostname, that will work on either network, to your IP address?


[#44605] Saturday, December 4, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fishutt

Total Points: 391
Total Questions: 137
Total Answers: 106

Location: Mexico
Member since Tue, Aug 11, 2020
4 Years ago
fishutt questions
Thu, Nov 17, 22, 07:36, 1 Year ago
Mon, Mar 28, 22, 15:09, 2 Years ago
Wed, Feb 8, 23, 06:50, 1 Year ago
Thu, Aug 25, 22, 13:26, 2 Years ago
Fri, Apr 22, 22, 00:08, 2 Years ago
;