Project

General

Profile

« Previous | Next » 

Revision b4323f39

Added by Jim Pingle about 12 years ago

Add the ability for dnsmasq to selectively respond to queries only on certain IPs and bind to specific interfaces.

View differences:

etc/inc/services.inc
1577 1577
		if (is_port($config['dnsmasq']['port']))
1578 1578
			$args .= " --port={$config['dnsmasq']['port']} ";
1579 1579

  
1580
		$listen_addresses = "";
1581
		if(isset($config['dnsmasq']['interface'])) {
1582
			$interfaces = explode(",", $config['dnsmasq']['interface']);
1583
			foreach ($interfaces as $interface) {
1584
				if (is_ipaddr($interface)) {
1585
					$listen_addresses .= " --listen-address={$interface} ";
1586
				} else {
1587
					$if = get_real_interface($interface);
1588
					if (does_interface_exist($if)) {
1589
						$laddr = find_interface_ip($if);
1590
						if (is_ipaddrv4($laddr))
1591
							$listen_addresses .= " --listen-address={$laddr} ";
1592
						$laddr6 = find_interface_ipv6($if);
1593
						if (is_ipaddrv6($laddr6) && !isset($config['dnsmasq']['strictbind']))
1594
							$listen_addresses .= " --listen-address={$laddr6} ";
1595
					}
1596
				}
1597
			}
1598
			if (!empty($listen_addresses)) {
1599
				$args .= " {$listen_addresses} ";
1600
				if (isset($config['dnsmasq']['strictbind']))
1601
					$args .= " --bind-interfaces ";
1602
			}
1603
		}
1604

  
1580 1605
		/* Setup forwarded domains */
1581 1606
		if (isset($config['dnsmasq']['domainoverrides']) && is_array($config['dnsmasq']['domainoverrides'])) {
1582 1607
			foreach($config['dnsmasq']['domainoverrides'] as $override) {
......
1625 1650
		}
1626 1651

  
1627 1652
		/* run dnsmasq */
1628
		mwexec_bg("/usr/local/sbin/dnsmasq --local-ttl 1 --all-servers {$dns_rebind} --dns-forward-max=5000 --cache-size=10000 {$args}");
1653
		$cmd = "/usr/local/sbin/dnsmasq --local-ttl 1 --all-servers {$dns_rebind} --dns-forward-max=5000 --cache-size=10000 {$args}";
1654
		//log_error("dnsmasq command: {$cmd}");
1655
		mwexec_bg($cmd);
1629 1656
		unset($args);
1630 1657

  
1631 1658
		if ($g['booting'])

Also available in: Unified diff