# IOS-XR BGP Config for ExaBGP Peering Apply to **both CORE routers** (`CML-R9K-CORE-01` @ 10.100.0.100 and `CML-R9K-CORE-02` @ 10.100.0.200). Credentials: `ssh user@` password `cisco` --- ## Route Policy (apply once per router) ``` route-policy EXABGP_IN pass end-policy route-policy EXABGP_OUT drop end-policy ``` --- ## BGP Neighbor Block ``` router bgp 65020 neighbor 10.40.40.202 remote-as 65100 description ExaBGP-Route-Injector ebgp-multihop 5 update-source MgmtEth0/RP0/CPU0/0 ! address-family ipv4 unicast route-policy EXABGP_IN in route-policy EXABGP_OUT out next-hop-self ! address-family ipv6 unicast route-policy EXABGP_IN in route-policy EXABGP_OUT out next-hop-self ! ! ! ``` ### Key config notes | Knob | Why | |------|-----| | `remote-as 65100` | ExaBGP presents as AS 65100 (eBGP to your AS 65020 mesh) | | `ebgp-multihop 5` | Host (10.40.40.202) and router (10.100.0.x) are different subnets | | `update-source MgmtEth0/RP0/CPU0/0` | Use management interface for the TCP session | | `next-hop-self` | Replace ExaBGP's next-hop (10.40.40.202) with the CORE router's loopback when reflecting into iBGP — ensures other routers can resolve the next-hop via ISIS | | `EXABGP_OUT` drops | Prevent the lab from advertising its own prefixes back to ExaBGP | --- ## Verification Commands ``` show bgp neighbors 10.40.40.202 show bgp neighbors 10.40.40.202 received routes show bgp summary show route 1.1.1.0/24 show bgp 1.1.1.0/24 ``` After loading the `internet_sample` scenario you should see ~94 new prefixes in the BGP table and they should propagate to all 9 routers via the iBGP mesh. --- ## NETCONF push (alternative to CLI) With NETCONF already enabled, you can push this config programmatically: ```bash pip install ncclient python3 - <<'EOF' from ncclient import manager ROUTERS = [ {'host': '10.100.0.100', 'description': 'CML-R9K-CORE-01'}, {'host': '10.100.0.200', 'description': 'CML-R9K-CORE-02'}, ] POLICY_XML = """ EXABGP_IN route-policy EXABGP_IN pass end-policy EXABGP_OUT route-policy EXABGP_OUT drop end-policy default 0 65020 10.40.40.202 0 65100 ExaBGP-Route-Injector 5 ipv4-unicast EXABGP_IN EXABGP_OUT true ipv6-unicast EXABGP_IN EXABGP_OUT true """ for router in ROUTERS: print(f"Configuring {router['description']} ({router['host']})...") with manager.connect( host=router['host'], port=830, username='user', password='cisco', hostkey_verify=False, device_params={'name': 'iosxr'}, ) as m: m.edit_config(target='candidate', config=POLICY_XML) m.commit() print(f" Done.") print("All routers configured.") EOF ```