Permalink
Browse files

Feature #1872 (Separate auto_dns from discover)

  • Loading branch information...
Carlos Vicente
Carlos Vicente committed Jun 17, 2016
1 parent d9d08a6 commit 63faf037285f8230ec312dc2c59cd355bf16b345
View
@@ -24,7 +24,7 @@
# Flags
my ($ATOMIC, $ADDSUBNETS, $SUBSINHERIT, $BGPPEERS, $RECURSIVE, $INFO, $FWT,
$TOPO, $ARP, $PRETEND, $HELP, $_DEBUG);
$TOPO, $ARP, $AUTO_DNS, $PRETEND, $HELP, $_DEBUG);
$ENV{REMOTE_USER} = "netdot";
@@ -62,6 +62,7 @@
-F, --fwt Get forwarding tables
-T, --topology Update Topology
-A, --arp Get ARP tables
-N, --auto-dns Generate DNS records for interface IPs
--atomic Make updates atomic (enable transactions)
--add-subnets <0|1> Enable/Disable trying to add subnets from routing devices
--subs-inherit <0|1> Enable/Disable having new subnets inherit information from device
@@ -85,6 +86,7 @@
"F|fwt" => \$FWT,
"A|arp" => \$ARP,
"T|topology" => \$TOPO,
"N|auto-dns" => \$AUTO_DNS,
"c|communities:s" => \$commstrs,
"r|retries:s" => \$retries,
"o|timeout:s" => \$timeout,
@@ -113,13 +115,14 @@
print $USAGE;
exit;
}
if ( ($host && $db) || ($host && $blocks) || ($host && $file ) || ($db && $blocks) || ($db && $file) || ($blocks && $file) ){
if ( ($host && $db) || ($host && $blocks) || ($host && $file ) || ($db && $blocks)
|| ($db && $file) || ($blocks && $file) ){
print $USAGE;
die "Error: arguments -H, -B, -D and -E are mutually exclusive\n";
}
unless ( $INFO || $FWT || $ARP || $TOPO ){
unless ( $INFO || $FWT || $ARP || $TOPO || $AUTO_DNS ){
print $USAGE;
die "Error: You need to specify at least one of -I, -F, -A or -T\n";
die "Error: You need to specify at least one of -I, -F, -A, -T or N\n";
}
foreach my $flagref ( \$ADDSUBNETS, \$SUBSINHERIT, \$BGPPEERS ){
@@ -218,7 +221,16 @@
}else{
print $USAGE;
die "Error: You need to specify one of: -H, -B, -E, -D or -T\n";
die "Error: You need to specify one of: -H, -B, -E, or -D\n";
}
}
if ( $AUTO_DNS ){
if ( $host || $blocks || $file ){
die "Error: AUTO DNS option only works with -D"
}elsif ( $db ){
$logger->info("Generating DNS for interface IPs on all devices");
Netdot::Model::Device->do_auto_dns_all();
}
}
@@ -238,7 +250,7 @@ =head1 AUTHOR
=head1 COPYRIGHT & LICENSE
Copyright 2013 University of Oregon, all rights reserved.
Copyright 2016 University of Oregon, all rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -255,5 +267,3 @@ =head1 COPYRIGHT & LICENSE
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=cut
View
BIN -2 Bytes (100%) doc/manual/netdot-manual-es.epub
Binary file not shown.
View
BIN +0 Bytes (100%) doc/manual/netdot-manual-es.pdf
Binary file not shown.
View
BIN +230 Bytes (100%) doc/manual/netdot-manual.epub
Binary file not shown.
@@ -370,15 +370,22 @@ <h4 id="modules-tab-if-the-device-provides-module-information-via-snmp"><a href=
<p>Netdot will show it in this tab. Modules are shown hierarchically based on how they are contained within each other.</p>
<h4 id="ip-info-tab-this-section-lists-all-the-ip-addresses-found-in-the"><a href="#TOC"><span class="header-section-number">4.1.3.4</span> IP Info Tab: This section lists all the IP addresses found in the</a></h4>
<p>device, together with the subnets they belong in, the device interface where they were found, and optionally, their DNS names.</p>
<p>At the bottom of this section, you will find an option to set the &quot;Auto DNS&quot; flag on all interfaces with IP addresses. The purpose of this flag is to tell Netdot whether it should generate DNS names for each IP address based on the interface name and the device name.</p>
<p>The logic of this operation is handed off to a plugin module, which means that you can write your own plugin to generate DNS names based on your own naming scheme (see configuration file for more details). The included plugin generates names such as &quot;ge-0-1.router1.mydomain.com&quot;, assuming that the device name is router1 and that the interface is GigabitEthernet0/1. This is very useful for when you are using the traceroute utility.</p>
<p>Near the end of this section, you will find an option to set the &quot;Auto DNS&quot; flag on all interfaces with IP addresses. The purpose of this flag is to tell Netdot whether it should generate DNS names for each IP address based on the interface name and the device name.</p>
<p>The logic of this operation is handed off to a plugin module, which means that you can write your own plugin to generate DNS names based on your own naming scheme (see configuration file for more details). The included plugin generates names such as &quot;ge-0-1.router1.mydomain.com&quot;, assuming that the device name is router1 and that the interface is GigabitEthernet0/1. This is very useful when you are using the traceroute utility.</p>
<p>For this to work you need the following:</p>
<ul>
<li>The device has to have its &quot;Auto DNS&quot; flag set (Basics section of the device page).</li>
<li>Each interface with an IP address on the device has to have the &quot;Auto DNS flag on&quot;</li>
<li>The IP address must exist within an IP block which has been assigned a DNS zone (Management -&gt; Address Space).</li>
<li>The IP address must exist within an IP block which has been assigned a DNS zone (Management -&gt; Address Space). Alternatively, the option AUTO_DNS_ZONE specifies the name of the zone to use.</li>
<li>For PTR records to be generated as well, the IP block must have a reverse zone (in-addr.arpa or ip6.arpa) associated with it.</li>
</ul>
<p>You can generate these records in two ways:</p>
<ol style="list-style-type: lower-alpha">
<li>By clicking on the button that reads &quot;Re-generate DNS names for all IPs&quot; at the bottom of the IP info tab of the device page. This will act on only that device</li>
<li>By using the updatedevices.pl executable as follows:</li>
</ol>
<pre class="sourceCode bash"><code class="sourceCode bash">~# bin/updatedevices.pl -DN</code></pre>
<p>The command above will instruct Netdot to generate DNS records for all IPs belong to device interfaces, as long as the criteria explained earlier are met.</p>
<h4 id="bgp-peers-tab-if-the-device-is-a-router-with-bgp-peering-sessions"><a href="#TOC"><span class="header-section-number">4.1.3.5</span> BGP Peers Tab: If the device is a router with BGP peering sessions,</a></h4>
<p>and those are seen via SNMP, Netdot will show that information in this tab. Information includes the remote IP address, the BGP ID and the AS. The BGPPeering record also includes fields to document things such as the maximum number of allowed IPv4 and IPv6 prefixes, whether the peering should be monitored (e.g. with Nagios), etc.</p>
<p>For each AS discovered, Netdot tries to look up its information using WHOIS. If the information is found, an entity record is created with the AS number, AS name, etc. You can expand this record to include contact information, comments, etc.</p>
View
BIN +1.26 KB (100%) doc/manual/netdot-manual.pdf
Binary file not shown.
@@ -594,7 +594,7 @@ on how they are contained within each other.
device, together with the subnets they belong in, the device interface
where they were found, and optionally, their DNS names.
At the bottom of this section, you will find an option to set the "Auto
Near the end of this section, you will find an option to set the "Auto
DNS" flag on all interfaces with IP addresses. The purpose of this flag
is to tell Netdot whether it should generate DNS names for each IP
address based on the interface name and the device name.
@@ -604,7 +604,7 @@ that you can write your own plugin to generate DNS names based on your own
naming scheme (see configuration file for more details). The included
plugin generates names such as "ge-0-1.router1.mydomain.com", assuming
that the device name is router1 and that the interface is GigabitEthernet0/1.
This is very useful for when you are using the traceroute utility.
This is very useful when you are using the traceroute utility.
For this to work you need the following:
@@ -613,10 +613,26 @@ For this to work you need the following:
* Each interface with an IP address on the device has to have the "Auto
DNS flag on"
* The IP address must exist within an IP block which has been assigned
a DNS zone (Management -> Address Space).
a DNS zone (Management -> Address Space). Alternatively, the
option AUTO_DNS_ZONE specifies the name of the zone to use.
* For PTR records to be generated as well, the IP block must have a
reverse zone (in-addr.arpa or ip6.arpa) associated with it.
You can generate these records in two ways:
a) By clicking on the button that reads "Re-generate DNS names for all IPs"
at the bottom of the IP info tab of the device page. This will act
on only that device
b) By using the updatedevices.pl executable as follows:
~~~~ {.bash}
~# bin/updatedevices.pl -DN
~~~~
The command above will instruct Netdot to generate DNS records for all
IPs belong to device interfaces, as long as the criteria explained earlier
are met.
#### BGP Peers Tab: If the device is a router with BGP peering sessions,
and those are seen via SNMP, Netdot will show that information in this
tab. Information includes the remote IP address, the BGP ID and the AS.
View
@@ -3836,8 +3836,33 @@ sub set_interfaces_auto_dns {
return 1;
}
###############################################################
=head2 _do_auto_dns - Generate DNS records for all interface IPs
###########################################################################
=head2 do_auto_dns_all - Generate DNS for all interface IPs on all devices
Arguments
None
Returns
Nothing
Example:
Device->do_auto_dns_all();
=cut
sub do_auto_dns_all {
my ($class, %argv) = @_;
$class->isa_class_method('do_auto_dns_all');
unless ( $class->config->get('UPDATE_DEVICE_IP_NAMES') ){
$logger->warn("UPDATE_DEVICE_IP_NAMES config option is disabled");
return;
}
foreach my $dev ( Device->retrieve_all ){
$dev->do_auto_dns();
}
}
################################################################################
=head2 do_auto_dns - Generate DNS records for all interface IPs of given device
Arguments
None
@@ -3849,13 +3874,23 @@ sub set_interfaces_auto_dns {
sub do_auto_dns {
my ($self, %argv) = @_;
$self->isa_object_method('do_auto_dns');
my $host = $self->fqdn;
# Get addresses that the main Device name resolves to
unless ( $self->auto_dns ){
$logger->debug(sub{sprintf("Auto DNS is disabled for device %s.".
" Skipping.", $host)});
return;
}
$logger->debug(sub{sprintf("Generating DNS records for IP interfaces in %s",
$host)});
# Get addresses that the main device name resolves to
my @hostnameips;
if ( @hostnameips = Netdot->dns->resolve_name($host) ){
$logger->debug(sub{ sprintf("Device::_update_interfaces: %s resolves to: %s",
$logger->debug(sub{ sprintf("Device::do_auto_dns: %s resolves to: %s",
$host, (join ", ", @hostnameips))});
}
@@ -3883,9 +3918,6 @@ sub do_auto_dns {
}
#####################################################################
#
# Private methods
@@ -6366,12 +6398,6 @@ sub _update_interfaces {
$obj->update({interface=>undef});
}
##############################################################
# Update A records for each IP address
if ( $self->config->get('UPDATE_DEVICE_IP_NAMES') && $self->auto_dns ){
$self->do_auto_dns();
}
1;
}
View
@@ -15,6 +15,9 @@ PREFIX=/usr/local/netdot
# Twice a day, rediscover devices and topology (in addition to above)
#0 12,17 * * * root $PREFIX/bin/updatedevices.pl -DIFAT
# Once a day, generate DNS records for interface IPs
30 7 * * * root $PREFIX/bin/updatedevices.pl -DN
# Update whole-network topology graphs
45 0 * * * root $PREFIX/bin/build_topo_graph.pl -f $PREFIX/htdocs/img/graphs/whole_network_no_vlans.png

0 comments on commit 63faf03

Please sign in to comment.