{"id":15616777,"url":"https://github.com/thepacketgeek/bgpd-rs","last_synced_at":"2025-04-28T16:16:51.040Z","repository":{"id":46577643,"uuid":"191795241","full_name":"thepacketgeek/bgpd-rs","owner":"thepacketgeek","description":"BGP Peering Tool in Rust","archived":false,"fork":false,"pushed_at":"2023-02-04T02:16:10.000Z","size":432,"stargazers_count":19,"open_issues_count":3,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-28T16:16:43.858Z","etag":null,"topics":["bgp","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thepacketgeek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-13T16:10:59.000Z","updated_at":"2025-03-10T09:32:56.000Z","dependencies_parsed_at":"2023-02-18T13:00:36.995Z","dependency_job_id":null,"html_url":"https://github.com/thepacketgeek/bgpd-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepacketgeek%2Fbgpd-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepacketgeek%2Fbgpd-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepacketgeek%2Fbgpd-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepacketgeek%2Fbgpd-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thepacketgeek","download_url":"https://codeload.github.com/thepacketgeek/bgpd-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342725,"owners_count":21574245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bgp","rust-lang"],"created_at":"2024-10-03T07:21:59.808Z","updated_at":"2025-04-28T16:16:51.017Z","avatar_url":"https://github.com/thepacketgeek.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BGPd-rs\n\nBGP service daemon built in Rust\n[![Actions Status](https://github.com/thepacketgeek/bgpd-rs/workflows/cargo/badge.svg)](https://github.com/thepacketgeek/bgpd-rs/actions)\n\n![PCAP](examples/pcap.png)\n\n\n## Features\n- [x] Listen for Incoming BGP sessions\n- Specified peers can be an IP address or Network+Mask\n- [x] Initiate outbound TCP connection to idle peers\n- Will attempt connection based on configured poll interval\n- [x] Negotiate OPEN Capabilities\n- [x] Receive and respond to Keepalives (on hold time based interval)\n- [x] Process UPDATE messages, store in RIB\n- [x] Config reloading for Peer status (enable, passive, etc.)\n  - [ ] Update static route advertisements mid-session\n- [x] CLI interface for viewing peer status, routes, etc.\n- [x] Advertise routes to peers (specified from API and/or Config)\n- [x] API/CLI interface for interacting with BGPd\n- [x] Flowspec Support\n- [ ] Route Refresh\n- [ ] Neighbor MD5 Authentication\n- [ ] Route Policy for filtering of learned \u0026 advertised routes\n\n# Peer config\nPeers and their config are defined in `TOML` format; see an example [here](examples/config.toml).\n\nDetails of config values:\n```toml\nrouter_id = \"1.1.1.1\"         # Default Router ID for the service\ndefault_as = 65000            # Used as the local-as if `local_as` is not defined for a peer\nbgp_socket = \"127.0.0.1:1179\" # BGP address \u0026 port\napi_socket = \"0.0.0.0:8080\"   # API address \u0026 port [Listen on all interfaces (IPv4 \u0026 IPv6)]\n\n[[peers]]\nremote_ip = \"127.0.0.2\"       # This can also be an IPv6 address, see next peer\n# remote_ip = \"10.0.0.0/24\"   # Network+Mask will accept inbound connections from any source in the subnet\nremote_as = 65000\npassive = true                # If passive, bgpd won't attempt outbound connections\nrouter_id = \"127.0.0.1\"       # Can override local Router ID for this peer\nhold_timer = 90               # Set the hold timer for the peer, defaults to 180 seconds\nfamilies = [                  # Define the families this session should support\n  \"ipv4 unicast\",\n  \"ipv6 unicast\",\n]\n[[peers.static_routes]]       # Add static routes (advertised at session start)\n  prefix = \"9.9.9.0/24\"\n  next_hop = \"127.0.0.1\"\n[[peers.static_routes]]\n  prefix = \"3001:100::/64\"\n  next_hop = \"3001:1::1\"\n[[peers.static_flows]]        # Add static Flowspec rules too!\nafi = 2\naction = \"traffic-rate 24000\"\nmatches= [\n    \"source 3001:100::/56\",\n    \"destination-port \u003e8000 \u003c=8080\",\n    \"packet-length \u003e100\",\n]\nas_path = [\"65000\", \"500\"]\ncommunities = [\"101\", \"202\", \"65000:99\"]\n\n\n[[peers]]\nremote_ip = \"::2\"\nenabled = false               # Peer is essentially de-configured\nremote_as = 100\nlocal_as = 200\nfamilies = [\n  \"ipv6 unicast\",\n]\n```\n\nYou can send the BGPd process a `SIGHUP` [E.g. `pkill -HUP bgpd$`] to reload and update peer configs. The following items can be updated:\n\n## Peers\n- Added \u0026 removed\n- Enabled/disabled\n- Active/passive polling for idle peers\n- *Hold Timer\n- *Supported Families\n\n \u003e * When not in an active session only, since these are negotiated in the OPEN\n\n\n# View BGPd Information\nBGPd offers an JSON RCP API that can be queried to view operational info like neighbors and routes:\n\nNeighbor uptime \u0026 prefixes received\n```sh\n$ curl localhost:8080 -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\":\"2.0\",\"method\":\"show_peers\",\"params\":null,\"id\":0}' | jq '.result[] | {peer: .peer, uptime: .uptime, prefixes_received: .prefixes_received}'\n{\n  \"peer\": \"127.0.0.2\",\n  \"uptime\": \"00:31:13\",\n  \"prefixes_received\": 4\n}\n{\n  \"peer\": \"127.0.0.3\",\n  \"uptime\": null,\n  \"prefixes_received\": null\n}\n{\n  \"peer\": \"172.16.20.2\",\n  \"uptime\": \"00:31:20\",\n  \"prefixes_received\": 2\n}\n```\n\nLearned routes (with attributes)\n```sh\n$ curl localhost:8080 -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\":\"2.0\",\"method\":\"show_routes_learned\",\"params\": {\"from_peer\": \"172.16.20.2\"},\"id\":0}' | jq '.result[]'\n{\n  \"afi\": \"IPv6\",\n  \"age\": \"00:00:38\",\n  \"as_path\": \"\",\n  \"communities\": [],\n  \"local_pref\": 100,\n  \"multi_exit_disc\": null,\n  \"next_hop\": \"::ffff:172.16.20.2\",\n  \"origin\": \"IGP\",\n  \"prefix\": \"3001:172:16:20::/64\",\n  \"received_at\": 1572898659,\n  \"safi\": \"Unicast\",\n  \"source\": \"172.16.20.2\"\n}\n{\n  \"afi\": \"IPv4\",\n  \"age\": \"00:00:38\",\n  \"as_path\": \"\",\n  \"communities\": [],\n  \"local_pref\": 100,\n  \"multi_exit_disc\": null,\n  \"next_hop\": \"172.16.20.2\",\n  \"origin\": \"IGP\",\n  \"prefix\": \"172.16.20.0/24\",\n  \"received_at\": 1572898659,\n  \"safi\": \"Unicast\",\n  \"source\": \"172.16.20.2\"\n}\n```\n\nThe `bgpd` [CLI](src/cli/mod.rs) can also be used to view peer \u0026 route information via the BGPd API (and announce routes too!)\n\n# Development\nI'm currently using [ExaBGP](https://github.com/Exa-Networks/exabgp) (Python) and [GoBGP](https://github.com/osrg/gobgp) (Go) to act as my BGP peers for testing.\n- Here's an [intro article](https://thepacketgeek.com/influence-routing-decisions-with-python-and-exabgp/) about installing \u0026 getting started with ExaBGP.\n\n## ExaBGP setup\nWith ExaBGP installed, you can use a config from the `examples/exabgp` dir:\n\n**conf_127.0.0.2.ini**\n```ini\nneighbor 127.0.0.1 {\n    router-id 2.2.2.2;\n    local-address 127.0.0.2;          # Our local update-source\n    local-as 65000;                    # Our local AS\n    peer-as 65000;                    # Peer's AS\n\n    announce {\n        ipv4 {\n            unicast 2.100.0.0/24 next-hop self med 500 extended-community [ target:65000:1.1.1.1 ];\n            unicast 2.200.0.0/24 next-hop self as-path [ 100 200 ];\n            unicast 2.10.0.0/24 next-hop self med 10 community [404 65000:10];\n        }\n    }\n}\n```\n\nRunning the exabgp service with the command:\n\n```sh\n$ env exabgp.tcp.port=1179 exabgp.tcp.bind=\"127.0.0.2\" exabgp ./conf_127.0.0.2.ini --once\n```\n\u003e *--once only attempts a single connection, auto-quits when session ends*\n\n## Gobgp\nWith GoBGP installed, you can use a config from the `examples/gobgp` dir:\n\n**gobgpd.toml**\n```toml\n[global.config]\n  as = 65000\n  router-id = \"4.4.4.4\"\n  port = 1179\n  local-address-list = [\"127.0.0.4\"]\n\n[[neighbors]]\n  [neighbors.config]\n    neighbor-address = \"127.0.0.1\"\n    peer-as = 65000\n  [neighbors.transport.config]\n    passive-mode = false\n    local-address = \"127.0.0.4\"\n    remote-port = 1179\n  [neighbors.timers.config]\n    connect-retry = 5\n    hold-time = 30\n    keepalive-interval = 10\n```\n\nRunning the gobgpd service with the command:\n\n```sh\n$ gobgpd -f ./examples/gobgp/gobgpd.toml\n```\n\n## BGPd Setup\nStart the bgpd-rs daemon running `bgpd` with a provided config as follows:\n\n```sh\n$ cargo run -- run ./examples/config.toml -vv\n```\n\nYou may notice that I'm using TCP port 1179 in the example config for testing, if you want/need to use TCP 179 for testing with a peer that can't change the port (*cough*Cisco*cough*), you need to run bgpd with sudo permissions:\n\n```sh\n$ cargo build --release\n$ sudo ./targets/release/bgpd run ./examples/config.toml -vv\n```\n\n# Thanks to\n- [bgp-rs](https://github.com/DevQps/bgp-rs) for the BGP Message Parsing\n- [tokio](https://tokio.rs/) for the Runtime\n- [ParityTech](https://github.com/paritytech/jsonrpsee) for the JSON RPC API","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthepacketgeek%2Fbgpd-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthepacketgeek%2Fbgpd-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthepacketgeek%2Fbgpd-rs/lists"}