DHCP + TinyDNS + MultiLAN



  • I have changed TinyDNS code to support MultiLAN. The problem with the original version is that it only register DHCP Static Leases from LAN interface and not others LAN interfaces (OPTX). So I have a modification made in tinydns.inc file which i would like to share with any one interested. The modification where made in version "tinydns.inc,v 1.86 2008/02/14 18:04:33 sullrich Exp".

    where in the file is:

    if($config['installedpackages']['tinydns']['config'][0]['regdhcpstatic']) {
                            if(is_array($config['dhcpd']['lan']['staticmap'])) {
                                    foreach($config['dhcpd']['lan']['staticmap'] as $dhcpdstatic) {
                                            $dhcpdhostname = $dhcpdstatic['hostname'];
                                            $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}";
                                            $dhcpdlanip = $dhcpdstatic['ipaddr'];
                                            $dhcpda = "={$dhcpdfqdn}:{$dhcpdlanip}";
                                            if($dhcpdhostname)
                                                    fwrite($fd, $dhcpda . "\n");
                                    }
                            }
                    }

    replace by:

    if($config['installedpackages']['tinydns']['config'][0]['regdhcpstatic']) {
                            foreach($config['dhcpd'] as $zone_key => $zone ) {
                                    $dhcpdhostname = $config['system']['hostname'];
                                    if ($zone['ddnsdomain']) 
                                            $dhcpddomain = $zone['ddnsdomain'];
                                    else
                                            $dhcpddomain = $config['system']['domain'];
                                    $dhcpdlanip = $config['interfaces'][$zone_key]['ipaddr'];
                                    $dhcpdipmask = $config['interfaces'][$zone_key]['subnet'];
                                    $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}";
                                    tinydns_complete_soa_record($fd, $dhcpdlanip, $dhcpdipmask, $dhcpdhostname, $dhcpddomain);

    if(is_array($zone['staticmap'])) {
                                            foreach($zone['staticmap'] as $dhcpdstatic) {
                                                    $dhcpdhostname = $dhcpdstatic['hostname'];
                                                    $dhcpdfqdn = "{$dhcpdhostname}.{$dhcpddomain}";
                                                    $dhcpdlanip = $dhcpdstatic['ipaddr'];
                                                    $dhcpda = "={$dhcpdfqdn}:{$dhcpdlanip}";
                                                    if($dhcpdhostname)
                                                            fwrite($fd, $dhcpda . "\n");
                                            }
                                    }
                            }
                    }

    This modification is working fine to me. It may have probs that i did not find. Working with 4 LAN'd each with Static DHCP Leases to register in.

    Hope this helps someone out there… and me if this goes to main line ;)

    Sorry for my bad english I'm Portuguese



  • Thanks, commited.

    In the future please submit patches through this process http://devwiki.pfsense.org/SubmittingPatches


Locked