From 59c1630e76f507680c8e12824cefe9cedc681777 Mon Sep 17 00:00:00 2001 From: Yuan Bai Date: Thu, 24 Jan 2019 14:36:35 +0800 Subject: [PATCH] add dnsforwardmode for makedns (#5970) * add forwardmode for makedns * polished * polished * update site table man doc * polished * polished --- .../admin-guides/references/man5/site.5.rst | 5 ++++ perl-xCAT/xCAT/Schema.pm | 4 +++ xCAT-server/lib/xcat/plugins/ddns.pm | 29 ++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/source/guides/admin-guides/references/man5/site.5.rst b/docs/source/guides/admin-guides/references/man5/site.5.rst index 7a3361399..d03af4847 100644 --- a/docs/source/guides/admin-guides/references/man5/site.5.rst +++ b/docs/source/guides/admin-guides/references/man5/site.5.rst @@ -135,6 +135,11 @@ site Attributes: service nodes will ignore this value and always be configured to forward to the management node. + dnsforwardmode: (first or only or no). This is to set forward value in named.conf options section. + "first": causes DNS requests to be forwarded before an attempt is made to resolve them via the root name servers. + "only": all requests are forwarded and none sent to the root name servers. + "no": no request will be forwarded. This is the default value if not specified. + emptyzonesenable: (yes or no). This is to set empty-zones-enable value in named.conf options section. master: The hostname of the xCAT management node, as known by the nodes. diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 9ce4d16d7..e792677b8 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1059,6 +1059,10 @@ passed as argument rather than by table value', " requests it does not know to these servers. Note that the DNS servers on the\n" . " service nodes will ignore this value and always be configured to forward \n" . " to the management node.\n\n" . +" dnsforwardmode: (first or only or no). This is to set forward value in named.conf options section. \n" . +" \"first\": causes DNS requests to be forwarded before an attempt is made to resolve them via the root name servers. \n" . +" \"only\": all requests are forwarded and none sent to the root name servers.\n". +" \"no\": no request will be forwarded. This is the default value if not specified. \n\n" . " emptyzonesenable: (yes or no). This is to set empty-zones-enable value in named.conf options section. \n\n" . " master: The hostname of the xCAT management node, as known by the nodes.\n\n" . " nameservers: A comma delimited list of DNS servers that each node in the cluster should\n" . diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 229462157..556a217b8 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -785,7 +785,7 @@ sub process_request { "Update Named Conf dir $ctx->{dbdir} $ctx->{zonesdir}"; xCAT::MsgUtils->message("I", $rsp, $callback); } - + $ctx->{forwardmode} = get_forwardmode(); update_namedconf($ctx, $slave); unless ($slave) @@ -935,6 +935,27 @@ sub get_zonesdir { return "$ZonesDir"; } +sub get_forwardmode { + my $forwardmode; + my @entries = xCAT::TableUtils->get_site_attribute("dnsforwardmode"); + my $site_entry = $entries[0]; + if (defined($site_entry)) { + if ($site_entry =~ /^only$|^first$/) { + $forwardmode = $site_entry; + } elsif ($site_entry =~ /^no$/) { + $forwardmode = "" + }else { + my $rsp = {}; + $rsp->{data}->[0] = "forward mode $site_entry is not supported, supported value: only, first, no."; + xCAT::MsgUtils->message("S", "forward mode $site_entry is not supported, supported value: only, first, no."); + xCAT::MsgUtils->message("W", $rsp, $callback); + return; + } + } + return "$forwardmode"; +} + + sub get_conf { my $conf = "/etc/named.conf"; @@ -1114,6 +1135,8 @@ sub update_namedconf { push @newnamed, "\t\t" . $_ . ";\n"; } push @newnamed, "\t};\n"; + } elsif ($ctx->{forwardmode} and $line =~ /forward/) { + push @newnamed, "\tforward " . $ctx->{forwardmode} . ";\n"; } elsif ($ctx->{empty_zones_enable} and $line =~ /empty-zones-enable/) { push @newnamed, "\tempty-zones-enable " . $ctx->{empty_zones_enable} . ";\n"; } elsif ($ctx->{slaves} and $line =~ /allow-transfer \{/) { @@ -1255,6 +1278,10 @@ sub update_namedconf { push @newnamed, "\t};\n"; } + if ($ctx->{forwardmode}){ + push @newnamed, "\tforward " . $ctx->{forwardmode} . ";\n"; + } + if ($ctx->{empty_zones_enable}){ push @newnamed, "\tempty-zones-enable " . $ctx->{empty_zones_enable} . ";\n"; }