Just need help with a small routing problem. So I have a route being learnt on a router via BGP.
Lets assume it is 172.16.100.0/24 via next hop 192.168.254.1.
Now, the gateway 192.168.254.1 is also being learnt as a summary route via BGP from the same neighbor.
In the routing table however, the route does not pick up the correct gateway and instead all traffic is routed via default route.
How can I resolve this? I assume this is because BGP does not use next hop if it is being learnt via BGP itself?
Thanks in advance.
in general, the more specific route gets chosen. That said, post the configs of both BGP neighbors so we can get a better picture of what is going on...
Is this EBGP or IBGP.
If it is EBGP then usually the next hop is the neighbor IP on a directly connected subnet or if you are using loopbacks then you add a static route just for that loopback so the neighborship can be formed.
If it is IBGP then you can use the next-hop-self command.
The BGP summary route should be used to resolve the BGP next hop. Can you post the output for "show bgp ipv4 uni 172.16.100.0 255.255.255.0".
It has to do with BGP next-hop validation:
- if your BGP neighbor is directly attached (192.168.254.1) both received routes (172.16.100.0/24 and summary for 192.168.254.1) will have a next-hop of 192.168.254.1; before BGP pushes both prefixes to the RIB, it needs to validate next-hop by matching on a non-default route in the RIB (which it finds as next-hop is connected), in which case both prefixes will be sent to the RIB and show up as BGP routes (unless you learn it from another protocol with a lower AD as well, which wins the RIB election; you should see this with "show bgp ipv4 unicast rib-failure").
- if your BGP neighbor is non directly attached (192.168.254.1) both received routes (172.16.100.0/24 and summary for 192.168.254.1) will have a next-hop of 192.168.254.1; before BGP pushes both prefixes to the RIB, it needs to validate next-hop by matching on a non-default route in the RIB, and it's not gonna match because it is not directly connected and you only have a default route in the RIB; BGP next-ho validation fails, thus prefixes are NOT sent to the RIB, thus don't show up in the RIB, thus all packets follow the default route, your only route in the RIB. To fix it, configure a static route for 192.168.254.1/32 and you'll see both BGP prefixes showing up in the RIB. Before doing the change, you could see that next-hop is inaccessible by issuing "show bgp ipv4 unicast 172.16.100.0