OSPF, or Open Shortest Path First. This is the secret sauce that lets routers in a Junos network automatically figure out the best way to send your data from point A to point B without a human having to manually draw the map. For the JNCIA-JUNOS exam, you must understand how to turn on OSPF for a single area—this is the first and most critical step in making a network smart enough to fix itself when things change.
Jump to a section
A simple way to picture Junos OSPF Configuration Basics
A regional post office sorting hub manager. Their job is to make sure every letter and package gets to the right destination, even when the postal system has multiple hubs. They don't control every single postman, but they manage the high-level map of how mail should flow between hubs. To do this, they must know about every other hub in their region and the fastest routes to reach them. \ \ If a new sorting hub opens in a neighbouring town, the manager must update their maps and tell all the other hubs about this new location. They do this by shouting out a special announcement: "Hey everyone, I know how to get to the new hub!" Other hubs listen and update their own maps. If a road closes or a new highway is built, the manager recalculates the best path and announces the change again. \ \ The office receives a constant stream of small test postcards from every other hub. If postcards from a particular hub stop arriving, the manager knows a route is broken and will mark it as dead. They then recalculate an alternative path for any mail that used that broken route. This is exactly how OSPF works: routers (the sorting hubs) discover each other, share their maps, and constantly check the health of their connections so that data (the mail) always takes the best available path.
Imagine you are in charge of a massive city with multiple neighbourhoods, and you need to decide the best way to deliver a package from one neighbourhood to another. You could draw a map yourself and update it every time a road is closed or a new street is built. That is 'static routing' — it works, but it is a huge pain to maintain and breaks the moment something changes. \ \ OSPF is the intelligent, automatic alternative. OSPF stands for Open Shortest Path First. It is a 'dynamic routing protocol', meaning the routers themselves talk to each other, discover the network layout, and calculate the best paths without you having to type every single route by hand. \ \ Here is how it works in a Junos device, step by step. \ \ First, every router that wants to use OSPF must be told to 'enable' OSPF on its interfaces — the physical ports that connect it to other routers or networks. In Junos, you configure this under the 'protocols ospf' hierarchy. You specify which interfaces (like ge-0/0/0) should participate in OSPF. You also assign the interface to an 'area'. For the JNCIA-JUNOS exam, you only deal with a single area, usually 'area 0.0.0.0', which is called the backbone area. \ \ Once OSPF is enabled on an interface, the router starts sending out 'Hello' packets. These are small, frequent messages that say, "Is anyone there?" If another OSPF-enabled router on the same cable receives the Hello, it replies. This is how two routers become 'neighbours'. They don't immediately swap all their routing information. First, they go through a negotiation process to become fully adjacent, ensuring they are on the same page. \ \ After becoming neighbours, the routers exchange 'Link State Advertisements' or LSAs. Think of an LSA as a postcard that says, "I am Router A, I am connected to Network X with a cost of 5." The 'cost' is the metric OSPF uses to determine the desirability of a route. It is often based on the speed of the link: a 1 Gbps link has a lower cost (more desirable) than a 100 Mbps link. \ \ Every router collects all the LSAs from its neighbours and builds a complete map of the network, called the 'Link State Database' (LSDB). Each router then runs the 'SPF algorithm' (Shortest Path First algorithm, created by Edsger Dijkstra) on this map to calculate the best, quickest path to every destination. The result is placed into the routing table, which tells the router where to forward packets. \ \ Why does this matter for beginners? Because OSPF is self-healing. If a link goes down, the router that detects the failure sends a new LSA to all its neighbours. They all recalculate their maps and update their routing tables within seconds. This is called 'convergence'. Without OSPF, you would have to manually delete the old route and type in a new one, which is slow and error-prone. \ \ On Junos, verifying your OSPF configuration is done with the 'show ospf neighbor' command (to see if you have formed neighbour relationships) and 'show ospf route' (to see the routes OSPF has learned). These are the primary verification commands you will use in the exam lab. \ \ Finally, OSPF uses areas to keep networks organised and efficient. The exam only tests single-area OSPF, which means all routers belong to the same area (usually area 0). In a single area, every router knows every route in the network. This is simple, but it does not scale to thousands of routers. For the exam, you just need to configure it correctly and verify that neighbours form and routes appear.
1. Configure interface IP addresses
Before OSPF can run, each interface that will participate in OSPF must have a valid IP address configured under the 'interfaces' hierarchy. For example, 'set interfaces ge-0/0/0 unit 0 family inet address 10.0.12.1/30'. This gives the router a unique identity on the network.
2. Enable OSPF on the desired interfaces in area 0
Enter the 'protocols ospf' configuration section and define area 0.0.0.0. Then add each interface that should run OSPF. The command is 'set protocols ospf area 0.0.0.0 interface ge-0/0/0.0'. This tells the router to start sending Hello packets on that interface.
3. Verify neighbour formation
After committing the configuration, use the operational command 'show ospf neighbor'. This lists all neighbouring routers discovered. Check that the state column shows 'Full' for at least one neighbour. If it shows 'Init' or 'Down', there is a problem with IP addressing, area mismatch, or a firewall blocking OSPF traffic.
4. Check the OSPF routing table
Use 'show ospf route' to see which networks OSPF has learned from neighbours. This confirms that routes from other routers are being installed. If a network you expect is missing, verify that the remote router has OSPF enabled on its interface and that it is advertising the correct prefix.
5. Test connectivity between end devices
Finally, ping from a device on one side of the OSPF network to a device on the other side. If the ping succeeds, the OSPF configuration is working. If it fails, check the routing table on the source and destination routers to ensure the return path is also learned via OSPF.
An IT professional at a medium-sized company, say one with three office floors and a data centre, would use OSPF to connect all the switches and routers so that employees can access the company's internal server and the internet reliably. \ \ Here is what they actually do, step by step. \ \ First, they log into the main Juniper router in the server room using SSH. They enter configuration mode. They type 'set protocols ospf area 0.0.0.0 interface ge-0/0/0.0' to enable OSPF on the port that connects to the switch on floor 1. They repeat this for the ports connecting to floor 2 and floor 3. \ \ Next, they need to make sure the router on floor 1 is also configured. They SSH into that switch and configure the same area and interface. If they misspell the area or forget to enable OSPF on one side, the neighbour relationship will not form. The engineer then runs 'show ospf neighbor' to confirm. They expect to see the state 'Full' for each neighbour. If they see 'Init' or 'ExStart', something is wrong with the Hello timer or the area ID. \ \ The real-world trick is that OSPF by itself does not advertise a default route to the internet. So the engineer must also add a 'default route' using the 'set protocols ospf area 0.0.0.0 interface ge-0/0/0.0' and then also configure a 'routing-options' stanza to generate a default route into OSPF. Without this, devices on floor 2 might know how to reach floor 1 but not know how to reach Google. \ \ A common task is troubleshooting why a new server on floor 3 cannot be reached. The engineer would check the OSPF database with 'show ospf database' to see if the server's network is being advertised. If the network is missing, they check if the interface connected to the server has OSPF enabled and is in the correct area. \ \ In a real scenario, the engineer also uses 'monitor traffic interface' to see if Hello packets are actually being sent and received. They might also configure 'OSPF authentication' to prevent unauthorised routers from joining the network, though this is beyond the JNCIA scope. \ \ The key takeaway from the real world: OSPF configuration is usually just a few lines, but troubleshooting why neighbours are not forming is the bulk of the work. Misconfigured interface IP addresses, mismatched area IDs, or firewalls blocking OSPF (protocol 89) are the most frequent causes of failure.
The JNCIA-JUNOS exam tests your ability to configure and verify single-area OSPF. Here is exactly what you need to know. \ \ The exam will present a multiple-choice or fill-in-the-blank question where you must identify the correct configuration command. The most common pattern is: 'Which command enables OSPF on interface ge-0/0/1 in area 0.0.0.0?' The correct answer is 'set protocols ospf area 0.0.0.0 interface ge-0/0/1.0'. They love to test that you use the exact syntax, including the unit number '0' after the interface (like ge-0/0/1.0). \ \ Another frequent trap is the difference between 'set protocols ospf area 0.0.0.0 interface ge-0/0/1.0' and 'set interfaces ge-0/0/1.0 unit 0 family inet address 10.0.0.1/30'. You must know that the IP address is set under 'interfaces', and OSPF is enabled under 'protocols'. They sometimes combine these in a single question to see if you get confused. \ \ Verification is heavily tested. Expect questions like: 'After configuring OSPF, you run a command and see that the neighbor state is Init. What does this indicate?' The answer is that the router has received a Hello from the neighbour but has not yet established a two-way conversation. The trap answer is 'the neighbor is fully adjacent' — that would be 'Full'. \ \ Memorise these key show commands: \ - 'show ospf neighbor' — displays the list of OSPF neighbours and their state. \ - 'show ospf route' — displays the routes OSPF has installed in the routing table. \ - 'show ospf database' — displays the link-state database (the collection of LSAs). \ - 'show configuration protocols ospf' — shows the current OSPF configuration. \ \ The exam loves to ask about the 'backbone area'. Remember, the backbone area is always area 0 (or 0.0.0.0). In a single-area OSPF network, that area must be area 0. If you use area 1 for all routers in the exam scenario, they will never form neighbours. \ \ Another exam favourite is the 'metric' or 'cost' of an OSPF route. They might ask: 'A 100 Mbps link has a reference bandwidth of 100 Mbps. What is the OSPF cost of a 100 Mbps interface?' The answer is 1 (since cost = reference bandwidth / interface bandwidth). If the interface is 10 Mbps, the cost is 10. Memorise this calculation. \ \ Finally, they test your understanding of 'passive interfaces'. An interface that is set to 'passive' under OSPF will advertise the network but will not send or accept Hello packets. This is used for interfaces that connect to end-user devices, not other routers. Expect a question where you need to identify why a router is not forming a neighbour on a specific interface — the answer may be that the interface is configured as passive.
OSPF is a dynamic routing protocol that automatically discovers network paths and recalculates routes when a link fails, eliminating the need for manual static routes.
The configuration command for enabling OSPF on an interface in Junos is 'set protocols ospf area <area-id> interface <interface-name>'. Ensure you include the unit number (e.g., ge-0/0/1.0).
Two OSPF routers become neighbours only if they are configured in the same area and their interfaces have matching IP subnets and Hello timers.
The 'show ospf neighbor' command displays the state of neighbour relationships; a state of 'Full' means the adjacency is complete and routes are being exchanged.
OSPF cost is calculated based on link bandwidth, not hop count; a higher bandwidth link has a lower cost and is preferred.
In a single-area OSPF configuration, all routers must belong to area 0 (the backbone area) to ensure full connectivity and proper route learning.
A passive interface in OSPF advertises the connected network but does not send or receive Hello packets, making it suitable for end-user device connections.
Verification commands like 'show ospf route' and 'show ospf database' are essential for confirming that OSPF has learned and installed the correct routes.
These come up on the exam all the time. Here's how to tell them apart.
OSPF
Automatically discovers neighbours and network topology.
Recalculates routes dynamically when a link fails.
Uses a metric (cost) based on link bandwidth.
Suitable for large, complex networks.
Static Routing
Requires manual configuration of every route.
Does not adapt to failures; a failed link means a broken route until manually updated.
No metric; next hop is simply defined.
Suitable for small, stable networks with few changes.
OSPF Neighbour State 'Full'
Indicates a fully established adjacency.
Both routers have synchronised their link-state databases.
The router can now forward traffic through this neighbour.
OSPF Neighbour State 'Init'
Indicates that only a one-way Hello has been received.
The neighbour relationship is not yet complete.
No routes are being exchanged yet.
OSPF Cost (Metric)
Calculated as reference bandwidth divided by interface bandwidth.
A faster link (e.g., 1 Gbps) has a lower cost than a slower link (e.g., 100 Mbps).
More accurate for real-world performance because it considers speed.
RIP Hop Count (Metric)
Simply counts the number of routers a packet must traverse.
Ignores link speed; a fast 1 Gbps link with one hop is rated the same as a slow 56 kbps link with one hop.
Less accurate for performance but simpler to understand.
Mistake
OSPF is a protocol that replaces the need for an IP address on an interface.
Correct
OSPF relies on the interface having a valid IP address configured. Without an IP address, OSPF cannot send Hello packets or build neighbour relationships.
Beginners think OSPF handles everything, but routing protocols operate on top of IP; the interface must already be up and have an IP address.
Mistake
Enabling OSPF on a router automatically makes it know every route in the entire world.
Correct
OSPF only learns routes that other OSPF-enabled routers in the same area advertise. It does not import routes from the internet or from other routing protocols unless explicitly configured to do so.
New learners confuse OSPF with the internet's global BGP routing. OSPF is designed for a single organisation's network (an Autonomous System), not the whole internet.
Mistake
The 'cost' of an OSPF route is determined by the number of routers the packet has to pass through (hop count).
Correct
OSPF cost is calculated based on the bandwidth of the link, not hop count. A faster link has a lower cost. The formula is typically cost = reference bandwidth / interface bandwidth.
RIP (another protocol) uses hop count, and many beginners assume all routing protocols work the same way. The exam specifically tests this difference.
Mistake
If you see the neighbour state 'Full', the router has finished exchanging routes and will never update them again.
Correct
The 'Full' state means the neighbours are fully adjacent and have synchronised their databases. However, OSPF continues to send Hello packets every few seconds to maintain the relationship and will send new LSAs if a link changes.
People assume 'done' means static, but OSPF is dynamic and constantly monitors health. The state 'Full' is the normal operational state, not the end of all activity.
Mistake
You must configure the same OSPF area number on every interface for them to form neighbours.
Correct
Two routers can only become neighbours if they share the same area on the connecting interface. If Router A has area 0 on its interface and Router B has area 1 on its interface, they will never become neighbours.
Beginners often set different area IDs on connected interfaces, thinking each router can pick its own area. The area must match on the link for OSPF to form an adjacency.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
Static routing requires you to manually type in every destination route. OSPF automatically discovers routes by talking to neighbouring routers and recalculates paths if a link fails, making it much more scalable and resilient.
The backbone area (area 0) is the core of an OSPF network. Even in a single area, all routers must belong to area 0 by convention, because Junos expects it and other areas require area 0 to function. The exam always tests single-area using area 0.
Yes, OSPF can run over any interface that has an IP address and supports multicast, including wireless LANs and VPN tunnels. However, you must ensure the underlying link is stable and the Hello timers are adjusted if the link is slow or lossy.
Setting an interface to passive means that OSPF advertises the network connected to that interface but does not send or listen for Hello packets on it. This prevents wasting resources on interfaces that only connect to end devices (like laptops) rather than other routers.
Use the operational command 'show ospf route' to see all routes learned by OSPF. For a more general view, use 'show route protocol ospf' to see how OSPF routes appear in the main routing table.
The 'Init' state means your router has received a Hello packet from the neighbour but has not yet established two-way communication. This usually indicates a mismatch in area IDs, subnet masks, or Hello/dead timers. Check that both sides have identical OSPF configuration on the connecting interface.
You've finished Junos OSPF Configuration Basics. Continue through the JNCIA-JUNOS study guide to build a complete picture of the exam.
Done with this chapter?