Coder Social home page Coder Social logo

team-tritan / frr-prefix-list-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 34.03 MB

Generate BGP prefix lists filters automatically for FRR.

Home Page: https://as393577.net

TypeScript 100.00%
frr bgp irr prefix-lists filter-generator filters

frr-prefix-list-generator's Introduction

FRR Prefix List Generator

Made with love by AS393577 <3

Overview

This project will generate BGP prefix lists, it pulls ASN from the output on the FRR bgp summary command then fetches their AS-SETs. Following this, it builds filters based on as-sets and adds them to the running config.

It essentially does the following:

  • Gets all bgp neighbors dynamically
  • Polls peeringdb api for as-set listed
    • If an ASN is on an ignore list (like IXP asns, transit, etc-- things that don't need specific or automated filters) it will ignore it.
    • If there is no as-set listed in peeringdb, it defaults to the ASN while generating filters.
  • Generates prefix lists from the as-set/asn via bgpq4, and pipes them into FRR's running config.
    • The naming format for prefix lists are as follow: AS00000-In-v4 or AS00000-In-v6. Your route maps for the neighbors will need to reflect this.

You can run this on a cronjob, daily, weekly, whatever. It saves it into the running config so you can default back to your orignal frr config by reloading it at any time.

Dependencies

You'll need to install the following deps on the linux box:

  • bgpq4
  • bun runtime
    • (or compile to js conventionally and use node)

Install the deps within the codebase:

  • bun install

Starting The Script

There are different ways you can run this, and I'll give a base level introduction to a few of them.

Dev:

  • With Bun installed, run bun install to get packages.
  • Run bun dev to start the script.

Compiling to Binary:

You can also just use bun to compile to a binary, we've included a binary in the repo named Generate. This is built for our use case, and you'll need to recompile the binary using bun when you make changes.

  • bun build ./src/main.ts --compile --outfile {binary name}
  • Setup a cronjob to run the binary, or setup a system service, etc. Run the binary however you want lol.

Bun Runtime on Cronjob:

  • Run which bun to get the executable of bun.
  • Create a cronjob as root: crontab -u root -E
  • Start using bun in the crontab, this example is every day at 00:00:
    • 0 0 * * * /root/.nvm/versions/node/v20.14.0/bin/bun run /root/folder/src/main.ts

Alternatively, compile the ts to js and use node as the runtime.

Contributing

Any contributions are welcome, feel free to submit a pull request. This was made in literally under a few hours while I was at work lol.

frr-prefix-list-generator's People

Contributors

dylanjamesdev avatar

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.