I am continuing my JNCIP-ENT lab series with BGP. This lab covers BGP peering and next-hop resolution. It is the first BGP lab in the series. The topology consists of two autonomous systems. We will establish EBGP between the two ASes and a full-mesh IBGP within one of them, then examine how the BGP next-hop attribute is handled when a prefix is advertised from EBGP into IBGP.
Overview
The topology contains two autonomous systems:
- AS 65100 is the internal network. It consists of three routers connected in a triangle. R1 is the border router. R2 and R3 are internal routers with no external connectivity.
- AS 65200 is the external network. It consists of a single router, R4, with a customer LAN (
198.51.100.0/24) and a host (H1) attached. R4 originates198.51.100.0/24into BGP.
R1 and R4 establish EBGP over a directly connected link. R1, R2, and R3 establish IBGP in a full mesh, peering over loopback addresses. OSPF area 0 will help advertise the loopbacks.
We will perform the following tasks:
- Establish EBGP between AS 65100 and AS 65200, and a full-mesh IBGP within AS 65100.
- Observe
198.51.100.0/24installed as a hidden route on R2 and R3, and identify the cause. - Resolve the hidden route with next-hop self, and document the alternative IGP-based method.
- Remove one IBGP session to demonstrate that an IBGP-learned route is not re-advertised to another IBGP peer, then restore it.
- Verify end-to-end forwarding with a ping from R3 to the host in AS 65200.
Topology
Base configuration
We will configure interfaces and OSPF first, and confirm loopback reachability before configuring BGP. IBGP peering over loopbacks requires the loopbacks to be reachable through OSPF.
R1 is representative of the internal routers:
set interfaces ge-0/0/0 unit 0 family inet address 10.1.12.1/30set interfaces ge-0/0/1 unit 0 family inet address 10.1.13.1/30set interfaces ge-0/0/2 unit 0 family inet address 172.16.14.1/30set interfaces lo0 unit 0 family inet address 10.0.0.1/32set protocols ospf area 0.0.0.0 interface ge-0/0/0.0set protocols ospf area 0.0.0.0 interface ge-0/0/1.0set protocols ospf area 0.0.0.0 interface lo0.0 passiveset routing-options router-id 10.0.0.1set routing-options autonomous-system 65100R4 is in AS 65200 and does not run an IGP:
set interfaces ge-0/0/0 unit 0 family inet address 172.16.14.2/30set interfaces ge-0/0/3 unit 0 family inet address 198.51.100.1/24set interfaces lo0 unit 0 family inet address 10.255.0.4/32set routing-options router-id 10.255.0.4set routing-options autonomous-system 65200H1:
ifconfig eth0 198.51.100.10 netmask 255.255.255.0 uproute add default gw 198.51.100.1Verifying the underlay
We commit the routers and verify OSPF:
show ospf neighborEach internal router has two internal neighbors and should show two adjacencies in the Full state. show route protocol ospf should list the other two loopbacks (10.0.0.x/32) and the remote transit /30.
Verify loopback reachability directly:
ping 10.0.0.3 source 10.0.0.1 count 3BGP configuration
We will configure EBGP on the border router first, then the full IBGP mesh.
R1 (border router)
R1 has two BGP groups: an external group toward R4 and an internal group toward R2 and R3.
set protocols bgp group ext-as65200 type externalset protocols bgp group ext-as65200 peer-as 65200set protocols bgp group ext-as65200 neighbor 172.16.14.2set protocols bgp group ibgp-65100 type internalset protocols bgp group ibgp-65100 local-address 10.0.0.1set protocols bgp group ibgp-65100 neighbor 10.0.0.2set protocols bgp group ibgp-65100 neighbor 10.0.0.3For IBGP over loopbacks, local-address must be set to the loopback so the TCP session is sourced from it.
R2 and R3
Each internal router uses the internal group with its own loopback as the local address and the other two loopbacks as neighbors.
set protocols bgp group ibgp-65100 type internalset protocols bgp group ibgp-65100 local-address 10.0.0.2set protocols bgp group ibgp-65100 neighbor 10.0.0.1set protocols bgp group ibgp-65100 neighbor 10.0.0.3set protocols bgp group ibgp-65100 type internalset protocols bgp group ibgp-65100 local-address 10.0.0.3set protocols bgp group ibgp-65100 neighbor 10.0.0.1set protocols bgp group ibgp-65100 neighbor 10.0.0.2This produces a full mesh of three sessions: R1-R2, R1-R3, and R2-R3.
R4 (external AS)
R4 advertises the customer LAN into BGP. A direct route is not advertised into BGP by default, so we add an export policy.
set protocols bgp group ext-as65100 type externalset protocols bgp group ext-as65100 peer-as 65100set protocols bgp group ext-as65100 neighbor 172.16.14.1set protocols bgp group ext-as65100 export ADV-CUSTOMERset policy-options policy-statement ADV-CUSTOMER term origin from protocol directset policy-options policy-statement ADV-CUSTOMER term origin from route-filter 198.51.100.0/24 exactset policy-options policy-statement ADV-CUSTOMER term origin then acceptset policy-options policy-statement ADV-CUSTOMER term reject then rejectVerifying the sessions
We commit all routers and verify the sessions on R1:
show bgp summaryThree peers should be in the Established state: the external peer 172.16.14.2 and the internal peers 10.0.0.2 and 10.0.0.3. An internal peer in the Active or Connect state indicates that the loopback is unreachable or that local-address is incorrect. An external peer that does not establish indicates a problem with the directly connected /30 or peer-as.
Hidden routes from an unresolved next-hop
R1, R2, and R3 all receive 198.51.100.0/24. Their handling of the prefix differs.
On R1:
show route 198.51.100.0/24R1 installs the route as active, with preference [BGP/170], localpref 100, AS path 65200 I, and next-hop 172.16.14.2 resolved through the directly connected interface ge-0/0/2.
On R2 (R3 is identical):
show route 198.51.100.0/24The prefix is not in the active routing table. It is present but hidden:
show route 198.51.100.0/24 hidden extensiveThe extensive output shows the next-hop type as Unusable and the protocol next-hop 172.16.14.2 in the PnhUnresolv (protocol next-hop unresolved) state. R2 has no route to 172.16.14.0/30, because that subnet is not advertised into OSPF. A BGP route with an unresolvable next-hop is not installed so it is installed as hidden.
show route receive-protocol bgp 10.0.0.1 198.51.100.0/24 hiddenThe next-hop is 172.16.14.2, unchanged from the value R1 received over EBGP. IBGP does not modify the next-hop attribute by default. R2 and R3 are therefore instructed to reach 198.51.100.0/24 through 172.16.14.2, an address only R1 can reach, and the route is hidden on both non-border routers.
A hidden route is retained rather than discarded. When a route that resolves the next-hop becomes available, Junos re-evaluates the hidden route automatically; no BGP update or session reset is required.
Resolving the next-hop
There is two methods to resolve the hidden route. The first, next-hop self, is the standard approach.
next-hop self
We will configure R1 to set the next-hop to its own address when advertising EBGP-learned routes to IBGP peers.
set policy-options policy-statement NHS then next-hop selfset protocols bgp group ibgp-65100 export NHSThe policy sets the next-hop and takes no accept or reject action. Because it does not reject the route, the default IBGP export behavior applies and advertises the active BGP route with the next-hop set to 10.0.0.1. A then accept is not required; adding a reject would prevent the default export behavior from advertising the route.
On R2 and R3:
show route 198.51.100.0/24The prefix is now active. The next-hop is 10.0.0.1, resolved through OSPF to the physical next-hop toward R1. show route hidden no longer lists the prefix.
The received route now shows the modified next-hop. The route is active, so the hidden keyword is no longer required:
show route receive-protocol bgp 10.0.0.1 198.51.100.0/24The next-hop is 10.0.0.1 instead of 172.16.14.2.
Alternative: advertise the external interface into OSPF
The next-hop can also be resolved by advertising R1's EBGP-facing interface into OSPF as a passive interface.
delete protocols bgp group ibgp-65100 export NHSset protocols ospf area 0.0.0.0 interface ge-0/0/2.0 passiveAdding ge-0/0/2 to OSPF as passive advertises 172.16.14.0/30 as a stub network in R1's router LSA, which allows R2 and R3 to resolve the original next-hop. The passive keyword prevents OSPF from forming an adjacency or sending hellos on the interface, which is appropriate for a link facing another AS. On R2, the received next-hop is 172.16.14.2 and is now resolvable through the OSPF route to 172.16.14.0/30.
This method advertises the external transit subnet into the IGP which is why it is better to use next hop self
delete protocols ospf area 0.0.0.0 interface ge-0/0/2.0set protocols bgp group ibgp-65100 export NHSData-plane verification
To verify forwarding, R4 requires a return path to the internal loopbacks. We configure an EBGP export policy on R1 to advertise them:
set policy-options policy-statement ADV-INTERNAL term loopbacks from route-filter 10.0.0.0/24 orlongerset policy-options policy-statement ADV-INTERNAL term loopbacks from protocol directset policy-options policy-statement ADV-INTERNAL term loopbacks from protocol ospfset policy-options policy-statement ADV-INTERNAL term loopbacks then acceptset policy-options policy-statement ADV-INTERNAL term reject then rejectset protocols bgp group ext-as65200 export ADV-INTERNALAfter committing, R4 has 10.0.0.1/32, 10.0.0.2/32, and 10.0.0.3/32 via 172.16.14.1.
We ping from R3, a non-border router, sourced from its loopback, to the host in AS 65200:
ping 198.51.100.10 source 10.0.0.3 count 3The ping succeeds. R3 resolves 198.51.100.0/24 to next-hop 10.0.0.1, forwards to R1, and R1 forwards the traffic over EBGP to R4, which delivers it to H1. The return path uses the loopbacks advertised by R1. ping -c 3 10.0.0.3 from H1 verifies the reverse direction.
The IBGP advertisement rule
The configuration works because the IBGP mesh is complete: R1 peers directly with both R2 and R3. If we remove one session it will fail.
We will remove the R1-R3 session on both ends to demonstrate.
R1:
delete protocols bgp group ibgp-65100 neighbor 10.0.0.3R3:
delete protocols bgp group ibgp-65100 neighbor 10.0.0.1We commit both. The remaining IBGP sessions are R1-R2 and R2-R3, so R3's only IBGP neighbor is R2. On R3:
show route 198.51.100.0/24show bgp summaryThe prefix is absent from R3, not hidden. show bgp summary shows R3 receiving zero prefixes from R2.
The cause is the IBGP advertisement rule: R2 learned 198.51.100.0/24 from R1 over IBGP, and an IBGP-learned route is not re-advertised to another IBGP peer. R2 therefore does not advertise the prefix to R3. R1 would advertise it to R3 directly, but that session has been removed.
We can confirm this from R2. The routes R2 advertises to R3:
show route advertising-protocol bgp 10.0.0.3 198.51.100.0/24R2 advertises nothing for this prefix. The routes R2 receives from R1:
show route receive-protocol bgp 10.0.0.1 198.51.100.0/24R2 holds the route but does not forward it to another IBGP peer.
We restore the R1-R3 session on both ends.
R1:
set protocols bgp group ibgp-65100 neighbor 10.0.0.3R3:
set protocols bgp group ibgp-65100 neighbor 10.0.0.1We commit. R3 installs 198.51.100.0/24 as active again, learned directly from R1:
show route 198.51.100.0/24A full mesh is required because an IBGP-learned route is not re-advertised between IBGP peers. The number of sessions grows as n(n-1)/2, so larger networks use route reflectors or confederations instead of a full mesh.
Key points:
- On a directly connected EBGP session, the peer advertises itself as the next-hop, and IBGP preserves that next-hop by default. This is the cause of the hidden route on the non-border routers.
- An IBGP route with an unresolvable next-hop is retained as hidden. Junos re-evaluates it automatically when a resolving route becomes available. Next-hop resolution is independent of the EBGP TTL.
- The IBGP next-hop problem has two standard resolutions: next-hop self on the border router, which does not modify the IGP, or advertising the external interface into the IGP as passive, which advertises the transit subnet into the IGP.
- next-hop self in Junos is a policy containing only
then next-hop self. It sets the attribute and relies on the default IBGP export behavior to advertise the route;then acceptis not required. - An IBGP router advertises EBGP-learned and locally originated routes to IBGP peers, but does not re-advertise an IBGP-learned route to another IBGP peer. A full IBGP mesh, a route reflector, or a confederation is therefore required.
- A received prefix is not necessarily active. A prefix can be received and hidden at the same time; cross-check with
show route hiddenwhen theshow bgp summarycounts are unexpected.
