pf-tools/pf-tools: add dns-search and dns-nameserver to /etc/net...

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Oct 23 12:30:02 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/d8e95fb70f60
changeset: 1337:d8e95fb70f60
user:      shad
date:      Thu Oct 23 14:28:52 2014 +0200
description:
add dns-search and dns-nameserver to /etc/network/interfaces

diffstat:

 lib/PFTools/Utils.pm |  33 +++++++++++++++++++++++++++++++--
 t/20.files.t         |   2 ++
 2 files changed, 33 insertions(+), 2 deletions(-)

diffs (76 lines):

diff -r 3e6bd2de80a4 -r d8e95fb70f60 lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm	Wed Sep 24 13:47:40 2014 +0200
+++ b/lib/PFTools/Utils.pm	Thu Oct 23 14:28:52 2014 +0200
@@ -1362,6 +1362,25 @@
     }
 
     my $host_ref = get_host_config( $hostname, $global_config, $site_name );
+    my $domain
+        = get_zone_from_hostname( $hostname, $global_config, $site_name );
+
+    my @dns = split qr{ \s* [,] \s* }xms, $host_ref->{'dns'}->{'resolver'};
+
+    my @nameservers = ();
+    foreach my $ip_type (qw( ipv4 ipv6 )) {
+        foreach my $dns (@dns) {
+            my $resolved_ref = __resolve_hostname(
+                {   hostname        => $dns,
+                    resolution_type => q{cnf},
+                    ip_type         => $ip_type,
+                    site_name       => $site_name,
+                    global_config   => $global_config,
+                }
+            );
+            push @nameservers, @{$resolved_ref};
+        }
+    }
 
     my $interfaces = {};
     my $routes     = {};
@@ -1369,7 +1388,7 @@
         push @{ $interfaces->{'__order'} }, $iface;
         $interfaces->{$iface}
             = __build_interface_lines_ref( $iface, $routes, $host_ref,
-            $pf_config );
+            $pf_config, $domain, @nameservers );
     }
 
 DESTINATION:
@@ -1431,7 +1450,7 @@
 =cut
 
 sub __build_interface_lines_ref {
-    my ( $iface, $routes, $host_ref, $pf_config ) = @_;
+    my ( $iface, $routes, $host_ref, $pf_config, $domain, @nameservers ) = @_;
 
     my @iface_lines;
 
@@ -1501,6 +1520,16 @@
         }
     }
 
+    # ubuntu and mdns overwrite /etc/resolv.conf taking value from here
+    if (    $host_ref->{'interfaces'}->{$iface}->{'vlan'}
+        and $host_ref->{'interfaces'}->{$iface}->{'vlan'} eq
+        $host_ref->{'deployment'}->{'dhcpvlan'} )
+    {
+        push @iface_lines, qq{\tdns-search\t$domain};
+        push @iface_lines,
+            qq{\tdns-nameservers\t} . join( q{ }, @nameservers );
+    }
+
     return \@iface_lines;
 }
 
diff -r 3e6bd2de80a4 -r d8e95fb70f60 t/20.files.t
--- a/t/20.files.t	Wed Sep 24 13:47:40 2014 +0200
+++ b/t/20.files.t	Thu Oct 23 14:28:52 2014 +0200
@@ -502,6 +502,8 @@
     qq{\tnetmask\t\t255.255.0.0},
     qq{\tnetwork\t\t10.1.0.0},
     qq{\tbroadcast\t10.1.255.255},
+    qq{\tdns-search\tprivate},
+    qq{\tdns-nameservers\t10.1.1.254 10.1.167.0 10.1.167.1},
     qq{},
     qq{auto eth0.39},
     qq{iface eth0.39 inet static},



More information about the pf-tools-commits mailing list