16

Is it possible to have round-robin DNS with the follwing configuration in /etc/hosts?

192.168.4.10 shaakunthala.local
192.168.4.20 shaakunthala.local

I'm on Linux.

Shaakunthala
  • 181
  • 1
  • 1
  • 7

2 Answers2

10

dnsmasq inludes Round-robin DNS out-of-the-box

> egrep -m1 '^nameserver' /etc/resolv.conf
nameserver 127.0.0.1
> grep -i rrtest /etc/hosts
1.1.1.1 rrtest
2.2.2.2 rrtest
> /etc/init.d/dnsmasq restart 
Shutting down dnsmasq:                                     [  OK  ]
Starting dnsmasq:                                          [  OK  ]
> nslookup rrtest 
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   rrtest
Address: 2.2.2.2
Name:   rrtest
Address: 1.1.1.1

> nslookup rrtest 
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   rrtest
Address: 1.1.1.1
Name:   rrtest
Address: 2.2.2.2
AndresVia
  • 253
  • 2
  • 9
  • 1
    dnsmasq can only archive wildcard dns or RR dns. You could use bind9 if you need the both features. – petertc Jun 20 '16 at 08:37
9

No, that doesn't work.

Also /etc/hosts is a primitive form of name->address mapping that DNS is meant to replace. If you want round-robin DNS, install a DNS server.

ThatGraemeGuy
  • 15,314
  • 12
  • 51
  • 78