This article describes a manual failover configuration for an A record, in which you need to tell NS1 when to shift traffic to a secondary IP; normally traffic will flow to a primary IP. It is easy to achieve automatic failover with NS1 as well, and we've covered that in a separate article.
The simplest way to do manual failover is just to configure a single IP address in your A record, and then change it when you need to shift traffic. But we suggest doing a little more work up front to make failover simple and quick when you need it.
First, you'll need to create an A record -- you can start by just setting the answer to your primary IP, and setting the TTL to something low like 60 seconds. A much lower TTL will be ignored by some DNS recursors; and a much higher one will limit the effectiveness of your failover. Once you've created the A record in the portal, click "Add Filter Chain" to go to the advanced configuration page.
On that page, we'll first configure a Filter Chain that will tell NS1 how to decide which answer to return:
- Click "Add Filter" and drag the Up filter into the Active Filters list; this prevents NS1 from returning any IPs that are marked "down"
- Now add the Priority filter, which tells the system to sort the answers by prioritization metadata after removing any answers that are down
- Lastly, drag the Select First N filter over to the Active Filters list and click Done. This will be set to N=1 by default. This tells the system that after sorting answers by priority, pick the highest priority IP and return only that single answer.
Next we will add the IP address for the backup server. Click "Add Answer" and enter the IP of your backup server.
- Click the Filter Data button at left to reveal the metadata associated with your Filter Chain.
- Under the primary IP's metadata section, click the pencil icon in the "up" row and set it to “true”
- Then click the edit tool in the "priority" row and set the priority of the primary IP (18.104.22.168) to 1 (note: lower numerical value indicates higher prioritization)
- Under the secondary IP's metadata section, click the pencil icon in the "up" row and set it to “true”
- Then click the edit tool in the "priority" row for the secondary IP (22.214.171.124) and set it equal to 2
- Click the Save button.
- Your record configuration should now look like this:
At this time, your record will work and will return the primary IP. When you want to fail over to the secondary IP, you just need to go to the record's page in the portal, open the primary IP's metadata, and change "Up/down" to "down" -- then click "Save Changes" at the top of the page. Your changes are immediately published to the NS1 platform and we will immediately start returning the secondary IP. To later fail back, just change "Up/down" of the primary IP back to "up" and hit Save.
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" state to the feed with your tools. Configuring this type of automatic failover setup is reviewed in this Knowledge Base article.