To get your first BGP Session up and running you will need the following ready:
-Your own ASN
-Your peers ASN (eg. your VPS providers ASN)
-Peering IPs (provided by peer usually)
-A prefix you plan to announce
For beginners we recomend bird as a BGP daemon. Bird is easy to use and features a config file like syntax.
To install bird on Debian run as root:
apt install bird
The bird config is stored in /etc/bird/bird.conf
and /etc/bird/bird6.conf
on Bird 1.6.x
Below is a simple BIRD BGP Config with one Upstream and a single Prefix announcement. You can use and adapt this example for both v4 and v4. You will need to replace the variables written in all caps with your ASNs, IPs etc.. The following examples are specific for Bird 1.6.x.
router id YOUR-ROUTER-IP;
protocol device {
scan time 10;
}
protocol kernel {
export all;
scan time 15;
}
protocol static announcement {
import all;
route YOURPREFIX reject;
}
protocol bgp upstream
{
import filter {
accept;
};
export limit 10;
export filter {
if proto ="announcement" then accept;
};
local as YOUR-ASN;
source address ROUTER-IP;
graceful restart on;
neighbor UPSTREAM-IP as UPSTREAM-ASN;
}
Useful Bird commands:
birdc configure
Configure Bird with the config set in /etc/bird/bird.conf
birdc show proto
Show the Status of the BGP protocols
birdc show route export PROTONAME
Show all routes you export to a specific upstream/peer
birdc show route 1.1.1.0/24 all
Shows all paths for 1.1.1.0/24 with details such as next-hop, communities and preference
For the IPv6 CLI on Bird 1.x use birdc6
router id ROUTER-ID;
protocol device { scan time 5; }
protocol direct { ipv4; }
protocol direct { ipv6; }
protocol static {
ipv4;
route $YOUR_V4_PREFIX reject;
}
protocol static {
ipv4;
route $YOUR_V6_PREFIX reject;
}
filter YOURASNv4 {
if (net ~ [ $YOUR_V4_PREFIX ]) then accept;
else reject;
}
filter YOURASNv6 {
if (net ~ [ $YOUR_V6_PREFIX ]) then accept;
else reject;
}
protocol bgp BGPTunnelV4 {
local 10.249.1.2 as YOURASN;
neighbor 10.249.1.1 as PEERASN;
ipv4 {
import all;
export filter YOURASNv4;
};
}
protocol bgp BGPTunnelV6 {
local 2a0c:9a40:a001::2 as YOURASN;
neighbor 2a0c:9a40:a001::1 as PEERASN;
ipv6 {
import all;
export filter YOURASNv6;
};
}