BGP vs OSPF for enterprise networks is a decision most network teams face sooner or later. Picture this: a branch link drops at 9 a.m. on a Monday, and half the office cannot reach the file server. When we sit down for design reviews, the question we hear most is simple. Should we run BGP or OSPF here? The honest answer is that these two protocols solve different problems. Choose the wrong one and you will feel it months later.
In our experience, OSPF suits most campus and regional WAN designs. BGP earns its place at the edge, where you peer with providers or need fine control over routing policy.
BGP vs OSPF for enterprise networks: the short answer first
OSPF is a link-state interior gateway protocol. Every router builds a complete map of its area and calculates shortest paths on its own. Inside a single routing domain it converges quickly. That is why it dominates the campus and mid-sized WAN designs we deploy most often.
BGP is a path-vector exterior gateway protocol defined in RFC 4271. It exchanges routes and their attributes between autonomous systems. It is built for policy rather than raw speed. When a client asks us to choose between two ISPs or to steer traffic across several administrative domains, BGP is the tool we reach for.
In practice, most mid-sized enterprises we work with run both. OSPF handles the inside, and BGP sits at the boundary facing the outside world. That hybrid is far more common than a pure BGP or pure OSPF network in a company of moderate size. If you are weighing enterprise network design options for a new site, start from that hybrid assumption. Move away from it only when the requirements clearly say so.
How the two protocols actually think
OSPF gives every router in an area the same database of links. Each router runs the SPF algorithm against that database to pick its best path. OSPFv2 is described in RFC 2328, and OSPFv3 for IPv6 in RFC 5340. Once the database is synchronised, the routers no longer need to discuss the topology in detail. They only exchange information about changes.
BGP works differently. It does not calculate paths from link costs. Routers announce prefixes together with attributes such as AS_PATH, LOCAL_PREF and MED. The router then decides based on those attributes and on the policy you configure. Once you internalise this, most BGP behaviour stops looking mysterious. Many of the surprises we debug come from someone expecting BGP to behave like a cost-based protocol.
The practical consequence is about scale. BGP handles a very large number of prefixes gracefully. OSPF scales with the number of links and routers inside an area. A badly sized area will hurt you long before the route table does. We have seen this bite teams who never looked at their area layout until SPF runs started taking seconds on modest hardware.
Where OSPF fits: campus and branch networks
A typical campus with a few dozen to a few hundred switches and routers is OSPF territory. The configuration stays readable. Convergence after a link failure is fast. Your operations team can troubleshoot it without deep BGP expertise, and that matters more than most architecture diagrams admit.
Design it as multi-area with area 0 as the backbone. Keep the number of LSAs inside each area reasonable. A huge flat area is the classic mistake that makes SPF runs expensive on modest hardware. One customer of ours ran a single area across forty access switches. They saw CPU spikes every time a port flapped. Splitting the network into three areas removed the problem almost overnight.
A basic Cisco IOS starting point looks like this:
router ospf 1
router-id 10.0.0.1
network 10.1.0.0 0.0.255.255 area 0
passive-interface default
no passive-interface GigabitEthernet0/1
Notice the passive-interface default line. Making interfaces passive by default and opting in only the uplinks you need keeps OSPF hellos off user-facing ports. That is both a security measure and a noise reduction. We treat it as a baseline for any campus we configure.
Where BGP earns its keep: WAN edges and data centers
BGP is the right answer when you connect to more than one ISP. It also fits when you want real control over which path traffic takes in and out. LOCAL_PREF lets you prefer one exit for outbound traffic. AS-path prepending nudges inbound traffic toward the link you prefer. It works only as a hint, though, and the rest of the internet may ignore it.
Modern leaf-spine data centers often run eBGP between layers. RFC 7938 describes exactly this approach. It keeps the design simple at scale because each device has a clear role in the policy. We have found it far easier to automate than a large OSPF fabric. Each switch gets its own private AS, and the policy lives in a handful of templates.
A minimal eBGP session toward a provider looks like this:
router bgp 65001
neighbor 203.0.113.1 remote-as 64500
network 198.51.100.0 mask 255.255.255.0
Do not expect BGP to be as forgiving as OSPF. A typo in a prefix or AS number can leak routes or blackhole traffic. We insist on a second reviewer for every BGP change. We recommend the same to any team running it in production.
Convergence and scale: the trade-offs you will live with
OSPF converges quickly inside a domain because each router recalculates locally once it receives the updated database. The cost is that more routers and more LSAs mean more CPU and memory pressure on every device. That pressure grows faster than most people expect.
BGP converges more slowly by default. Its timers and the way updates propagate make it deliberately cautious. If you need fast failover between providers, you will typically add BFD and tune the timers. Without that work, failover feels sluggish, and users notice it before any dashboard does.
Real convergence numbers depend heavily on your software release and hardware. Check vendor documentation before promising a figure in an SLA. We have watched identical configurations behave very differently across two code versions. For that reason we always test on the exact release going into production.
Choosing at a glance
- Scope: OSPF runs inside one autonomous system. BGP runs between autonomous systems.
- Policy: OSPF keeps its policy options deliberately limited, which makes it predictable internally. BGP offers very strong policy control but asks more of the people configuring it.
- Prefix scale: Moderate for OSPF, very large for BGP.
- Best fit: Campus and internal WAN favour OSPF. ISP peering, multi-homing and data center fabrics favour BGP.
Treat this as a starting point. Your own topology and policy requirements will shift the balance.
Running both without creating a loop
Redistribution between OSPF and BGP is where many outages begin. Routes can bounce back and forth between the two protocols if nothing stops them. Use route-maps and prefix-lists that state exactly what may cross the boundary. Treat anything not explicitly permitted as forbidden.
Tagging is the safety net. Mark routes that came from redistribution, then block them from being redistributed again. It feels tedious on day one. It saves you badly on the day something changes upstream and a route you never intended starts circulating. For teams that want to tighten their routing and security practices across a wider estate, the same discipline of explicit allow-lists applies beyond routing alone.
Verify the routing table after every change and write down the policy you applied. Whoever is on call at 2 a.m. will thank you for it, and so will you.
Mistakes we see again and again
The first is running iBGP without a full mesh or route reflectors. Internal BGP does not re-advertise routes learned from one iBGP peer to another by default, so routes quietly disappear. Route reflectors or confederations fix this. Someone has to design them deliberately, and that step is often skipped in a hurry.
The second is redistributing the entire BGP table into OSPF. That floods the link-state database with external LSAs and can overwhelm modest routers. Redistribute only what the internal network genuinely needs, usually a default route or a short list of aggregates.
The third is leaving user-facing interfaces active in OSPF. Hellos and routing information then reach segments where they have no business being. They also hand an attacker useful detail about your topology. Set passive interfaces on those ports from the start.
Cost, skills and operations in Vietnam
Routers with full BGP support usually sit in a higher price tier than basic campus switches. Compare prices with local distributors rather than relying on list prices from abroad. Import duties and support terms vary widely between suppliers.
Your team also needs BGP experience to handle peering faults and policy mistakes. Training costs depend on your staff and your provider, so request actual quotes before budgeting. We avoid quoting a figure until we have seen a verified proposal from the vendor or partner.
When to strengthen the underlying links
Routing protocols can only be as resilient as the links they run over. If your WAN has to survive a single circuit failure without drama, the physical and overlay design matters as much as the protocol. Look at SD-WAN and fiber backbone redundancy. Read SD-WAN and Fiber Backbone Resilience at Scale to see how we lay out dual paths between branches and the data center.
For a broader view of how these pieces fit together, our team also publishes practical notes on network automation and configuration management. That helps when you have to push the same policy to dozens of devices without introducing drift.
Frequently asked questions
Does a small business need BGP?
Usually not. If you have a single ISP and no need for policy-based path selection, static routing or a default route is simpler and easier to troubleshoot. BGP becomes worth the effort when you hold your own public address space and connect to two or more providers.
Can OSPF and BGP run on the same router?
Yes, and that is the normal arrangement at a network edge. The router runs OSPF toward internal neighbors and BGP toward providers. You control the exchange between them with route-maps and prefix-lists.
Should we use iBGP instead of OSPF in a campus?
Generally no. iBGP is powerful but demands careful design with route reflectors and more operational discipline. For a campus of ordinary size, OSPF gives faster internal convergence with less to maintain.
How do I find out the convergence time of my equipment?
Test it in a lab that mirrors your production software and hardware, then measure failover under realistic load. Vendor documentation gives a starting point, but your numbers can differ from published figures.
Can BGP and OSPF run together without creating loops?
Yes, provided you control redistribution tightly. Use route-maps, prefix-lists and route tags so routes learned from one protocol are not fed back into the other. Verify the routing table after each change.