From 28392da09ad01d565d9372643f2d3daf593958d3 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 29 Sep 2021 11:10:15 +0200 Subject: [PATCH 1/3] VR: fix data-server if shared network has multiple ip ranges This fixes #5518 --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index 487d247b744b..5b694c51a474 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -129,8 +129,10 @@ def configure_server(self): 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 +168,6 @@ def preseed(self): 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") From f3814868141ff331d3949c48fdf45cfe7d991053 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 30 Sep 2021 09:31:29 +0200 Subject: [PATCH 2/3] Update PR #5530: fix nameserver in vm with IP in additional IP ranges without this change ``` root@r-757-VM:~# cat /etc/dnsmasq.d/cloud.conf listen-address=127.0.0.1,10.10.12.31,10.10.13.19 dhcp-range=set:interface-eth0-0,10.10.12.31,static dhcp-option=tag:interface-eth0-0,15,cs1cloud.internal dhcp-option=tag:interface-eth0-0,6,10.10.12.31,10.0.32.1,8.8.8.8 dhcp-option=tag:interface-eth0-0,3,10.10.12.254 dhcp-option=tag:interface-eth0-0,1,255.255.255.0 dhcp-range=set:interface-eth0-1,10.10.13.19,static dhcp-option=tag:interface-eth0-1,15,cs1cloud.internal dhcp-option=tag:interface-eth0-1,6,10.10.12.31,10.0.32.1,8.8.8.8 <<< nameserver 10.10.12.31 dhcp-option=tag:interface-eth0-1,3,10.10.13.254 dhcp-option=tag:interface-eth0-1,1,255.255.255.0 ``` with this change ``` root@r-757-VM:~# cat /etc/dnsmasq.d/cloud.conf listen-address=127.0.0.1,10.10.12.31,10.10.13.19 dhcp-range=set:interface-eth0-0,10.10.12.31,static dhcp-option=tag:interface-eth0-0,15,cs1cloud.internal dhcp-option=tag:interface-eth0-0,6,10.10.12.31,10.0.32.1,8.8.8.8 dhcp-option=tag:interface-eth0-0,3,10.10.12.254 dhcp-option=tag:interface-eth0-0,1,255.255.255.0 dhcp-range=set:interface-eth0-1,10.10.13.19,static dhcp-option=tag:interface-eth0-1,15,cs1cloud.internal dhcp-option=tag:interface-eth0-1,6,10.10.13.19,10.0.32.1,8.8.8.8 <<< nameserver 10.10.13.19 dhcp-option=tag:interface-eth0-1,3,10.10.13.254 dhcp-option=tag:interface-eth0-1,1,255.255.255.0 ``` --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index 5b694c51a474..381b8c0e6159 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -108,6 +108,12 @@ def configure_server(self): 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': From f521ab9531a8ab4b7c7398c86949acf740888b23 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 30 Sep 2021 09:42:35 +0200 Subject: [PATCH 3/3] Update #5530: add 'localise-queries' to /etc/dnsmasq.conf --- systemvm/debian/etc/dnsmasq.conf.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/systemvm/debian/etc/dnsmasq.conf.tmpl b/systemvm/debian/etc/dnsmasq.conf.tmpl index 4e9d24962934..f09255410901 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