Bug #3262

DHCP: multiple dns option ignored

Added by Giacomo Sanchietti almost 6 years ago. Updated almost 6 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-dnsmasq
Target version:v6.7-final
Security class: Resolution:
Affected version:v6.6 NEEDINFO:No

Description

Given a configured DHCP range with a list of DNS servers, dnsmasq sends to clients only the first DNS server address.

Steps to reproduce
  • Create a new DHCP range associated to a green interface
  • Click on "Advanced" options
  • Set a list of two IPs inside the "DNS servers" field
  • Start a DHCP client
  • The client will receive only the first DNS server

Expected behavior
DHCP server must send both DNS server addresses to the client

Thanks to @Adam for reporting. Refence: http://community.nethserver.org/t/dhcp-bug-when-assigning-multiple-dns-servers/1628

Associated revisions

Revision 0e9eeb6f
Added by Giacomo Sanchietti almost 6 years ago

Merge pull request #4 from LucentW/multiple-dns-patch

Fix multiple DNS server option. Refs #3262

Revision ad339b11
Added by Giacomo Sanchietti almost 6 years ago

Refactor code for multiple DNS server option. Refs #3262

Revision a78475ca
Added by Davide Principi almost 6 years ago

Merge branch '6.7'. Refs #3262

History

#1 Updated by Giacomo Sanchietti almost 6 years ago

  • Description updated (diff)

Tested solution

Create a template custom /etc/e-smith/templates-custom/etc/dnsmasq.conf/30dhcp with the following content:

#
# 30dhcp
#

# Enable the DHCP server. Addresses will be given out from the range
# <start-addr> to <end-addr> and from statically defined addresses
# given in dhcp-host options. 
# See db configuration getprop dnsmasq DhcpStatus

{
    use NetAddr::IP;
    my $db = esmith::ConfigDB->open_ro("dhcp") || die "Can't open dhcp database: $!\n";
    my $ndb = esmith::NetworksDB->open_ro() || die "Can't open networks database: $!\n";
    my $tot_range_length = 0;
    foreach ($db->get_all_by_prop("type" => "range")) {
        my $status = $_->prop('status') || 'disabled';
        if ( $status eq 'enabled') {
            my $interface = $_->key;
            my $start = $_->prop('DhcpRangeStart') || next;
            my $end = $_->prop('DhcpRangeEnd') || next;
            my $start_ip = new NetAddr::IP($start);
            my $end_ip = new NetAddr::IP($end);
            my $range_length = $end_ip->numeric - $start_ip->numeric;
            $tot_range_length += $range_length;
            my $lease = $_->prop('DhcpLeaseTime') || '86400';
            $OUT .= 'dhcp-range=' . join(',',$_->key,$start,$end,$lease) . "\n";

            my $domain = $_->prop('DhcpDomain') || '';
            if ($domain ne '') {
                $OUT .= 'domain=' . join(',',$domain,$start,$end) . "\n";
            }

            # Send router configuration to clients
            my $router = $_->prop('DhcpGatewayIP') || '';
            if ($router eq '') {
                my $i = $ndb->get($_->key);
                if ($ndb->red()) {
                    $router = $i->prop('ipaddr');
                } else {
                    $router = $i->prop('gateway') || $i->prop('ipaddr');
                }
            }
            if ($router) {
               $OUT .= "dhcp-option=".$_->key.",option:router,$router\n";
            } else {
               $OUT .= "# dhcp-option=".$_->key.",option:router,<UNDEFINED>";
            }

            my $dns_server = $_->prop('DhcpDNS') || '';
            if ($dns_server ne '') {
               $OUT .= "dhcp-option=$interface,option:dns-server,$dns_server\n";
            }

            my $ntp_server = $_->prop('DhcpNTP') || '';
            if ($ntp_server ne '') {
               foreach (split(',',$ntp_server)) {
                   $OUT .= "dhcp-option=$interface,option:ntp-server,$_\n";
               }
            }

            my $wins_server = $_->prop('DhcpWINS') || '';
            if ($wins_server ne '') {
               foreach (split(',',$wins_server)) {
                   $OUT .= "dhcp-option=$interface,44,$_ # WINS\n";
               }
            }

            my $tftp_server = $_->prop('DhcpTFTP') || '';
            if ($tftp_server ne '') {
               foreach (split(',',$tftp_server)) {
                   $OUT .= "dhcp-option=$interface,66,$_ # TFTP\n";
               }
            }

        } else {
            $OUT .= "\n# DHCP disabled on ".$_->key."\n";
        } 
    }
    if ($tot_range_length > 0) {
        use esmith::HostsDB;
        my $hdb = esmith::HostsDB->open_ro() || die "Can't open hosts database: $!\n";
        foreach ($hdb->get_all_by_prop('type' => 'local')) {
            $_->prop('MacAddress') || next;
            $tot_range_length++;
        }
        $OUT .= "dhcp-lease-max=$tot_range_length\n";
    }
}

