Part 1 covered the L2 foundation on SW1 and SW2. This article moves to the routers. R1 and R2 handle inter-VLAN routing via 802.1Q subinterfaces with VRRP, run OSPF and IS-IS on the core P2P link, peer iBGP between themselves and eBGP toward the ISP through the FortiGate, and provide BFD for fast failure detection. R2 also terminates GRE and IP-IP tunnels to the branch and uses filter-based forwarding to steer VLAN20 traffic through GRE. R4 is the branch endpoint with static routing back to HQ.
Missed Part 1? Read it here: JNCIS-ENT: Building the L2 Foundation.
DOT1Q SUBINTERFACES
R1 and R2 are the actual default gateways for VLAN10 and VLAN20, not the switches. The design is router-on-a-stick: a single physical link from each switch carries both VLANs as tagged 802.1Q traffic, and the router terminates each VLAN on a separate logical subinterface.
On Junos, this requires two things on the physical interface before you can create subinterfaces with VLAN IDs. First, flexible-vlan-tagging tells the router to expect 802.1Q tags. Second, encapsulation flexible-ethernet-services changes the interface encapsulation from the default ENET2 to something that actually supports subinterfaces. If you forget the encapsulation line, the subinterfaces will refuse to come up, and the error message will not be particularly helpful about why.
set interfaces ge-0/0/1 description TRUNK-to-SW1set interfaces ge-0/0/1 flexible-vlan-taggingset interfaces ge-0/0/1 encapsulation flexible-ethernet-servicesset interfaces ge-0/0/1 unit 10 description VLAN10-GWset interfaces ge-0/0/1 unit 10 vlan-id 10set interfaces ge-0/0/1 unit 10 family inet address 10.10.10.2/24set interfaces ge-0/0/1 unit 20 description VLAN20-GWset interfaces ge-0/0/1 unit 20 vlan-id 20set interfaces ge-0/0/1 unit 20 family inet address 10.20.20.2/24Verify the subinterfaces are up:
root@R1> show interfaces terse | match ge-0/0/1ge-0/0/1 up upge-0/0/1.10 up up inet 10.10.10.2/24ge-0/0/1.20 up up inet 10.20.20.2/24Both subinterfaces Up/Up. If .10 or .20 shows Down, check the encapsulation first. show interfaces ge-0/0/1 | match encapsulation should return Flexible-Ethernet-Services. If it says ENET2, you forgot the encapsulation line.
VRRP SPLIT ACTIVE-ACTIVE
With two routers providing gateways for two VLANs, VRRP lets us split the load. R1 is master for VLAN10 (priority 150) and backup for VLAN20 (priority 100). R2 is the mirror: master for VLAN20 (priority 150), backup for VLAN10 (priority 100). Both VLANs share a virtual IP that hosts use as their default gateway, and whichever router is master for that VLAN owns the virtual MAC and answers ARP for it.
Here's R1's VRRP on the VLAN10 subinterface, where it's master:
set interfaces ge-0/0/1 unit 10 family inet address 10.10.10.2/24 vrrp-group 10 virtual-address 10.10.10.1set interfaces ge-0/0/1 unit 10 family inet address 10.10.10.2/24 vrrp-group 10 priority 150set interfaces ge-0/0/1 unit 10 family inet address 10.10.10.2/24 vrrp-group 10 preemptset interfaces ge-0/0/1 unit 10 family inet address 10.10.10.2/24 vrrp-group 10 accept-dataset interfaces ge-0/0/1 unit 10 family inet address 10.10.10.2/24 vrrp-group 10 track interface ge-0/0/2 priority-cost 60And VLAN20, where it's backup:
set interfaces ge-0/0/1 unit 20 family inet address 10.20.20.2/24 vrrp-group 20 virtual-address 10.20.20.1set interfaces ge-0/0/1 unit 20 family inet address 10.20.20.2/24 vrrp-group 20 priority 100set interfaces ge-0/0/1 unit 20 family inet address 10.20.20.2/24 vrrp-group 20 preemptset interfaces ge-0/0/1 unit 20 family inet address 10.20.20.2/24 vrrp-group 20 accept-dataR2 has the same structure with the priorities flipped: 150 on VLAN20 (master), 100 on VLAN10 (backup), and interface tracking on ge-0/0/2 for VLAN20 instead.
The accept-data knob is easy to overlook and will cost you in the lab. Without it, the VRRP master responds to ARP for the virtual IP but silently drops actual data packets destined to it. The router owns the virtual IP for gateway purposes but won't process traffic sent to that IP, which means pings to the gateway succeed (ARP resolves) but actual forwarding breaks. Always enable it.
track interface ge-0/0/2 priority-cost 60 watches the FortiGate-facing link. If ge-0/0/2 goes down on R1, its VLAN10 priority drops from 150 to 90, which is below R2's 100, so R2 takes over as VLAN10 master. The logic: if the uplink to the firewall is dead, there's no point being the gateway because you can't forward traffic toward the internet anyway. R2's matching config tracks ge-0/0/2 for VLAN20 for the same reason.
root@R1> show vrrp summaryInterface State Group VR state VR Mode Timer Type Addressge-0/0/1.10 up 10 Master Active 1.000 lcl 10.10.10.2 vip 10.10.10.1ge-0/0/1.20 up 20 Backup Active 3.609 lcl 10.20.20.2 vip 10.20.20.1R1 is Master for VLAN10, Backup for VLAN20. R2 should show the exact inverse.
OSPF AREA 0 AND BFD
OSPF ties the core together. R1, R2, the switches (via passive IRBs), and the FortiGate inside segment all sit in area 0. The R1-R2 P2P link is the only adjacency that actually exchanges LSAs between routers. Everything else is passive, meaning OSPF advertises those prefixes but doesn't try to form adjacencies on them.
set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 interface-type p2pset protocols ospf area 0.0.0.0 interface ge-0/0/0.0 bfd-liveness-detection minimum-interval 300set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 bfd-liveness-detection multiplier 3set protocols ospf area 0.0.0.0 interface ge-0/0/1.10 passiveset protocols ospf area 0.0.0.0 interface ge-0/0/1.20 passiveset protocols ospf area 0.0.0.0 interface ge-0/0/2.0set protocols ospf area 0.0.0.0 interface lo0.0 passiveThe P2P link uses interface-type p2p so OSPF skips the DR/BDR election, which is pointless on a two-router segment. BFD runs at 300ms intervals with a multiplier of 3, giving a detection time of 900ms. Without BFD, OSPF would wait for its dead timer (default 40 seconds) to notice the neighbor is gone, which is an eternity if you need traffic to reconverge.
ge-0/0/2.0 (the FortiGate inside segment) is not passive because the FortiGate also runs OSPF and needs to form an adjacency to redistribute its default route into the enterprise. The VLAN subinterfaces are passive because the switches run OSPF passively on their IRBs too, and nobody needs an actual adjacency on those broadcast segments.
root@R1> show ospf neighborAddress Interface State ID Pri Dead10.1.1.2 ge-0/0/0.0 Full 10.0.0.2 128 3710.1.2.1 ge-0/0/2.0 Full 10.1.2.1 1 33Two neighbors: R2 on the P2P link and the FortiGate on the inside segment. Both Full.
root@R1> show bfd session Detect TransmitAddress State Interface Time Interval10.1.1.2 Up ge-0/0/0.0 0.900 0.3001 sessions, 1 clientsBFD is up, 900ms detection. If this shows Down, check that R2 also has BFD configured with matching parameters on ge-0/0/0.0.
IS-IS
Both R1 and R2 run IS-IS alongside OSPF on the same P2P link. In production, you'd pick one IGP. In this lab, both exist because the exam covers both, and running them in parallel on the same topology is the most efficient way to study the differences without building a second lab. IS-IS has a higher routing preference (18 vs 10 for OSPF internal), so OSPF wins in the RIB for any overlapping prefixes. IS-IS is here for show commands and understanding, not for actual forwarding.
set interfaces ge-0/0/0 unit 0 family isoset interfaces lo0 unit 0 family iso address 49.0001.0100.0000.0001.00set protocols isis interface ge-0/0/0.0 level 1 disableset protocols isis interface ge-0/0/0.0 point-to-pointset protocols isis interface lo0.0 passiveset protocols isis level 1 disableset protocols isis level 2 wide-metrics-onlyLevel 1 is disabled everywhere because this is a single-area flat network with no need for L1/L2 hierarchy. Wide metrics are mandatory for anything modern (narrow metrics cap at 63 per link, which doesn't leave much room for traffic engineering or meaningful metric differentiation).
The NET address on lo0 follows the standard format: area 49.0001, system ID derived from the loopback (10.0.0.1 becomes 0100.0000.0001), selector 00. R2 uses 0100.0000.0002. The ISO family on ge-0/0/0 is required for IS-IS to run on that interface, since IS-IS operates directly on the data link layer rather than on top of IP.
root@R1> show isis adjacencyInterface System L State Hold (secs) SNPAge-0/0/0.0 R2 2 Up 23Level 2 adjacency with R2, Up. You can compare the IS-IS database with OSPF's to see the same topology from two different protocols' perspectives:
root@R1> show isis database detail | match "IP prefix" IP prefix: 10.0.0.1/32 IP prefix: 10.0.0.2/32Same loopbacks, different protocol, different database format. The exam likes to test whether you understand the structural differences: IS-IS uses TLVs inside LSPs, OSPF uses LSA types. The routing math is the same Dijkstra SPF, but the packaging is different.
iBGP
R1 and R2 peer iBGP using loopback addresses, which are resolved through OSPF-learned routes. Loopback peering survives individual link failures as long as some path exists between the loopbacks, though in this topology there's only one physical path so that resilience is theoretical.
set routing-options router-id 10.0.0.1set routing-options autonomous-system 65001set protocols bgp group IBGP type internalset protocols bgp group IBGP local-address 10.0.0.1set protocols bgp group IBGP export IBGP-EXPORTset protocols bgp group IBGP neighbor 10.0.0.2R1's IBGP-EXPORT policy does two important things: sets next-hop self on routes learned from eBGP before advertising them to R2, and also exports the aggregate route:
set policy-options policy-statement IBGP-EXPORT term bgp from protocol bgpset policy-options policy-statement IBGP-EXPORT term bgp then next-hop selfset policy-options policy-statement IBGP-EXPORT term bgp then acceptset policy-options policy-statement IBGP-EXPORT term aggregate from protocol aggregateset policy-options policy-statement IBGP-EXPORT term aggregate then acceptset policy-options policy-statement IBGP-EXPORT term reject then rejectNext-hop self matters because R1 learns eBGP routes from R3 with a next-hop of 203.0.113.2. R2 has no route to 203.0.113.0/30 through OSPF (it's not advertised there), so without next-hop self, R2 would receive the BGP prefix but couldn't resolve the next-hop and would hide the route. Next-hop self rewrites the next-hop to 10.0.0.1 (R1's loopback), which R2 can reach via OSPF.
R2's IBGP-EXPORT is simpler because R2 doesn't do eBGP. It exports static routes (for the branch) and that's about it:
set policy-options policy-statement IBGP-EXPORT term bgp from protocol bgpset policy-options policy-statement IBGP-EXPORT term bgp then acceptset policy-options policy-statement IBGP-EXPORT term static from protocol staticset policy-options policy-statement IBGP-EXPORT term static then acceptset policy-options policy-statement IBGP-EXPORT term reject then rejectroot@R1> show bgp summaryThreading mode: BGP I/OGroups: 2 Peers: 2 Down peers: 0Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...10.0.0.2 65001 xxx xxx 0 0 xx:xx Establ inet.0: 0/0/0/0203.0.113.2 65100 xxx xxx 0 0 xx:xx Establ inet.0: 2/2/2/0Two peers, both Established. R3 sends two prefixes (default route and 8.8.8.0/24).
eBGP THROUGH THE FORTIGATE
R1 peers eBGP with R3 (the simulated ISP, AS 65100) across the FortiGate HA pair. The FortiGate doesn't participate in BGP; it just passes TCP/179 through a firewall policy. From BGP's perspective, the FortiGate is transparent infrastructure.
The catch is that R1 and R3 aren't directly connected. R1 sits on the inside (10.1.2.5), R3 sits on the outside (203.0.113.2), and the FortiGate NATs and routes between them. R1 needs a static route to reach R3's peering address, and the BGP session uses multihop with TTL 2 to account for the FortiGate in the path.
set routing-options static route 203.0.113.0/30 next-hop 10.1.2.1set protocols bgp group EBGP type externalset protocols bgp group EBGP multihop ttl 2set protocols bgp group EBGP local-address 10.1.2.5set protocols bgp group EBGP import EBGP-IMPORTset protocols bgp group EBGP export EBGP-EXPORTset protocols bgp group EBGP peer-as 65100set protocols bgp group EBGP neighbor 203.0.113.2The local-address is R1's inside interface (10.1.2.5), not the loopback, because R3 needs to reach R1 at an address that's routable through the FortiGate. The static route to 203.0.113.0/30 via 10.1.2.1 (the FortiGate's inside IP) ensures R1 can reach R3.
The import policy accepts only the default route and 8.8.8.0/24 from R3:
set policy-options policy-statement EBGP-IMPORT term default from route-filter 0.0.0.0/0 exactset policy-options policy-statement EBGP-IMPORT term default then acceptset policy-options policy-statement EBGP-IMPORT term internet from route-filter 8.8.8.0/24 exactset policy-options policy-statement EBGP-IMPORT term internet then acceptThe export policy sends a single aggregate (10.0.0.0/8) to R3, summarizing the entire enterprise:
set policy-options policy-statement EBGP-EXPORT term aggregate from protocol aggregateset policy-options policy-statement EBGP-EXPORT term aggregate from route-filter 10.0.0.0/8 exactset policy-options policy-statement EBGP-EXPORT term aggregate then acceptset policy-options policy-statement EBGP-EXPORT term reject then rejectThis works with the aggregate route defined in routing-options, which we'll cover in the next section.
STATIC ROUTES, AGGREGATES, AND LOAD BALANCING
Three pieces of routing plumbing that don't get their own protocol but still need to exist.
R1 and R2 both have a static default route pointing at the FortiGate inside IP:
set routing-options static route 0.0.0.0/0 next-hop 10.1.2.1R1 also has the aggregate route that feeds the eBGP export policy:
set routing-options aggregate route 10.0.0.0/8An aggregate route in Junos only appears in the routing table when at least one contributing (more-specific) route exists. Since R1 has connected routes for 10.10.10.0/24, 10.20.20.0/24, and others, the aggregate is always active. It shows as protocol Aggregate in the route table, and the eBGP export policy matches on from protocol aggregate to advertise it to R3.
Per-flow load balancing is enabled on both routers so that when ECMP paths exist, traffic gets distributed across them per flow rather than per destination. In this topology there aren't actual ECMP paths between R1 and R2, but the config is there for completeness and because the exam tests it:
set policy-options policy-statement LB term 1 then load-balance per-flowset routing-options forwarding-table export LBThe forwarding-table export stanza applies the load-balance policy to the FIB, not the RIB. This distinction matters: the RIB selects best paths, the FIB decides how to spray packets across equal-cost paths.
GRE AND IP-IP TUNNELS
R2 connects to the branch router R4 via two tunnels running over the same physical P2P link (10.1.4.0/30). Both use the P2P addresses as outer transport, but they have different inner addressing and different overhead characteristics.
GRE adds a 24-byte header (20 IP + 4 GRE), so MTU drops from 1500 to 1476. IP-IP adds only a 20-byte header (just the outer IP, no protocol-specific header), so MTU is 1480. TCP MSS is set 40 bytes below MTU to account for the inner IP and TCP headers.
R2's GRE tunnel:
set interfaces gr-0/0/0 description GRE-to-R4set interfaces gr-0/0/0 unit 0 tunnel source 10.1.4.1set interfaces gr-0/0/0 unit 0 tunnel destination 10.1.4.2set interfaces gr-0/0/0 unit 0 family inet mtu 1476set interfaces gr-0/0/0 unit 0 family inet tcp-mss 1436set interfaces gr-0/0/0 unit 0 family inet address 172.16.1.1/30R2's IP-IP tunnel:
set interfaces ip-0/0/0 unit 0 description IP-IP-to-R4set interfaces ip-0/0/0 unit 0 tunnel source 10.1.4.1set interfaces ip-0/0/0 unit 0 tunnel destination 10.1.4.2set interfaces ip-0/0/0 unit 0 family inet mtu 1480set interfaces ip-0/0/0 unit 0 family inet tcp-mss 1440set interfaces ip-0/0/0 unit 0 family inet address 172.16.2.1/30R4 has the mirror config with source and destination swapped and .2 addresses on the inner interfaces. The practical difference between the two: GRE can carry non-IP protocols (multicast, MPLS, ISO) because it has its own protocol header with a protocol type field. IP-IP can only encapsulate IPv4 inside IPv4. For this lab, both carry IPv4 only, so the functional difference is just the 4 bytes of overhead. The exam tests when you'd pick one over the other.
root@R2> show interfaces terse | match "gr-|ip-"gr-0/0/0.0 up up inet 172.16.1.1/30ip-0/0/0.0 up up inet 172.16.2.1/30Both Up/Up. If they show up down, R4's tunnel config isn't committed yet or the P2P link between R2 and R4 is down.
root@R2> ping 172.16.1.2 count 3PING 172.16.1.2 (172.16.1.2): 56 data bytes64 bytes from 172.16.1.2: icmp_seq=0 ttl=64 time=2.341 ms64 bytes from 172.16.1.2: icmp_seq=1 ttl=64 time=1.987 ms64 bytes from 172.16.1.2: icmp_seq=2 ttl=64 time=1.854 msGRE inner reachability confirmed.
FILTER-BASED FORWARDING
Filter-based forwarding (FBF) on R2 solves a specific problem: traffic from VLAN20 hosts (10.20.20.0/24) destined for the branch LAN (192.168.4.0/24) should go through the GRE tunnel, even though R2's default routing table might prefer a different path. FBF intercepts matching traffic at the interface level and redirects it into a separate routing instance with its own forwarding table.
The firewall filter matches on source (VLAN20) and destination (branch LAN):
set firewall family inet filter FBF-GRE term to-branch from source-address 10.20.20.0/24set firewall family inet filter FBF-GRE term to-branch from destination-address 192.168.4.0/24set firewall family inet filter FBF-GRE term to-branch then count FBF-BRANCH-HITset firewall family inet filter FBF-GRE term to-branch then routing-instance BRANCH-FORWARDINGset firewall family inet filter FBF-GRE term default then acceptThe routing-instance BRANCH-FORWARDING action is what makes this FBF rather than a regular filter. Instead of accept/discard/policer, it shunts the packet into a different routing instance for lookup.
The BRANCH-FORWARDING instance is type forwarding, which means it's not a full VRF with its own interfaces. It's a lightweight table that borrows routes and makes independent forwarding decisions:
set routing-instances BRANCH-FORWARDING instance-type forwardingset routing-instances BRANCH-FORWARDING routing-options interface-routes rib-group inet inet-to-branchset routing-instances BRANCH-FORWARDING routing-options static route 192.168.4.0/24 next-hop 172.16.1.2The static route inside the instance points 192.168.4.0/24 at 172.16.1.2, which is R4's GRE inner address. The RIB group imports routes from inet.0 into BRANCH-FORWARDING.inet.0 so the instance can resolve the GRE next-hop:
set routing-options rib-groups inet-to-branch import-rib inet.0set routing-options rib-groups inet-to-branch import-rib BRANCH-FORWARDING.inet.0The first import-rib is the source, the second is the destination. Routes from inet.0 get copied into BRANCH-FORWARDING.inet.0. Without this, the forwarding instance has a static route to 172.16.1.2 but no idea how to reach it because gr-0/0/0 lives in the main instance.
The filter applies inbound on R2's VLAN20 subinterface:
set interfaces ge-0/0/1 unit 20 family inet filter input FBF-GREVerify the counter after sending test traffic:
root@R2> show firewall filter FBF-GREFilter: FBF-GRECounters:Name Bytes PacketsFBF-BRANCH-HIT 840 10Ten packets matched and got redirected. If the counter stays at zero, check that the filter is actually applied on the correct interface and unit, and that the source/destination match conditions are correct.
R4: THE BRANCH
R4 is the simplest device in the topology. It has one physical link to R2 (ge-0/0/0, 10.1.4.2/30), one LAN interface (ge-0/0/1, 192.168.4.1/24), and both tunnel endpoints mirroring R2's config with source/destination swapped.
The routing is entirely static. R4 doesn't run OSPF, IS-IS, or BGP. It points its default route at R2's physical P2P address, and uses more-specific statics for enterprise subnets via the GRE tunnel and for R1's loopback via the IP-IP tunnel:
set routing-options router-id 10.0.0.4set routing-options static route 0.0.0.0/0 next-hop 10.1.4.1set routing-options static route 10.0.0.0/24 next-hop 172.16.1.1set routing-options static route 10.0.0.1/32 next-hop 172.16.2.1set routing-options static route 10.10.10.0/24 next-hop 172.16.1.1set routing-options static route 10.20.20.0/24 next-hop 172.16.1.1The interesting detail: 10.0.0.1/32 (R1's loopback) goes through the IP-IP tunnel (172.16.2.1), while the enterprise subnets go through GRE (172.16.1.1). This is deliberate. It gives you two different tunnel paths to verify independently and demonstrates that you can steer specific prefixes through specific tunnels using nothing more than static routes and longest-prefix match.
root@R4> show route protocol staticinet.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)+ = Active Route, - = Last Active, * = Both0.0.0.0/0 *[Static/5] 00:05:xx > to 10.1.4.1 via ge-0/0/0.010.0.0.0/24 *[Static/5] 00:05:xx > to 172.16.1.1 via gr-0/0/0.010.0.0.1/32 *[Static/5] 00:05:xx > to 172.16.2.1 via ip-0/0/0.010.10.10.0/24 *[Static/5] 00:05:xx > to 172.16.1.1 via gr-0/0/0.010.20.20.0/24 *[Static/5] 00:05:xx > to 172.16.1.1 via gr-0/0/0.0Enterprise traffic goes through GRE. R1's loopback specifically goes through IP-IP. Default goes out the physical link. You can traceroute from R4 to verify:
root@R4> traceroute 10.10.10.2 source 192.168.4.1traceroute to 10.10.10.2 (10.10.10.2), 30 hops max, 52 byte packets 1 172.16.1.1 (172.16.1.1) 2.115 ms 1.943 ms 1.876 ms 2 10.10.10.2 (10.10.10.2) 3.241 ms 3.012 ms 2.987 msFirst hop is R2's GRE inner address, confirming the traffic went through the tunnel. Second hop is R1's VLAN10 subinterface.
root@R4> traceroute 10.0.0.1 source 10.0.0.4traceroute to 10.0.0.1 (10.0.0.1), 30 hops max, 52 byte packets 1 172.16.2.1 (172.16.2.1) 2.054 ms 1.887 ms 1.823 ms 2 10.0.0.1 (10.0.0.1) 3.156 ms 2.943 ms 2.901 msFirst hop is R2's IP-IP inner address. Different tunnel, same destination router, different path. That's the whole point of having both.
THAT'S IT!
R1, R2, and R4 are done. The core has 802.1Q subinterfaces, VRRP split active-active with interface tracking, OSPF and IS-IS running in parallel (one for production, one for the exam), iBGP with next-hop self, eBGP through the FortiGate, GRE and IP-IP tunnels to the branch, and filter-based forwarding to steer VLAN20 traffic through GRE. R4 sits at the end with static routes pointing back through the tunnels, happy and simple.
Next up is the FortiGate HA pair: FGCP active-passive, firewall policies for BGP transit and internet access, NAT, and the OSPF integration that makes the whole perimeter work. That's the NSE4 side of this lab, and it's a different kind of config entirely.
