Question : Can /etc/hosts file be used for failover ?

Can an /etc/hosts file be used for failover ?

e.g. I have a machine A which needs to get a resource R that is present on both Machine B and Machine C

The /etc/hosts/ file on machine A looks as below




Would it be reasonable to expect that the machine A will get the resource R from machine C, IF machine B is down (unreachable) ?

Please give me reasons as to why this might or might not be possible ?

If both machines are up and running, which IP address is going to be picked up when I type in the URL to the resource R ? I am looking for explanations and logic behind your answer

Thanks,

Answer : Can /etc/hosts file be used for failover ?

That's not going to work.

Lookups from a hosts file are first match, so if you have different IP's equated to the same host name it will always be the IP of the first hostname that is returned. Furthermore, the system doesn't care when it looks up an IP in the hosts file whether the machine having that IP is up or not.
Random Solutions  
 
programming4us programming4us