Package: mactopeer
mac-to-peerAutomatically fetch MAC/IP address tables (ARP and IPv6 neighbors) from devices and build MAC address to BGP peer ASN mappings.Particularly focused on buildingpmacct’sbgp_peer_src_as_mapfile.router1#show ip arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.0.2.1             101   0000.5E00.5300  ARPA   TenGigabitEthernet0/0/0

router1#show bgp ipv4 unicast neighbors 192.0.2.1
BGP neighbor is 192.0.2.1, remote AS 65536, internal link
...Expected:00:00:5E:00:53:00->AS65536JSON output format:$ mactopeer -u pierky -p - --hostname router1.example.com
Enter password:
{
  "router1.example.com": {
    "00:00:5E:00:53:00": {
      "ifaces": [
        "TenGigabitEthernet0/0/0"
      ],
      "ip_addrs": [
        "192.0.2.1"
      ],
      "peer_asns": {
        "65536": {
          "description": "my-peer",
          "ip_addrs": [
            "192.0.2.1"
          ]
        }
      }
    }
  }
}pmacct output format:$ mactopeer -u pierky -p - --devices device.json -f pmacct
Enter password:
id=65536      ip=203.0.113.1          src_mac=00:00:5E:00:53:00Installation and dependenciesInstall the program using pip:pip install mactopeerThe script uses theNAPALMlibrary to connect to network devices and to fetch data from them: you must install the whole library…pip install napalm… or at least the subset of network drivers needed to connect to the devices you actually need:pip install napalm-ios napalm-junosFor more details, the full list of network drivers and their dependencies please see the officialNAPALM documentation.Usage and featuresThe--helpshows all the options this program offers. Seeits output in USAGE.rst.A list of devices can be provided using an input JSON file: for details about its schema please runmactopeer--help-devices. Seeits output in USAGE.rst.Filters can be set to skip entries on the basis of their MAC address, IP address or resulting peer ASN. Useful to exclude iBGP sessions or to handle exceptions.Multithreading is also supported to fetch information from more than one device concurrently.The list of supported devices can be found in theSupported Devicessection of the NAPALM’s documentation website. All those implementing theget_arp_tableandget_bgp_neighborsmethods should work: at time of writing they are EOS, IOS, IOSX-R, JunOS, NXOS, VyOS.Integration with PeeringDBThe--use-peeringdbargument can be used to fetch missing peers’ ASNs from PeeringDB, for example in case of multi-lateral peering (such as route servers at IXPs). In this case, routers have not a straight mapping between IP address and BGP neighborship, so the IP address is used to look into PeeringDB records to find the network which is using it.CaveatsCurrently VRF support is missing, mostly because it’s not included in NAPALM yet.IPv6 neighbors table can only be fetched if a not yet released version of NAPALM is used, that is one which includesthis pull request. To avoid theWARNING - Skipping IPv6 neighbors tablemessage please use the--arp-onlyargument.AuthorPier Carlo Chiodi -https://pierky.com/Blog:https://blog.pierky.com/Twitter:@pierkyChange logv0.3.0Improvement: madeuse_peeringdban attribute of devices’ declaration.Improvement: some fixes.Also, the tool can be used as a library now.v0.2.0New: IP based filters extended to the use of prefixes too.New:--use-peeringdbargument to fetch missing peers’ ASNs from PeeringDB (e.g. in case of multi-lateral peering at IXPs).v0.1.0First release.