diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 1f3ee8cc1..5b138bd31 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -1098,7 +1098,8 @@ sub my_if_netmap Error: none Example: - xCAT::NetworkUtils->my_ip_facing + my $ip = xCAT::NetworkUtils->my_ip_facing($peerip) + my @ip = xCAT::NetworkUtils->my_ip_facing($peerip) # return multiple Comments: none =cut @@ -1116,6 +1117,8 @@ sub my_ip_facing unless ($peernumber) { return undef; } my $noden = unpack("N", inet_aton($peer)); my @nets = split /\n/, `/sbin/ip addr`; + + my @ips; foreach (@nets) { my @elems = split /\s+/; @@ -1128,10 +1131,19 @@ sub my_ip_facing my $curn = unpack("N", inet_aton($curnet)); if (($noden & $curmask) == ($curn & $curmask)) { - return $curnet; + push @ips, $curnet; } } - return undef; + + if (@ips) { + if (wantarray) { + return @ips; + } else { + return $ips[0]; + } + } else { + return undef; + } } #------------------------------------------------------------------------------- diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index b41649019..ed9a6a0f1 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -355,13 +355,15 @@ sub process_request { if ($net and $net->{nameservers}) { my $valid = 0; - my $myip = xCAT::NetworkUtils->my_ip_facing($net->{net}); + my @myips = xCAT::NetworkUtils->my_ip_facing($net->{net}); foreach (split /,/, $net->{nameservers}) { chomp $_; - if (($_ eq $myip) || ($_ eq '') || ($_ eq $sitens)) - { - $valid += 1; + foreach my $myip (@myips) { + if (($_ eq $myip) || ($_ eq '') || ($_ eq $sitens)) + { + $valid += 1; + } } } unless ($valid > 0)