Menu

#26 Add Ability to Ignore Specified Networks During Discover

None
moved-to-github
nobody
None
2015-01-24
2014-11-12
Don Greer
No

I needed to ignore a specific network during discovery so that one of my devices wouldn't use that IP address for it's management interface. I also don't want Netdisco to dig into that network at some point in the future.

I hacked this patch and it appears to work.

=============CUT===============
diff -r -U3 OLD/perl5/lib/perl5/App/Netdisco/Core/Discover.pm perl5/lib/perl5/App/Netdisco/Core/Discover.pm
--- OLD/perl5/lib/perl5/App/Netdisco/Core/Discover.pm 2014-09-12 08:06:21.000000000 -0500
+++ perl5/lib/perl5/App/Netdisco/Core/Discover.pm 2014-11-12 11:01:02.559006083 -0600
@@ -3,7 +3,8 @@
use Dancer qw/:syntax :script/;
use Dancer::Plugin::DBIC 'schema';

-use App::Netdisco::Util::Device qw/get_device is_discoverable/;
+#use App::Netdisco::Util::Device qw/get_device is_discoverable/;
+use App::Netdisco::Util::Device ':all';
use App::Netdisco::Util::DNS ':all';
use App::Netdisco::JobQueue qw/jq_queued jq_insert/;
use NetAddr::IP::Lite ':lower';
@@ -126,6 +127,7 @@

   next if $addr eq '0.0.0.0';
   next if $ip->within($localnet);
  • next if check_device_only($addr,'ignore_nets');
    next if setting('ignore_private_nets') and $ip->is_rfc1918;

    my $iid = $ip_index->{$addr};
    diff -r -U3 OLD/perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml
    --- OLD/perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml 2014-09-22 13:58:45.000000000 -0500
    +++ perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml 2014-11-12 10:49:15.619491100 -0600
    @@ -150,6 +150,8 @@
    - 'Virtual-Access\d+'
    - '(E|T)\d \d\/\d\/\d'
    ignore_private_nets: false
    +ignore_nets:
    + - 0.0.0.0/0
    reverse_sysname: false
    vlanctl: true
    portctl_nameonly: false

=============CUT===============

In the configuration, you MUST have at least one network defined, or the "check_device_only" will return true. The solution is to define the network as "0.0.0.0/0" because that is already being ignored to lines above, making it the safe choice. By adding "ignore_nets:" to the environments/deployment.yml with a list of networks to be ignored, these IPs should be ignored for discovery, meaning that no device will receive one of those IPs as it's management IP.

At least, that's what I THINK is happening (it worked for me :).

There is likely some earth-shattering thing that I've missed here, so please review what I did and let me know if I flubbed it.

Discussion

  • Oliver Gorwits

    Oliver Gorwits - 2014-11-13

    I'm a bit skeptical about this... it's filtering entries in the device_ip table and not really changing what SNMP::Info::root_ip returns. Surely we still want to see all device IPs? I'd prefer a smarter way to steer root_ip().

     
    • Don Greer

      Don Greer - 2014-11-14

      Fair enough. It worked for me :).
      On Nov 13, 2014 5:47 PM, "Oliver Gorwits" olly_g@users.sf.net wrote:

      I'm a bit skeptical about this... it's filtering entries in the device_ip
      table and not really changing what SNMP::Info::root_ip returns. Surely we
      still want to see all device IPs? I'd prefer a smarter way to steer
      root_ip().


      Status: new
      Created: Wed Nov 12, 2014 05:21 PM UTC by Don Greer
      Last Updated: Wed Nov 12, 2014 05:21 PM UTC
      Owner: nobody

      I needed to ignore a specific network during discovery so that one of my
      devices wouldn't use that IP address for it's management interface. I also
      don't want Netdisco to dig into that network at some point in the future.

      I hacked this patch and it appears to work.

      =============CUT===============
      diff -r -U3 OLD/perl5/lib/perl5/App/Netdisco/Core/Discover.pm
      perl5/lib/perl5/App/Netdisco/Core/Discover.pm
      --- OLD/perl5/lib/perl5/App/Netdisco/Core/Discover.pm 2014-09-12
      08:06:21.000000000 -0500
      +++ perl5/lib/perl5/App/Netdisco/Core/Discover.pm 2014-11-12
      11:01:02.559006083 -0600
      @@ -3,7 +3,8 @@
      use Dancer qw/:syntax :script/;
      use Dancer::Plugin::DBIC 'schema';

      -use App::Netdisco::Util::Device qw/get_device is_discoverable/;
      +#use App::Netdisco::Util::Device qw/get_device is_discoverable/;
      +use App::Netdisco::Util::Device ':all';
      use App::Netdisco::Util::DNS ':all';
      use App::Netdisco::JobQueue qw/jq_queued jq_insert/;
      use NetAddr::IP::Lite ':lower';
      @@ -126,6 +127,7 @@

      next if $addr eq '0.0.0.0';
      next if $ip->within($localnet);

      -

      next if check_device_only($addr,'ignore_nets');
      next if setting('ignore_private_nets') and $ip->is_rfc1918;

      my $iid = $ip_index->{$addr};
      diff -r -U3
      OLD/perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml
      perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml
      --- OLD/perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml
      2014-09-22 13:58:45.000000000 -0500
      +++ perl5/lib/perl5/auto/share/dist/App-Netdisco/config.yml 2014-11-12
      10:49:15.619491100 -0600
      @@ -150,6 +150,8 @@
      - 'Virtual-Access\d+'
      - '(E|T)\d \d\/\d\/\d'
      ignore_private_nets: false
      +ignore_nets:
      + - 0.0.0.0/0
      reverse_sysname: false
      vlanctl: true
      portctl_nameonly: false

      =============CUT===============

      In the configuration, you MUST have at least one network defined, or the
      "check_device_only" will return true. The solution is to define the network
      as "0.0.0.0/0" because that is already being ignored to lines above,
      making it the safe choice. By adding "ignore_nets:" to the
      environments/deployment.yml with a list of networks to be ignored, these
      IPs should be ignored for discovery, meaning that no device will receive
      one of those IPs as it's management IP.

      At least, that's what I THINK is happening (it worked for me :).

      There is likely some earth-shattering thing that I've missed here, so
      please review what I did and let me know if I flubbed it.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/netdisco/netdisco2/167/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Oliver Gorwits

    Oliver Gorwits - 2015-01-24

    Ticket moved from /p/netdisco/netdisco2/167/

     
  • Oliver Gorwits

    Oliver Gorwits - 2017-02-02
    • Status: new --> moved-to-github