diff --git a/systemvm/debian/etc/dnsmasq.conf.tmpl b/systemvm/debian/etc/dnsmasq.conf.tmpl index 4e9d2496293..f0925541090 100644 --- a/systemvm/debian/etc/dnsmasq.conf.tmpl +++ b/systemvm/debian/etc/dnsmasq.conf.tmpl @@ -636,3 +636,4 @@ log-facility=/var/log/dnsmasq.log conf-dir=/etc/dnsmasq.d dhcp-optsfile=/etc/dhcpopts.txt +localise-queries diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index 0caba6dea26..964cf7a860d 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -108,6 +108,12 @@ class CsDhcp(CsDataBag): if gn.get_dns() and device: sline = "dhcp-option=tag:interface-%s-%s,6" % (device, idx) dns_list = [x for x in gn.get_dns() if x] + if self.config.is_dhcp() and not self.config.use_extdns(): + guest_ip = self.config.address().get_guest_ip() + if guest_ip and guest_ip in dns_list and ip not in dns_list: + ## Replace the default guest IP in VR with the ip in additional IP ranges, if shared network has multiple IP ranges. + dns_list.remove(guest_ip) + dns_list.insert(0, ip) line = "dhcp-option=tag:interface-%s-%s,6,%s" % (device, idx, ','.join(dns_list)) self.conf.search(sline, line) if gateway != '0.0.0.0': @@ -129,8 +135,10 @@ class CsDhcp(CsDataBag): else: listen_address.append(ip) # Add localized "data-server" records in /etc/hosts for VPC routers - if self.config.is_vpc(): + if self.config.is_vpc() or self.config.is_router(): self.add_host(gateway, "%s data-server" % CsHelper.get_hostname()) + elif self.config.is_dhcp(): + self.add_host(ip, "%s data-server" % CsHelper.get_hostname()) idx += 1 # Listen Address @@ -166,8 +174,6 @@ class CsDhcp(CsDataBag): self.add_host("::1", "localhost ip6-localhost ip6-loopback") self.add_host("ff02::1", "ip6-allnodes") self.add_host("ff02::2", "ip6-allrouters") - if self.config.is_router() or self.config.is_dhcp(): - self.add_host(self.config.address().get_guest_ip(), "%s data-server" % CsHelper.get_hostname()) def write_hosts(self): file = CsFile("/etc/hosts")