[pve-devel] applied: [PATCH container] seperate serachdomain and nameserver config

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Mar 7 15:02:43 CET 2018


applied, will add the same behavior to cloud-init

On Tue, Mar 06, 2018 at 11:08:04AM +0100, Dominik Csapak wrote:
> until now, if either searchdomain or nameservers was not set,
> we used the values from the host.
> 
> it would make sense, to set this individually (e.g. only use a
> different searchdomain)
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PVE/LXC/Setup/Base.pm | 31 ++++++++++++++-----------------
>  1 file changed, 14 insertions(+), 17 deletions(-)
> 
> diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
> index 0228fe7..62e37b9 100644
> --- a/src/PVE/LXC/Setup/Base.pm
> +++ b/src/PVE/LXC/Setup/Base.pm
> @@ -28,27 +28,24 @@ sub lookup_dns_conf {
>      my $nameserver = $conf->{nameserver};
>      my $searchdomains = $conf->{searchdomain};
>  
> -    if (!($nameserver && $searchdomains)) {
> -
> -	if ($conf->{'testmode'}) {
> -	    
> -	    $nameserver = "8.8.8.8 8.8.8.9";
> -	    $searchdomains = "proxmox.com";
> -	
> -	} else {
> -
> -	    my $host_resolv_conf = $self->{host_resolv_conf};
> +    if ($conf->{'testmode'}) {
> +	return ('proxmox.com', '8.8.8.8 8.8.8.9');
> +    }
>  
> -	    $searchdomains = $host_resolv_conf->{search};
> +    my $host_resolv_conf = $self->{host_resolv_conf};
>  
> -	    my @list = ();
> -	    foreach my $k ("dns1", "dns2", "dns3") {
> -		if (my $ns = $host_resolv_conf->{$k}) {
> -		    push @list, $ns;
> -		}
> +    if (!defined($nameserver)) {
> +	my @list = ();
> +	foreach my $k ("dns1", "dns2", "dns3") {
> +	    if (my $ns = $host_resolv_conf->{$k}) {
> +		push @list, $ns;
>  	    }
> -	    $nameserver = join(' ', @list);
>  	}
> +	$nameserver = join(' ', @list);
> +    }
> +
> +    if (!defined($searchdomains)) {
> +	$searchdomains = $host_resolv_conf->{search};
>      }
>  
>      return ($searchdomains, $nameserver);
> -- 
> 2.11.0




More information about the pve-devel mailing list