Project

General

Profile

« Previous | Next » 

Revision 153613e3

Added by Phil Davis over 10 years ago

Handle reverse lookup domain overrides

that match exactly a whole block of private address space.
e.g. if the user has checked "Do not forward private reverse lookups" and also adds adds a domain override that matches a whole block of private address space, such as:
10.in-addr.arpa -> 10.42.1.1
then we want all reverse lookups in the "10" network to be referred to their DNS server at 10.42.1.1 and reverse lookups of other private addresses to immediately return NXDOMAIN.
Without this change, those referrals were not happening, because there was a "-server=10.in-addr.arpa" to nowhere put on the command line and that was effectively overriding the user-specified domain override!

View differences:

etc/inc/services.inc
1825 1825
		}
1826 1826

  
1827 1827
		/* If selected, then first forward reverse lookups for private IPv4 addresses to nowhere. */
1828
		/* If any of these are duplicated by a user-specified domain override (e.g. 10.in-addr.arpa) then */
1829
		/* the user-specified entry made later on the command line below will be the one that is effective. */
1828
		/* Only make entries for reverse domains that do not have a matching domain override. */
1830 1829
		if (isset($config['dnsmasq']['no_private_reverse'])) {
1831 1830
			/* Note: Carrier Grade NAT (CGN) addresses 100.64.0.0/10 are intentionally not here. */
1832 1831
			/* End-users should not be aware of CGN addresses, so reverse lookups for these should not happen. */
1833 1832
			/* Just the pfSense WAN might get a CGN address from an ISP. */
1834
			$args .= " --server=/10.in-addr.arpa/ ";
1835
			$args .= " --server=/168.192.in-addr.arpa/ ";
1836
			/* Unfortunately the 172.16.0.0/12 range does not map nicely to the in-addr.arpa scheme. */
1833

  
1834
			// Build an array of domain overrides to help in checking for matches.
1835
			$override_a = array();
1836
			if (isset($config['dnsmasq']['domainoverrides']) && is_array($config['dnsmasq']['domainoverrides'])) {
1837
				foreach ($config['dnsmasq']['domainoverrides'] as $override) {
1838
					$override_a[$override['domain']] = "y";
1839
				}
1840
			}
1841

  
1842
			// Build an array of the private reverse lookup domain names
1843
			$reverse_domain_a = array("10.in-addr.arpa", "168.192.in-addr.arpa");
1844
			// Unfortunately the 172.16.0.0/12 range does not map nicely to the in-addr.arpa scheme.
1837 1845
			for ($subnet_num = 16; $subnet_num < 32; $subnet_num++) { 
1838
				$args .= " --server=/" . $subnet_num . ".172.in-addr.arpa/ ";
1846
				$reverse_domain_a[] = "$subnet_num.172.in-addr.arpa";
1847
			}
1848

  
1849
			// Set the --server parameter to nowhere for each reverse domain name that was not specifically specified in a domain override.
1850
			foreach ($reverse_domain_a as $reverse_domain) { 
1851
				if (!isset($override_a[$reverse_domain]))
1852
					$args .= " --server=/$reverse_domain/ ";
1839 1853
			}
1854
			unset($override_a);
1855
			unset($reverse_domain_a);
1840 1856
		}
1841 1857

  
1842 1858
		/* Setup forwarded domains */

Also available in: Unified diff