First at all:
I am new to BGP and the Bird internet routing daemon.


ISP1 - R1 - SW1 - R3
ISP2 - R2 - SW2 - R4

I have an eBGP instance for R1 and ISP1 and the same between R2 and ISP2. And also I have an iBGP Instance for R1 and R2 on both Routers.

Heres my sample config from R1 for iBGP:

protocol bgp bgp1 {
        local as 200000;                
        neighbor as 200000; 
        multihop 1;                     
        keepalive time 5;                            
        source address;

And heres my sample config from R2 for iBGP:

protocol bgp bgp1 {
        local as 200000;                
        neighbor as 200000; 
        multihop 1;                     
        keepalive time 5;                            
        source address;

Furthermore I have a keepalived cluster between R1 and R2 wich is the
default-gateway for R3 and R4.
Now, what if the link from R1 to ISP1 goes down? The Cluster wont change and
I don't have any connection to the internet.

I want to let the traffic flow even if this happens.My idea was to let
R1 send the whole traffic to R2 so that R2 sends it to the Internet.
My questions now are:
1) What is the best way to do this with Bird and iBGP?
2) Are there other and even better mechanisms?


  • I see the same setup I like to achieve, it's a nice post. For the most parts I understand everything but for the final routing to R3 + R4 I don't see how to route prefixes to them. Could you give an example how to setup the iBGP config to them? Kind regards, Richard
    – richard
    Commented Sep 5, 2017 at 11:50
  • R3 and R4 form a cluster, too. Same with R1 and R2. So if you want to send smth to the subnet below R3 and R4 you need to send it to their cluster IP. EGP or IGP aren't needed here. Commented Sep 6, 2017 at 13:32

2 Answers 2


I found the answer by myself:
If you want to create a failover between two Routers with the
bird internet routing daemon you need to follow the next steps:

1. Every router must be connected to an ISP: means 1 Router to 1 ISP
2. Form peers (BGP neighbor, eBGP) between your AS and the ISPs' AS
3. Form a peer (iBGP) between both of your Routers
4. Add a preference (highest preference wins)

Here's an example config:

# example ID, change at R2, e.g.
router id; 
debug protocols all;

# filtering routes
function avoid_martians() 
prefix set martians; 
martians = [,,,, ];

  # Avoid RFC1918 and similar networks   
  if net ~ martians then return false;

  return true; 

filter bgp_in {
        if ! (avoid_martians())
                then reject;

# tell BGP about your routes to your systems
# change to at R2
protocol static {
        route via; 

protocol kernel {
        scan time 20;
        import filter bgp_in;
        export all; 

protocol device {
        scan time 10; 

protocol bgp iBGP_INSTANCE {
        local as 500000;                # local AS
        neighbor as 500000; # iBGP peering to R2, change to at R2 
        keepalive time 5;               # keepalive timer
        graceful restart;                    
        import filter bgp_in;
        export all;
        preference 150;                 # highest preference "wins", 100 at R2
        gateway direct; 

protocol bgp eBGP_INSTANCE {
        local as 500000;                
        neighbor as 102;      # eBGP peering to ISP1, change at R2
        keepalive time 5;               
        graceful restart;               
        import filter bgp_in;
        export all;
        hold time 10;
        preference 150;                # highest preference "wins", 100 at R2

The config above creates two BGP instances.
One for the internal BGP (same AS as the other Router) and one external BGP (an other AS as the other Router).

As I commented in the config, the Router with the highest preference will be the "Master Router". The traffic now flows through R1 to ISP1.
But what if R1 doesn't get any update and/or keepalive message from the ISP?

The answer is simple:
R1 doesn't get any update from ISP1. Means, there is no route to the destination.
Now that R1 and R2 has formed a peer (iBGP), R1 gets updates from R2.
This means now that R1 has to send every traffic from below to R2 who sends it to the ISP2.

//edit: corrected typos


You can try to propagate the default route via OSPF - or -

if you send via iBGP to the second router all the routes advertised by the ISP, the packets will use the other router to route internet traffic in case the link on the primary router fails.


R1 routing table, with ISP1 up: via ISP1 metric 100 via R2 metric 200

R2 routing table, with ISP2 up: via ISP2 metric 100 via R1 metric 200

in case of ISP1 failure, R1 routing table will be: via R2 metric 200

and so the packets will be routed to R2.

remember to establish iBGP peering on a loopback address and set next-hop-self.

  • I have done this now. R1+R2 have the same entrys in their routing tables as u told me. Furthermore I have established iBGP peering on a loopback address and I used next-hop-self. Then I tried the configuration and R1 still wants to forward the packet to ISP1. There is no forwarding to R2 with this config. Commented Sep 22, 2015 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.