Can a host file DNS entry point to multiple Ip addresses?

Can a host file DNS entry point to multiple Ip addresses ?

basically i want have to ad servers , but no balancer due to port issues , the solution i think is host file entry ,but can one dns point to multiple ip address ?

1 Answer

Mostly dupe How to add multiple IPv6 address for single host in /etc/hosts? as auto-suggested by Stack.

Can a hostfile entry point to multiple addresses? NO

Can a hostfile have a hostname pointed to multiple addresses? YES

You can have multiple entries for the same name, e.g.:

192.168.99.12 testhost.local
192.168.99.34 testhost.local
192.168.99.56 testhost.local

This has the same effect as multiple A records in DNS for the name; gethostbyname or getaddrinfo for the name will return all the addresses, as an array or linked list respectively.

However, what a client program will do with multiple addresses depends entirely, and wildly, on the client program. Some will choose randomly, or at least maybe-somewhat-randomly, some will always use the first address, some will use the first address unless an error occurs then the second, some may even use several (or all) in parallel. Only if you are pretty lucky will you get a result similar to using an actual load balancer. Although you will avoid having a single-point-of-failure.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like