BGP – Bird2 minimal configuration

BGP

Below are minimalist BGP configuration examples using Bird 2, tailored for announcing prefixes via a Servperso VPS or tunnel. These examples are ideal for those looking to configure BGP sessions and announce IP blocks securely.

You must replace the relevant information with your actual network details in the configuration below:

Router ID: This is usually your VPS’s public IP address. It uniquely identifies your router in the BGP topology.

Local AS: Use your allocated ASN (either private or public).

filter_to_upstream: This filter defines which prefixes you’re allowed to announce. Only insert your assigned IPv4 and IPv6 blocks here. This is crucial to prevent BGP route leaks and to avoid getting your session suspended by your upstream provider.

protocol static: This section defines which prefixes are inserted into Bird’s routing table to be advertised. It’s mandatory when used with filter_to_upstream to ensure proper BGP propagation over the internet.

If you don’t own servperso or vps, we highly recomend you to order one first

Order BGP VPS

Order BGP tunnel

Full Table (Multiple Peers)

Receiving a full BGP table is useful when you peer with multiple providers. It allows your kernel to access the global routing table (~900k IPv4 and ~200k IPv6 entries). However, this setup requires significantly more CPU and memory.

Servperso also allows switching your session from full-table mode to default-route mode upon request via a support ticket.

# Define your router ID, usually your VPS IP
router id 194.28.99.12;

# Inject received BGP routes into the Linux kernel
protocol kernel krnv4 {
        scan time 60;
        ipv4 {
                import none;
                export all;
        };
}

protocol kernel krnv6 {
        scan time 60;
        ipv6 {
                import none;
                export all;
        };
}

# Static announcements to the global BGP table
protocol static announce_ipv4 {
        ipv4;
        route 192.0.2.0/24 unreachable;
}

protocol static announce_ipv6 {
        ipv6;
        route 2a0c:b641::/44 unreachable;
}

# Filter to only announce your assigned prefixes
filter filter_to_upstream {
        if (net.type = NET_IP4 && net ~ [ 192.0.2.0/24 ]) then accept;
        if (net.type = NET_IP6 && net ~ [ 2a0c:b641::/44 ]) then accept;
        reject;
};

# IPv4 BGP session with Servperso
protocol bgp BGP_Servperso_V4 {
        local as 65535;
        neighbor 194.28.99.254 as 34872;
        ipv4 {
                import all;
                export filter filter_to_upstream;
        };
}

# IPv6 BGP session with Servperso
protocol bgp BGP_Servperso_V6 {
        local as 65535;
        neighbor 2a0c:b640:10::3:ffff as 34872;
        ipv6 {
                import all;
                export filter filter_to_upstream;
        };
}

Default Route Configuration

The default route mode is ideal if you don’t need the full BGP table. It’s suitable for low-resource virtual machines or ASN setups with a single upstream peer. In this setup, there’s no need to import peer routes or export them to the kernel.

# Define your router ID
router id 194.28.99.12;

# Static route advertisements
protocol static announce_ipv4 {
        ipv4;
        route 192.0.2.0/24 unreachable;
}

protocol static announce_ipv6 {
        ipv6;
        route 2a0c:b641::/44 unreachable;
}

# Prefix filter to avoid BGP leaks
filter filter_to_upstream {
        if (net.type = NET_IP4 && net ~ [ 192.0.2.0/24 ]) then accept;
        if (net.type = NET_IP6 && net ~ [ 2a0c:b641::/44 ]) then accept;
        reject;
};

# BGP sessions with upstream
protocol bgp BGP_Servperso_V4 {
        local as 65535;
        neighbor 194.28.99.254 as 34872;
        ipv4 {
                import none;
                export filter filter_to_upstream;
        };
}

protocol bgp BGP_Servperso_V6 {
        local as 65535;
        neighbor 2a0c:b640:10::3:ffff as 34872;
        ipv6 {
                import none;
                export filter filter_to_upstream;
        };
}

Looking to get started with BGP on your VPS using Bird2? These examples cover both full and default route setups, ensuring your prefixes are safely and properly announced. Feel free to adapt them to your network!

Use the command line to troubleshoot

Bird has an internal command line. You can access it by using birdc command.

show protocol all BGP_Servperso_V4 : show the full protocol detail (route exported, imported, session state, …)

show route export BGP_Servperso_V4: Show route you send out on BGP_Servperso_V4 session.

show protocols : show the full protocol list.

Servperso also prupose a few tools to diagnose we receive your route well. You can access that documentation by clicking this link.

Posted in BGP