How to set up iBGP session on a server

This guide explains how to configure BGP (Border Gateway Protocol) on a server connected to two switches (peers) using either BIRD or FRR — two popular BGP daemons for Linux. Both sections cover installing the daemon, writing the configuration, and verifying that both sessions are established. Follow the section for the tool you prefer; the result is equivalent either way.

Before you start, collect the following values from your hosting provider's control panel. They are required in both configurations.

ParameterDescription
<SERVER_PUBLIC_IP>Your server's default public IP address. Use the default IP - not a floating or additional one.
<ASN>Your ASN, shown as ASN in the portal.
<PEER_ASN>Your provider's ASN, shown as Peer ASN in the portal. For iBGP, both ASN numbers are the same.
<PEER1_IP>IP address of the first switch, shown as Peer1 in the portal.
<PEER2_IP>IP address of the second switch, shown as Peer2 in the portal.
<ANNOUNCED_PREFIX/MASK>The IP block you want to announce, shown as Announced network in the portal. To announce multiple networks, repeat the relevant lines for each prefix.
multihopSee the Multihop field in the portal; once it's Yes, specify the 2 value.

BIRD

BIRD is a lightweight routing daemon widely used on bare-metal servers. It uses a declarative config file and a CLI tool called birdc for runtime inspection. The configuration below creates two independent BGP sessions (one per peer) and announces your prefix through both.

Install BIRD

sudo apt install bird2

Configure BIRD

Create or edit /etc/bird/bird.conf with the following content:

router id <SERVER_PUBLIC_IP>;

protocol static announce {
    ipv4;
    route <ANNOUNCED_PREFIX/MASK> blackhole;
}

protocol bgp peer1 {
    local <SERVER_PUBLIC_IP> as <ASN>;
    neighbor <PEER1_IP> as <PEER_ASN>;
    multihop 2;
    ipv4 {
        next hop self;
        export filter {
            if net ~ [ <ANNOUNCED_PREFIX/MASK> ] then accept;
            reject;
        };
        import all;
    };
}

protocol bgp peer2 {
    local <SERVER_PUBLIC_IP> as <ASN>;
    neighbor <PEER2_IP> as <PEER_ASN>;
    multihop 2;
    ipv4 {
        next hop self;
        export filter {
            if net ~ [ <ANNOUNCED_PREFIX/MASK> ] then accept;
            reject;
        };
        import all;
    };
}

The multihop parameter is optional, remove it when unnecessary.

To announce multiple networks, add a route line for each prefix in the protocol static block and list all prefixes inside the export filter brackets, separated by commas:

protocol static announce {
    ipv4;
    route <ANNOUNCED_PREFIX/MASK> blackhole;
    route <ANNOUNCED_PREFIX2/MASK> blackhole;
}

# inside both peer1 and peer2 export filter:
        export filter {
            if net ~ [ <ANNOUNCED_PREFIX/MASK>, <ANNOUNCED_PREFIX2/MASK> ] then accept;
            reject;
        };
        import all;
    };

Start BIRD

sudo systemctl enable bird
sudo systemctl start bird

Verify the sessions

sudo birdc show protocols                  # both peer1 and peer2 should show "Established"
sudo birdc show route                      # all routes received from both peers
sudo birdc show route export peer1         # routes being announced to peer1
sudo birdc show route export peer2         # routes being announced to peer2

A healthy session shows BGP state: Established. If a session shows Active, check that <PEER1_IP> or <PEER2_IP> is correct and that BGP is enabled on the provider side. If the IPs are correct but the session stays Active, run traceroute <PEER1_IP>, count the hops, and set multihop to that number.

FRR

FRR (FRRouting) is a full-featured routing suite that uses a Cisco-like CLI called vtysh. It is a common alternative to BIRD and supports the same dual-peer iBGP setup. The configuration is applied interactively through the CLI rather than by editing a file directly.

Install FRR

sudo apt install frr

After installing, enable the BGP daemon by editing /etc/frr/daemons and setting:

bgpd=yes

Then restart the service:

sudo systemctl restart frr

Configure FRR

Open the FRR CLI:

sudo vtysh

Enter the following configuration:

configure terminal
ip route <ANNOUNCED_PREFIX/MASK> blackhole
!
router bgp <ASN>
 bgp router-id <SERVER_PUBLIC_IP>
 neighbor <PEER1_IP> remote-as <PEER_ASN>
 neighbor <PEER1_IP> description peer1
 neighbor <PEER1_IP> update-source <SERVER_PUBLIC_IP>
 neighbor <PEER1_IP> ebgp-multihop 2
 neighbor <PEER2_IP> remote-as <PEER_ASN>
 neighbor <PEER2_IP> description peer2
 neighbor <PEER2_IP> update-source <SERVER_PUBLIC_IP>
 neighbor <PEER2_IP> ebgp-multihop 2
 !
 address-family ipv4 unicast
  network <ANNOUNCED_PREFIX/MASK>
  neighbor <PEER1_IP> next-hop-self
  neighbor <PEER2_IP> next-hop-self
 exit-address-family
exit
!

The multihop parameter is optional, remove it when unnecessary.

To announce multiple networks, add a blackhole and a network line for each prefix inside the address-family ipv4 unicast block:

ip route <ANNOUNCED_PREFIX/MASK> blackhole
ip route <ANNOUNCED_PREFIX2/MASK> blackhole

...

 address-family ipv4 unicast
  network <ANNOUNCED_PREFIX/MASK>
  network <ANNOUNCED_PREFIX2/MASK>
  neighbor <PEER1_IP> next-hop-self
  neighbor <PEER2_IP> next-hop-self
 exit-address-family

Save the configuration:

write memory

Verify the sessions

sudo vtysh -c "show bgp summary"                                      # both peers should show "Established"
sudo vtysh -c "show ip route bgp"                                     # routes learned via BGP
sudo vtysh -c "show bgp neighbors <PEER1_IP> advertised-routes"       # routes being announced to peer1
sudo vtysh -c "show bgp neighbors <PEER2_IP> advertised-routes"       # routes being announced to peer2

A healthy session shows state Established in the summary output. If a peer shows Active, verify the peer IP and ASN values and confirm BGP is enabled in the provider portal. If the session still stays Active, run traceroute <PEER1_IP>, count the hops, and update ebgp-multihop to that value.

On this page