How do you get a prefix into BGP, and why might a network statement not work?
Show the answer
Say this first
Three ways: a network statement, redistribution, or aggregate-address. Unlike OSPF, the BGP network
command does not enable anything on interfaces. It means "advertise this prefix if an exact match, same prefix
and same mask, is in the routing table". It usually fails because of a mask mismatch or no matching route.
The fix is the right mask, or a static route to Null0 that anchors the prefix.
Go deeper
ip route 203.0.113.0 255.255.255.0 Null0
!
router bgp 64500
network 203.0.113.0 mask 255.255.255.0R1# show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 203.0.113.0 0.0.0.0 0 32768 iWhy the Null0 route
The /24 stays in the table as long as the router is up, so the announcement does not flap when a LAN subnet goes down. Inside, more specific routes for the real subnets win by longest match. Traffic for unused parts of the block hits Null0 and is dropped instead of looping toward the default route.
Common mistakes
network 203.0.113.0withoutmaskassumes the classful mask. Fine for a /24 in class C space, wrong for10.20.0.0which IOS would read as /8.- The RIB has 203.0.113.0/25 and /25, but you asked for the /24. No exact match, no advertisement.
Redistribution
redistribute ospf 1 route-map OSPF-TO-BGP sets origin ? and copies the IGP metric into MED. Always use a
route map at the internet edge; never redistribute the full BGP table into an IGP.
They will ask next
Does the route behind a network statement have to be connected?
No. Any route in the routing table works: connected, static, OSPF. It has to match exactly.
Why prefer network statements at the internet edge?
They are explicit. You advertise only what you listed, with origin IGP. Redistribution can leak whatever the IGP happens to learn.
Traps
- Expecting
network 203.0.113.0 mask 255.255.255.0to summarise smaller routes. It needs the exact /24 in the RIB.