Bird BGP Metric Distance Configuration

bgproutingtunnel

In my lab I have two routers which are connected to different ISPs.
They're not directly connected via a wire, but they're connected via a tunnel.

Through that tunnel I used to create an iBGP peer and they exchange routes.

Now, router A sends a better route to router B which now installs it into its routing table.

Now Router B is "able" to reach everything through the tunnel via Router A.

The above scenario describes my problem and I thought the solution was to check incoming routes which come from the neighbor router in the same AS and add a higher distance so that existed routes won't change.

Is that even a good solution? If yes, how am I able to do that?

Here's my filter configuration so far, but, unfortunately, it doesn't work properly:

import filter {
   if bgp_path ~ [= AS_NUMBER =] then
       {
             bgp_path.prepend(AS_NUMBER);
             bgp_path.prepend(AS_NUMBER);
             bgp_path.prepend(AS_NUMBER);
             bgp_path.prepend(AS_NUMBER);
             bgp_path.prepend(AS_NUMBER);
             bgp_path.prepend(AS_NUMBER);
             bgp_path.prepend(AS_NUMBER);
             accept;
           }
         reject;
 };

But the problem seems to be more complicated:

I need to adjust a preference on both iBGP routers.

E.g. router A has a higher preference than router B, router B will send send everything through router A.

Either my settings are wrong, or performing an iBGP peer through a tunnel is more than wrong.

Best Answer

You problem seems to be related to the iBGP rule that iBGP routers will not advertise a route learned from another iBGP speaker. The problem is that iBGP will not change the AS_PATH, and this creates the problem of routing loops. To avoid routing loops, iBGP speaker will not advertise to any other iBGP speakers prefixes learned through iBGP. That is why iBGP requires a full-mesh (every iBGP speaker must have a connection to every other iBGP speaker) or a mitigation such as route reflectors or confederations.

If you are trying to advertise, through the tunnel, prefixes learned from another iBGP speaker, that will not work. You need to either use eBGP through the tunnel, or set up the routers at the tunnel ends as route reflectors or separate confederations. The route reflectors must have a connection to every router for which it is a route reflector, or confederations must have a full-mesh of iBGP speakers.

The methods used to modify routing for eBGP, such as AS_PATH prepending or changing the metric (MED), are for eBGP, not iBGP.