# Should be set when dnsmasq is definitely the only DHCP server on a
# network.
dhcp-authoritative

# Read dhcp reservations from dhcp-hostsfile. 
# See dhcp-hosts option for more informations.
dhcp-hostsfile=/etc/dnsmasq-dhcp-hosts

#2 Updated by Giacomo Sanchietti almost 6 years ago

  • Affected version set to v6.6

#3 Updated by Giacomo Sanchietti almost 6 years ago

  • Status changed from NEW to TRIAGED
  • Target version set to v6.6
  • % Done changed from 0 to 20

#4 Updated by Giacomo Sanchietti almost 6 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Giacomo Sanchietti
  • % Done changed from 20 to 30

#5 Updated by Giacomo Sanchietti almost 6 years ago

  • Status changed from ON_DEV to MODIFIED
  • % Done changed from 30 to 60

Thanks to LucentW for the patch.

#6 Updated by Giacomo Sanchietti almost 6 years ago

  • Status changed from MODIFIED to ON_QA
  • Assignee deleted (Giacomo Sanchietti)
  • % Done changed from 60 to 70
Package in nethserver-testing:
  • nethserver-dnsmasq-1.5.1-1.4.gad339b1.ns6.noarch.rpm
Test case
  • Check the bug is not reproducible

#7 Updated by dz0 0te almost 6 years ago

  • Assignee set to dz0 0te

#8 Updated by dz0 0te almost 6 years ago

  • Status changed from ON_QA to VERIFIED
  • Assignee deleted (dz0 0te)
  • % Done changed from 70 to 90

System and Package Version installed
HP Microserver N40L - Nethserver 6.6 fully updated
Package Installed: nethserver-dnsmasq-1.5.1-1.ns6.noarch
Other Package installed: Bandwidth monitor,Basic firewall,DNS and DHCP server.Intrusion Prevention,System,POP3 proxy,SMTP proxy,Statistics,UPS support,VPN,Web filter,Web proxy,Web server

Test Original Problem
Bug confirmed, only one dns server is assigned to client

Install Updated Package

yum update --enablerepo=nethserver-testing nethserver-dnsmasq-1.5.1-1.4.gad339b1.ns6

Test Results after install
Test case 1:
configure 2 dns in advanced option of dhcp settings.
Ok on Windows10/Linux(Fedora22)/Mac(10.10.4)

Test case 2:
configure 3 dns in advanced option of dhcp settings.
Ok on Windows10/Linux(Fedora22)/Mac(10.10.4)

Verified or Reopen
Verified

Note
tested only on eth0 -Green network

#9 Updated by Giacomo Sanchietti almost 6 years ago

  • Target version changed from v6.6 to v6.7

#10 Updated by Davide Principi almost 6 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100

In nethserver-base/6.7:

nethserver-dnsmasq-1.5.3-1.ns6.noarch.rpm

#11 Updated by Giacomo Sanchietti almost 6 years ago

  • Target version changed from v6.7 to v6.7-final

Also available in: Atom PDF