Giter VIP home page Giter VIP logo

giraphe's Introduction

Build Status

Discover and visualize layer-2 and layer-3 network topology.

See the API documentation.

Installation

To use giraphe as an escript:

  1. Install Erlang/OTP

  2. Install GraphViz

  3. Install nmap

  4. Clone the giraphe repository

git clone https://gitlab.com/jonnystorm/giraphe.git
  1. Add nmap command to sudoers
Cmnd_Alias NMAP = /usr/bin/nmap -n -oG - -sU -p *

%wheel ALL=(root) NOPASSWD: NMAP

Defaults!NMAP !requiretty
  1. Run from within the giraphe directory
$ cd giraphe
$ ./giraphe
Usage: giraphe [-qv] -c <credentials_path> -o <output_file>
               [-r <routers_file>] [-h <hosts_file>] [-i <ignore_file>]
               [-2 <gateway_ip> [<subnet_cidr>]] [-3 [<router_ip> ...]]

  -q: quiet
  -v: verbose ('-vv' is more verbose)

  -o: output file (must end in .png or .svg)
  -r: export routers to file
  -h: discover hosts and export to file (slow!)
  -i: do not discover hosts for CIDRs listed in file

  -c: Specify file containing credentials
    <credentials_path>: path to file containing credentials

    Valid lines in this file will look like one of the following:
      snmp v2c 'r34D0n1Y!'
      snmp v3 noAuthNoPriv 'admin'
      snmp v3 authNoPriv 'admin' md5 '$3cR3t!'
      snmp v3 authPriv 'admin' sha '$3cR3t!' aes 'pR1v473!'

  -2: generate layer-2 topology
     <gateway_ip>: IP address of target subnet gateway
    <subnet_cidr>: Specifies switch subnet to graph

  -3: generate layer-3 topology
    <router_ip>: IP address of seed target router; with no seed specified,
                 this machines's default gateway is used

To use giraphe as a library:

  1. Add giraphe to your list of dependencies in mix.exs:
def deps do
  [ {:giraphe, git: "https://gitlab.com/jonnystorm/giraphe.git"},
  ]
end
  1. Ensure giraphe is started before your application:
def application do
  [ applications: [
      :giraphe,
    ],
  ]
end

Example

L3

$ ./giraphe -c ~/creds -o ~/new-l3-diagram.png -3 198.51.100.1
Seeding targets 198.51.100.1/32
New routers discovered: R1
Next targets: 192.0.2.2/31, 198.51.100.2/32, 198.51.100.3/32

12:50:25.494 [warn]  Unable to query target '198.51.100.3/32' for object 'routes': :etimedout

12:50:31.524 [warn]  Unable to query target '198.51.100.3/32' for object 'addresses': :etimedout

12:50:37.553 [warn]  Unable to query target '198.51.100.3/32' for object 'sysname': :etimedout
New routers discovered: 192.0.2.2, R2, 198.51.100.3
Next targets: 198.51.100.4/32, 198.51.100.5/32
New routers discovered: R4, R5
Next targets: 
Done!

L2

$ ./giraphe -c ~/creds -o ~/new-l2-diagram.svg -2 192.0.2.1
Found subnet '192.0.2.0/24' for gateway '192.0.2.1/32'.
Inducing ARP entries on '192.0.2.0/24'...
Retrieving ARP entries for '192.0.2.0/24'...
Found the following hosts: 192.0.2.1, 192.0.2.2, 192.0.2.3, 192.0.2.4, 192.0.2.5, 192.0.2.6, 192.0.2.7, 192.0.2.8

12:36:57.896 [warn]  Unable to query target '192.0.2.5/32' for object 'fdb': :etimedout

12:37:04.112 [warn]  Unable to query target '192.0.2.7/32' for object 'sysname': :etimedout

12:37:11.680 [warn]  Unable to query target '192.0.2.8/32' for object 'sysname': :snmperr_unknown_user_name
Done!

giraphe's People

Contributors

jonnystorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gmcintire

giraphe's Issues

Problem: Crashes when "?" occurs in SNMP table output

  • Code assumes "?" will never appear as destination or nexthop in routes.
  • Missing destination/nexthop appears when route churn is present.

Crash Output

** (Protocol.UndefinedError) protocol NetAddr.Representation not implemented for {:error, :einval}. This protocol is implemented for: NetAddr.Generic, NetAddr.IPv4, NetAddr.IPv6, NetAddr.MAC_48
    (netaddr_ex) deps/netaddr_ex/lib/netaddr.ex:842: NetAddr.Representation.impl_for!/1
    (netaddr_ex) deps/netaddr_ex/lib/netaddr.ex:844: NetAddr.Representation.address/2
    (giraphe) lib/giraphe/discover/l3.ex:22: anonymous fn/2 in Giraphe.Discover.L3.any_similar_address?/2
    (elixir) lib/enum.ex:2786: Enum.any_list/2
    (giraphe) lib/giraphe/discover/l3.ex:127: anonymous fn/3 in Giraphe.Discover.L3._discover/2
    (elixir) lib/enum.ex:2857: Enum.filter_list/2
    (giraphe) lib/giraphe/discover/l3.ex:126: Giraphe.Discover.L3._discover/2
    (giraphe) lib/giraphe/discover/l3.ex:167: Giraphe.Discover.L3.discover/1

SNMP Output

[%{age: "14", dest: "10.100.11.0", ifindex: "0",
   index: "[10.100.11.0][255.255.255.252][0][10.100.1.2]", info: "?",
   mask: "255.255.255.252", metric1: "?", metric2: "?", metric3: "?",
   metric4: "?", metric5: "?", nexthop: "10.100.1.2", nexthopas: "?",
   proto: "14", status: "?", tos: "0", type: "4"},
 %{age: "?", dest: "?", ifindex: "?",
   index: "[10.100.11.0][255.255.255.252][0][10.1.1.2]",
   info: "SNMPv2-SMI::zeroDotZero", mask: "?", metric1: "0", metric2: "?",
   metric3: "?", metric4: "?", metric5: "?", nexthop: "?", nexthopas: "0",
   proto: "?", status: "?", tos: "?", type: "?"}]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.