def dig_reverse_resolve(self, ip, version=4, removing=False): """Reverse resolve `ip` using dig. Returns a list of results.""" self.dns_wait_soa(IPAddress(ip).reverse_dns, removing) output = dig_call( port=self.bind.config.port, commands=['-x', ip, '+short', '-%i' % version]) return output.split('\n')
def dig_reverse_resolve(self, ip, version=4, removing=False): """Reverse resolve `ip` using dig. Returns a list of results.""" self.dns_wait_soa(IPAddress(ip).reverse_dns, removing) output = dig_call( port=self.bind.config.port, commands=["-x", ip, "+short", "-%i" % version], ) return output.split("\n")
def dig_resolve(self, fqdn, version=4, removing=False): """Resolve `fqdn` using dig. Returns a list of results.""" # Using version=6 has two effects: # - it changes the type of query from 'A' to 'AAAA'; # - it forces dig to only use IPv6 query transport. self.dns_wait_soa(fqdn, removing) record_type = "AAAA" if version == 6 else "A" commands = [fqdn, "+short", "-%i" % version, record_type] output = dig_call(port=self.bind.config.port, commands=commands) return output.split("\n")
def test_dns_config_has_NS_record(self): self.patch(settings, "DNS_CONNECT", True) ip = factory.make_ipv4_address() with RegionConfiguration.open_for_update() as config: config.maas_url = "http://%s/" % ip domain = factory.make_Domain() node, static = self.create_node_with_static_ip(domain=domain) dns_update_all_zones() # Creating the domain triggered writing the zone file and updating the # DNS. self.dns_wait_soa(domain.name) # Get the NS record for the zone 'domain.name'. ns_record = dig_call(port=self.bind.config.port, commands=[domain.name, "NS", "+short"]) self.assertGreater(len(ns_record), 0, "No NS record for domain.name.") # Resolve that hostname. self.dns_wait_soa(ns_record) ip_of_ns_record = dig_call(port=self.bind.config.port, commands=[ns_record, "+short"]) self.assertEqual(ip, ip_of_ns_record)