
By combining Border Gateway Protocol (BGP) and Vultr's Reserved IP feature, you can create a Floating IP that provides high availability for your application by automatically redirecting traffic among available instances. This guide explains how to configure a Floating IP using BIRD, a popular routing daemon.
This guide uses example values. Please replace them with your information.
Look for your instance IP address and BGP AS number on the Vultr Console server information page, and the reserved IP on the Network Reserved IP page.
All Vultr VPS cloud server instances use these BGP values:
If you use Vultr Bare Metal, please use these values:
You can ensure high availability for your site by using multiple VPS instances with the same BGP configuration. When an instance is unavailable, BGP anycast dynamically makes a one-of-many selection and redirects traffic to an available instance. This routing strategy allows a high number of instances with the same configuration to share a single reserved IP as a floating address. BGP anycast routes traffic from the reserved address to a single instance at any given time. The reserved address, and all available instances, must be in the same location.
BGP anycast distributes traffic with an Equal-Cost Multi-Path (ECMP) routing strategy. ECMP routing means that traffic will be randomly distributed between any instances in the same location announcing an IP address.
To follow the steps in this guide:
The steps below explain how to set up a single instance. To achieve high availability, repeat these steps on two or more instances, using the corresponding IP address for each instance.
SSH to the instance as root.
Create a dummy network interface.
Bring the interface up.
Bind the dummy interface to the Reserved IP address. Replace the example 192.0.2.2 with your reserved IP.
Confirm the network configuration.
Verify your firewall permits traffic on TCP port 179.
In a web browser, navigate to the Vultr Console and locate the server information page for your instance.
Click the BGP tab.
Look for the link at the bottom of the page:
Click the BGP configuration link. Refer to this example configuration for the next few steps.
Install BIRD. This guide uses BIRD version 1.6.8.
Edit your BIRD configuration. On Ubuntu, the BIRD configuration file is /etc/bird/bird.conf.
On a new installation, the configuration file looks like this:
Edit the router id line to match the IP address in your instance BGP example.
Add this section to the bottom of the file.
Add the protocol bgp vultr block from your instance BGP example to the bottom of the file. When finished, your file should look like this. Substitute your values for router id, local as, source address, and password.
👋 If you use Bare Metal, replace the
neighborline with the Bare Metal values in the Example Values section.
With this configuration, BIRD looks for the dummy1 interface and advertises its IP to Vultr's infrastructure via BGP. As soon as your instance is running, it receives traffic. If it crashes, traffic will stop.
Start the BIRD service.
Wait a few seconds. Check that the BGP session is established.
If everything is working, you'll see Established next to the BGP state.
If there are configuration issues, you may see an error such as:
/var/log/bird.Verify BIRD is advertising the route to your floating IP.
Open two terminal sessions. We'll call the session connected to the server the SSH session and a second session at your local workstation the Local session.
In the Local session, ping the Reserved IP address. You should see replies.
In SSH session, take the dummy interface down. Repeat this step on all instances.
You'll see the pings begin to fail in the Local session.
In the SSH session, check the route again.
BIRD notices that the interface has disappeared and withdraws the route. Repeat this command on all instances to verify.
In the SSH session, enable the dummy1 interface on one instance only.
Notice that the pings resume in the Local session.
Disable the dummy1 interface on the selected instance again. You'll see the pings begin to fail in the Local session again.
Repeat these steps on each instance in turn. You'll see the pings on the floating IP resume as each instance becomes available. Repeat your tests until you are satisfied the floating IP is performing as desired.
You can use BGP prepends to assign preferential traffic ordering if you want to control traffic distribution to your instances. Assume there are three instances:
Configure three instances as previously described.
Edit the BIRD configuration on the First Backup instance.
Insert the following block inside the protocol bgp vultr section. Replace the example AS number 65500 with your AS number.
For reference, the full example looks like this:
On the Second Backup instance, add a similar section, with two bgp_path.prepend lines, like this:
In normal operation, all traffic goes to the Primary instance. In case of failure, BGP directs traffic to the First Backup. If both of these are down, BGP directs floating IP traffic to the Second Backup. You can extend this method to more instances by adding additional bgp_path.prepend lines on lower-priority backup instances.
This process also works with IPv6 reserved subnets. In general, the process for IPv6 is similar to IPv4. You can follow the process described above with a few changes:
bird6 for birdbirdc6 for birdc.All instance types at Vultr use 2001:19f0:ffff::1 as the neighbor IPv6 address. Use the AS number 64515 for all instances except for Bare Metal, which uses 20473.
An abbreviated example is shown below that uses two IPv6 addresses from a reserved /64 subnet. The example values are:
👋 Note: The instance must have a public IPv6 subnet and address assigned for Floating IPv6 BGP to work.
Create a dummy network interface.
Bring the interface up.
Bind the dummy interface to one or more IPv6 addresses in the Reserved IP /64 subnet. Use our IPv6 Calculator to see the range of usable IP addresses. You can assign as many IPv6 addresses within the Reserved /64 subnet as you need. This example configures two addresses.
Verify the interface:
Create a /etc/bird/bird.conf file:
👋 If you use Bare Metal, replace the
neighborline with the Bare Metal values:
Start the Bird6 process.
Check the Bird6 console.
Use ping6 from your local workstation to test connectivity on the two IPv6 addresses.
It may take up to 20 minutes for Vultr's network to pick up the IPv6 routes.
If you use FreeBSD 12 or 13 instead of Linux, you may need to load the tcpmd5 kernel module by adding this line to /boot/loader.conf.
Note: loader.conf is only read at boot. If you'd like to test the configuration, you can load it immediately with:
Older versions may need to recompile the kernel for TCP MD5 signature support. Those instructions are outside of the scope of this article.
If your BSD kernel does not support TCP MD5 signatures, you will see the following output in the BIRD log.
The BIRD configuration file is located at /usr/local/etc/bird.conf on BSD.
The Vultr API offers several endpoints to manage reserved IPs.
0 Comments
Be the first to comment and share your perspective with the community.