mrt2bgp streams routes from an MRT RIB dump into a live BGP session. It is intended for lab, replay, route-server testing, and controlled internal environments.
Do not point this at production routers unless you understand the route volume, next-hop rewriting, AS_PATH behavior, and session policy on the receiver.
- Reads MRT RIB files through
bgpkit-parser, including compressed inputs supported by that library. - Lists peers found in the MRT file with IPv4 and IPv6 route counts.
- Streams routes for one selected MRT peer over active, passive, or dual BGP TCP setup.
- Preserializes BGP UPDATE messages for high-throughput replay.
- Supports IPv4 and IPv6 unicast, 4-byte ASNs, MED, local-pref, standard communities, and large communities.
- Can rewrite IPv4 and IPv6 next hops.
cargo build --releaseList peers available in an MRT file:
target/release/mrt2bgp --mrt-path data.rib.gz --listStream routes from one MRT peer to an active BGP peer:
target/release/mrt2bgp \
--mrt-path data.rib.gz \
--peer-ip 203.0.113.10 \
--local-as 65001 \
--peer-as 65000 \
--mode active \
--peer-bgp-ip 127.0.0.1 \
--peer-port 1179 \
--next-hop-ipv4 192.0.2.1 \
--next-hop-ipv6 2001:db8::1Limit route count while testing:
target/release/mrt2bgp \
--mrt-path data.rib.gz \
--peer-ip 203.0.113.10 \
--peer-as 65000 \
--peer-bgp-ip 127.0.0.1 \
--max-routes 1000The included run.sh is a configurable example wrapper using environment variables:
MRT_PEER_IP=203.0.113.10 PEER_AS=65000 PEER_BGP_IP=127.0.0.1 ./run.shRun the standard checks before publishing changes:
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test- The peer must advertise 4-byte ASN support because UPDATE AS_PATH attributes are serialized with 4-byte ASNs.
- IPv6 routes are streamed only when the peer advertises IPv6 unicast support.
- BGP UPDATE messages are chunked and rejected if a single route plus its attributes cannot fit inside the 4096-byte BGP message limit.
MIT