This article demonstrates the process for configuring manual failover for an A record in which you will tell NS1 when to shift traffic to a secondary IP.
Note: Alternatively, refer to this article for instructions on how to configure automatic failover.
The easiest way to set up manual failover is to configure a single IP address in your A record, and then change it when you need to shift traffic. However, we recommend doing a little more work up front to simplify the process.
First, you'll need to create an A record. You can start by setting the answer to your primary IP, and then setting a low TTL (like 60 seconds).
Note: A much lower TTL may be ignored by some DNS recursive resolvers, and a much higher one will limit the effectiveness of your failover.
Once you've created the A record in the portal, click Create Filter Chain.
Click the + next to the Up filter to add it to the chain. This prevents NS1 from returning any IPs that are marked as down.
Next, add the Priority filter which tells the system to sort the answers based on the priority metadata.
Lastly, add the Select First N filter. This filter is set to N=1 by default—telling the system to return only a single answer.
- Click Save Filter Chain.
Next, we will add the IP address for the backup server.
- Click Add Answer.
- Enter the IP address for your backup server.
- From the list of answers, click the primary IP's metadata icon (to its right), and select Edit Answer Metadata.
- In the Answer Metadata window, click Up from the menu on the left, and select Up from the drop-down menu.
- In the Answer Metadata window, select Priority tier value from the list on the left, and enter a value of 1.
- Click Save.
- From the list of answers, click the secondary IP's metadata icon, and select Edit Answer Metadata.
- Repeat steps 4 & 5—however, enter a value of 2 in the priority field.
The configuration would look like this:
At this time, your record works and will return the primary IP. When you want to failover to the secondary IP, navigate to the record's page, open the primary IP's metadata, change the up metadata to down, and then click Save. You can revert back at any time.
It is also possible to enact failover and failback through the NS1 API if you want to make your own tool (like a command line script) to quickly trigger failover or failback. One of the easiest way to do this is to configure an NS1 API Data Feed for your primary IP, and publish up/down status to the feed with your tools. Refer to this article for more information on configuring automatic failover.