This article describes an automatic failover configuration for an A record, in which NS1 is configured to automatically shift traffic to a secondary IP (which normally receives no traffic) upon detecting a failure of your primary IP. For a guide to configuring simple manual failover, read this Knowledge Base article.
Please note that the same guide can be used for CNAME and other record types compatible with a failover configuration.
Configure an Integration
If you’re using NS1's built-in monitoring, then navigate to the Monitoring tab and follow the guides for creating Ping or TCP monitors.
Alternatively, NS1 has pre-configured integrations with the following 3rd-party monitoring services:
- Amazon CloudWatch
- Rackspace Cloud Monitoring
For this example we'll use NS1's native API service:
- Navigate to the Integrations tab
- In the "Supported Services" section select NS1 API.
- Create an Incoming Datafeed and enter a name for the feed that you will be able to easily identify when connecting to record metadata. Choose a Label for your feed that will be used as an identifier in the API call. (Note: this field does not allow spaces.)
- Click Create Datafeed from nsone_v1, which will send you to the Incoming screen, where you will see this new feed now lives.
Create an A record
- Click on the Zones tab and select the Zone you will be working under.
- Click on the Add Record button.
- Enter the domain (e.g. abc.example.web)
- Select the record type as A
- Enter your desired TTL.
- Set the Answers for this record
- Click on the Save Changes button
Preparing the record for failover
- Once you've created the A record in the portal, click on the drop-down menu in the top right corner of the record and click "Add Filter Chain"
- Click "Add Filter" and drag the "Up" filter from the Telemetry and Healthchecks section over to Active Filters. This prevents NS1 from returning any IPs that are marked down.
- Click into the Traffic Management section and drag the Priority filter into your newly created Filter Chain. This tells the system to sort the answers by priority (after executing "UP" to remove any answers that are down). Also drag over the Select First N filter, which will be set to N=1 by default. This tells the system that after sorting by priority, return ONLY the answer with the highest priority associated. Click Done.
Adding the secondary IP and setting Answer priority
Now that we have added both servers’ IP’s into the A record config, we need to set up/down state and a priority value for both servers:
- 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 plug icon in the "up" row and connect your primary monitor or data feed (we'll use NS1 native monitoring for this example)
- Then click the edit tool in the "priority" row and set the priority of the primary IP (188.8.131.52) to 1 (note: lower numerical value indicates higher prioritization)
- Under the secondary IP's metadata section, click the plug icon and connect your secondary monitor or data feed.
- Then click the edit tool in the "priority" row for the secondary IP (184.108.40.206) and set it equal to 2
- Click the Save button.
- Your record configuration should now look like this:
You're done! At this point, if the monitor on your primary server trips, the corresponding answer will be updated to up status of "false" in the NS1 platform immediately.
If you have other DNS records serviced by the same servers, you can reuse the same Data Feeds in those records too. Updates to a Data Feed will automatically be pushed to every connected answer throughout our system.
Assuming you want to automate "failback" (shifting traffic back to your primary server once it returns to a healthy state), make sure your monitoring service is configured to notify NS1 when your monitors return to an "up" state. Please note that this is the default setting for NS1 monitors.
To enable this if you are using NS1's monitoring;
- Click on the Monitors tab
- Select the monitoring job attributed to your primary server’s IP address. You will be taken to the monitoring job details page
- Click "Toggle advanced options"
- Make sure “Notify Failback” is checked
- Click “Save”
If you want to do manual failback, make sure your monitoring service doesn't notify NS1 on return to an "up" state; to failback to your primary, just visit your record page and manually change the "Up/down" state of the primary back to "up".