Changeset 342
- Timestamp:
- Aug 30, 2018, 2:49:44 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ddt/ddt
r341 r342 2613 2613 2614 2614 GetOptions( 2615 ' Direct|D' => \$opt_direct,2615 'direct|d' => \$opt_direct, 2616 2616 'reverse|r' => \$opt_reverse, 2617 2617 ); … … 2619 2619 my $computer_db = ipamdb_load($COMPUTER_YAML); 2620 2620 2621 LOOP_ON_DOMAINSET: 2622 for my $domainset_current (keys %{$computer_db}) { 2623 last LOOP_ON_DOMAINSET if $opt_direct; # No DDT to DNS check 2624 next if $domainset_current eq 'dset'; 2625 next if $domainset_current eq 'pool'; 2626 next if $domainset_current eq 'pxe'; 2627 next if $domainset_current eq 'tag'; 2628 next if $domainset_current eq 'version'; 2629 2630 my @domainsetdb = @{$computer_db->{$domainset_current}}; 2631 2632 LOOP_ON_COMPUTER: 2633 for my $computer (@domainsetdb) { 2634 my ($mac_address, $attribute) = %{$computer}; 2635 #my $new_mac = normalize_mac_address($mac_address); 2636 my $ip = $attribute->{'ip'}; 2637 next LOOP_ON_COMPUTER if not $ip =~ m/$DDT::RE::IPv4_ADDRESS/xms; 2638 next LOOP_ON_COMPUTER if $attribute->{'enabled'} eq 'no'; 2639 2640 my $dns_hostname_fq = scalar gethostbyaddr(inet_aton($ip), AF_INET); 2641 my ($dns_hostname) = split /\./, $dns_hostname_fq; 2642 2643 if ($attribute->{'hostname'} ne $dns_hostname) { 2644 print "$mac_address ($domainset_current) $ip - $dns_hostname / $attribute->{'hostname'} # $attribute->{'comment'}\n"; 2645 next LOOP_ON_COMPUTER; 2646 } 2647 2648 my $packed_ip = scalar gethostbyname($dns_hostname_fq); 2649 if (defined $packed_ip) { 2650 my $ip_address = inet_ntoa($packed_ip); 2651 if ($ip ne $ip_address) { 2652 print "reverse DNS error for $dns_hostname_fq / $ip\n"; 2621 if ($opt_direct or not $opt_reverse) { # DDT to DNS check 2622 LOOP_ON_DOMAINSET: 2623 for my $domainset_current (keys %{$computer_db}) { 2624 next if $domainset_current eq 'dset'; 2625 next if $domainset_current eq 'pool'; 2626 next if $domainset_current eq 'pxe'; 2627 next if $domainset_current eq 'tag'; 2628 next if $domainset_current eq 'version'; 2629 2630 my @domainsetdb = @{$computer_db->{$domainset_current}}; 2631 2632 LOOP_ON_COMPUTER: 2633 for my $computer (@domainsetdb) { 2634 my ($mac_address, $attribute) = %{$computer}; 2635 #my $new_mac = normalize_mac_address($mac_address); 2636 my $ip = $attribute->{'ip'}; 2637 next LOOP_ON_COMPUTER if not $ip =~ m/$DDT::RE::IPv4_ADDRESS/xms; 2638 next LOOP_ON_COMPUTER if $attribute->{'enabled'} eq 'no'; 2639 2640 my $dns_hostname_fq = scalar gethostbyaddr(inet_aton($ip), AF_INET); 2641 my ($dns_hostname) = split /\./, $dns_hostname_fq; 2642 2643 if ($attribute->{'hostname'} ne $dns_hostname) { 2644 print "$mac_address ($domainset_current) $ip - $dns_hostname / $attribute->{'hostname'} # $attribute->{'comment'}\n"; 2653 2645 next LOOP_ON_COMPUTER; 2654 2646 } 2655 } 2656 } 2657 } 2658 2659 if ($opt_reverse) { # No DNS to DDT check 2647 2648 my $packed_ip = scalar gethostbyname($dns_hostname_fq); 2649 if (defined $packed_ip) { 2650 my $ip_address = inet_ntoa($packed_ip); 2651 if ($ip ne $ip_address) { 2652 print "Error: bad IP for reverse DNS on $dns_hostname_fq / $ip\n"; 2653 next LOOP_ON_COMPUTER; 2654 } 2655 } 2656 } 2657 } 2658 } 2659 2660 if ($opt_reverse) { # DNS to DDT check 2660 2661 my %saw; # count for unique member 2661 2662 my @dns_domain_list = sort grep !$saw{$_}++, … … 3149 3150 ddt change-mac [--hostname|-h hostname] [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] 3150 3151 ddt change-tag [--hostname|-h hostname] [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3151 ddt check-dns [-- Direct] [--reverse]3152 ddt check-dns [--direct] [--reverse] 3152 3153 ddt create-domainset [--domainset|-d domainset] [--dns-extension|-e dns_extension] [--comment|-c comment] 3153 3154 ddt create-pool [--pool|-p pool] [--domainset|-d domainset] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool] … … 3243 3244 ddt change-mac [--hostname|-h hostname] [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] 3244 3245 ddt change-tag [--hostname|-h hostname] [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3245 ddt check-dns [-- Direct] [--reverse]3246 ddt check-dns [--direct] [--reverse] 3246 3247 ddt create-domainset [--domainset|-d domainset] [--dns-extension|-e dns_extension] [--comment|-c comment] 3247 3248 ddt create-pool [--pool|-p pool] [--domainset|-d domainset] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool] … … 3332 3333 =head2 check-dns 3333 3334 3334 ddt check-dns [-- Direct] [--reverse]3335 ddt check-dns [--direct] [--reverse] 3335 3336 3336 3337 =head2 create-domainset
Note: See TracChangeset
for help on using the changeset viewer.