Skip to content
Fixedmark

Networking · 11 min read

Updated

Static IP Pairs and Failover: How Two IPs Stay Up

One static IP is only as available as the single host or gateway it is attached to, and a partner allowlist cannot be changed fast enough to route around an outage. Run two addresses on two hosts that fail separately, let each host take over the other's address, have partners allowlist both, and make clients retry safe calls after the reset that failover causes.

On this page

Why one static IP is a single point of failure

A static IP never fails on its own. What fails is the thing it is attached to, such as a VM, a network interface, or a NAT gateway in one building. When that goes down, every packet from the address stops, and every allowlist that trusts it now trusts nothing.

Common ways a single egress IP goes dark:

  • The host fails, or the provider reboots it for maintenance.
  • You redeploy the VM and forget the address is tied to it.
  • The zone or data center holding the gateway has an outage.
  • The proxy or NAT process on the host crashes while the VM stays up, so health checks on the VM pass and traffic still fails.
  • The host runs out of ports or bandwidth under a burst.

AWS states the zone case plainly for its own NAT gateways. Each NAT gateway lives in one Availability Zone, and if that zone is down, resources in other zones that share it lose internet access. The fix AWS gives is one NAT gateway per zone. Each of those has its own Elastic IP, so a three-zone setup gives a partner three addresses to allowlist. The cost side of that design is in NAT gateway hidden costs.

The real problem is the allowlist on the other side. You can launch a new VM with a new address in two minutes. A bank, a broker, or a partner's security team may take days to add it. Some brokers allow one change per week. So the address you registered has to keep working through any single failure, because you cannot swap it in an emergency.

Move the address, or run two

There are two basic ways to keep an allowlisted address alive. You can move one address between hosts. Or you can run two addresses on two hosts and have partners trust both. A pair done well uses both ideas at once.

Ways to make egress survive a host failure
PatternPartner allowlistsOn failureWeak spot
One floating IP, active and standby1 addressThe standby claims the addressThe standby path is idle, so nothing proves it works until you need it
Two IPs, both active, no takeover2 addressesClients must stop using the dead addressHalf of new connections fail until every client notices
Two IPs, both active, each host covers the other2 addressesThe survivor claims the dead host's addressOpen connections on the dead host still drop

A floating IP is the classic answer. On a LAN, VRRP (RFC 9568) lets a backup router take over a virtual address. The backup declares the active router down after three missed advertisements plus a skew. With the default 1 second interval and a priority of 100, that is about 3.6 seconds. The new active router then sends a gratuitous ARP so switches learn where the address lives now.

On most clouds one VM cannot claim another's address with ARP alone, so the move goes through the provider instead. On AWS you remap an Elastic IP, which AWS describes as a way to mask an instance failure. Akamai Cloud (Linode) shares an IP between two instances and moves it by BGP using its lelastic tool or FRR. DigitalOcean reserved IPs reassign between Droplets in the same data center. The detection logic can still be VRRP, run by keepalived, with the takeover step replaced by an API call.

Aim for the third row. Both addresses carry traffic every day, so a partner who allowlisted only one finds out in the first hour, not during an outage. When a host dies, its address keeps working from the other host, so clients never need to pick a healthy address.

Put the pair on hosts that fail separately

Two addresses on one VM fail together. So do two VMs on one hypervisor. The pair only helps if the two hosts sit in different failure domains, and the address can only move inside the boundary your provider allows.

  • Separate physical hosts at minimum. Akamai's failover guide warns that an affinity placement group can put both instances on one host, which defeats failover, and asks for anti-affinity.
  • Separate zones where the provider supports it. An AWS Elastic IP belongs to a Region (more precisely a network border group), so it can move between instances in different zones of that Region.
  • Not across regions. AWS says an Elastic IP cannot be moved to a different Region. Linode IP sharing needs both instances in the same data center, and DigitalOcean reserved IPs stay in one data center. Region-level failover means a second pair and more allowlist entries.

Check the source address, not just the inbound one. Many floating IP products are built for traffic coming in. DigitalOcean, for example, needs you to route outbound traffic through the anchor gateway before packets leave from the reserved IP, and the change is lost on reboot unless you write it into the OS network config. Run an IP echo check from each host after every takeover.

A sketch on AWS with keepalived

Here is the shape of a two-node egress pair on EC2. Each node runs a forward proxy. Node A normally holds Elastic IP A and node B holds Elastic IP B. Each node also has a spare secondary private address on its interface for the other node's Elastic IP. keepalived runs two VRRP instances over unicast, since a plain VPC subnet does not carry multicast. Node A is active for instance A and backup for instance B. Node B mirrors it. The security groups must allow IP protocol 112 (VRRP) between the nodes.

/etc/keepalived/keepalived.conf (node A)
vrrp_script chk_proxy {
    script "/usr/bin/curl -fsS -o /dev/null http://127.0.0.1:9100/health"
    interval 2
    fall 2
    rise 2
}

vrrp_instance EGRESS_A {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    unicast_src_ip 10.0.1.10
    unicast_peer {
        10.0.2.10
    }
    track_script {
        chk_proxy
    }
    notify_master "/usr/local/bin/claim-eip.sh eipalloc-0aaaaaaaaaaaaaaaa 10.0.1.10"
}

vrrp_instance EGRESS_B {
    state BACKUP
    interface eth0
    virtual_router_id 52
    priority 100
    advert_int 1
    unicast_src_ip 10.0.1.10
    unicast_peer {
        10.0.2.10
    }
    track_script {
        chk_proxy
    }
    notify_master "/usr/local/bin/claim-eip.sh eipalloc-0bbbbbbbbbbbbbbbb 10.0.1.11"
}
/usr/local/bin/claim-eip.sh
#!/bin/sh
# Run by keepalived when this node becomes active for an instance.
# $1 is the Elastic IP allocation ID, $2 the private address on this node to map it to.
set -eu
IMDS=http://169.254.169.254/latest
TOKEN=$(curl -sX PUT "$IMDS/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
MAC=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" "$IMDS/meta-data/mac")
ENI=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
  "$IMDS/meta-data/network/interfaces/macs/$MAC/interface-id")

aws ec2 associate-address \
  --allocation-id "$1" \
  --network-interface-id "$ENI" \
  --private-ip-address "$2" \
  --allow-reassociation

The health check watches the proxy process, not just the VM, so a crashed proxy hands its address over too. associate-address moves an address that is already associated elsewhere, so the script works whether the old node is dead or only sick. The proxy must send traffic for address B from the private address 10.0.1.11, or the packets leave as address A. Every takeover drops the connections open on the old holder, so keep flapping in check with sensible fall and rise values.

This is a sketch, not a finished setup. You still need an instance role allowed to call ec2:AssociateAddress, the secondary private addresses configured in the OS, and a plan for split brain. If the nodes lose sight of each other, both may claim an address. The last API call wins, so the address always lands on a live node, but it can bounce.

What partners need to allowlist

Give every partner both addresses in one request, as single-host entries. If you send the second one later, that is the request that gets lost, and you find out the day traffic moves.

  • Send each address as a /32. Never round two addresses up to a range you do not own. A /24 that happens to cover both also admits 254 strangers.
  • Say that both addresses are in use at all times. Partners who see the words primary and secondary sometimes treat the second as a spare and skip it.
  • Ask whether they keep separate lists per environment. Bank UAT and production lists are often separate, as covered in bank API onboarding.
  • Ask for their change lead time and record it. That number decides how far ahead you must plan any future move.
  • If a form has one field, ask for a second entry rather than dropping an address. Brokers in India expose two slots for exactly this, as explained in why brokers ask for a primary and a secondary IP.

When the allowlist is yours, the same rule applies. Here are the two entries in three common places. The examples use documentation addresses from 203.0.113.0/24 and 198.51.100.0/24.

aws ec2 authorize-security-group-ingress \
  --group-id sg-0123456789abcdef0 \
  --ip-permissions 'IpProtocol=tcp,FromPort=5432,ToPort=5432,IpRanges=[{CidrIp=203.0.113.10/32,Description=egress-a},{CidrIp=198.51.100.20/32,Description=egress-b}]'

If you run a pair in two regions, the partner allowlists four addresses. That is still a short, exact list. It is far smaller than trusting a whole cloud's published ranges, which admits every other tenant.

What your client sees during failover

Moving an address does not move the connections that were using it. TCP state lives in the kernel of the host that died. The new holder of the address has never heard of those connections. Under RFC 9293, a segment that arrives for a connection that does not exist gets a reset. So the sequence your client sees has three phases.

  1. Silence. The host is dead and the address has not moved yet. Packets go nowhere. A client with no timeout waits forever.
  2. Resets. The address now lives on the survivor. Any packet on an old connection gets an RST back, and the client reports ECONNRESET or a broken pipe.
  3. Recovery. New connections open normally from the moved address. The partner sees the same source IP as before.

The length of the silent phase is detection time plus move time. Detection is under your control, such as the 3.6 seconds of default VRRP timing above. The move time depends on your provider's API or BGP convergence. Measure it on your own setup rather than trusting a number from a blog post, including this one.

Through a proxy there is a second layer. The client reaches the proxy by host name. A good setup removes a dead node from DNS, but resolvers cache records until the TTL expires, so clients that try the next address on a failed connect recover faster.

Connection pools hold the risk for longer. A pooled connection that went through the dead node looks fine until you write to it. Database pools need a check before use, or a retry on reset. Pool settings through a proxy are covered in database connections through SOCKS5.

Make clients retry the right calls

Failover becomes a non-event when clients time out instead of hanging, retry calls that are safe to repeat, and make unsafe calls safe first.

RFC 9110 defines PUT, DELETE, and the safe methods (GET, HEAD, OPTIONS, TRACE) as idempotent. It says a client should not automatically retry a non-idempotent request unless it knows the request is idempotent or can tell the original was never applied. That matters because a reset can come after the request was sent. A payout POST may have gone through and only the reply was lost.

The split that libraries make follows that rule. A failure to connect means the server never got the request, so any method is safe to retry. A failure after sending is safe to retry only for idempotent methods, or for writes that carry an idempotency key the server honours. Stripe takes an Idempotency-Key header on POST requests. RazorpayX takes X-Payout-Idempotency on Create Payout and its composite APIs, and the retry must send the same key and the same body.

# pip install requests  (urllib3 2.x for backoff_jitter)
import os
import time
import uuid

import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry

PROXY = os.environ["FIXEDMARK_PROXY_URL"]

retry = Retry(
    total=5,
    connect=3,  # failed before sending: retried for every method
    read=2,     # failed after sending: retried only for allowed_methods
    status=2,
    allowed_methods=Retry.DEFAULT_ALLOWED_METHODS,  # GET, PUT, DELETE...; not POST
    status_forcelist=(502, 503, 504),
    backoff_factor=0.5,
    backoff_jitter=0.3,
)

session = requests.Session()
session.trust_env = False  # ignore HTTPS_PROXY; use only the proxy below
session.proxies = {"http": PROXY, "https": PROXY}
session.mount("https://", HTTPAdapter(max_retries=retry))

TIMEOUT = (3.05, 15)  # (connect, read) seconds, so a dead path never hangs

# Reads retry on their own.
status = session.get("https://api.partner.example/v1/status", timeout=TIMEOUT)

# Writes reuse one key, so a retry after an unclear failure is safe.
key = str(uuid.uuid4())
for attempt in range(3):
    try:
        res = session.post(
            "https://api.partner.example/v1/payouts",
            json={"amount": 5000, "currency": "INR"},
            headers={"Idempotency-Key": key},
            timeout=TIMEOUT,
        )
        break
    except (requests.ConnectionError, requests.Timeout):
        if attempt == 2:
            raise
        time.sleep(0.5 * 2**attempt)

In urllib3, the Retry class counts connection errors and read errors separately. Connection errors are retried for any method. Read errors are retried only for allowed_methods, which by default leaves out POST. That is why the Python sample loops on the POST by hand, with the key held constant. In undici, the RetryHandler default methods also leave out POST. The Node sample opts POST in on a separate agent so reads and writes keep different rules. It uses request() with a string body, which undici can replay on a retry.

If the API you call has no idempotency key, do not retry writes blindly after a reset. Look the operation up by your own reference first, then decide. The primary and secondary broker IP post walks through that pattern for orders.

Test failover before you need it

A pair you have never failed over is a guess. Test in staging, then once in production at a quiet hour.

  1. 1
    Prove both addresses are liveSend twenty new connections through your egress to an IP echo service and count the answers. With an active pair, both addresses should appear. Then make one real call to the partner from each address.
  2. 2
    Start steady trafficRun a loop that makes one request per second and logs the time, the status, and the source IP the echo service reports.
  3. 3
    Kill one node hardStop the instance or drop its network, rather than stopping the proxy cleanly. A clean shutdown closes connections politely and hides the silent phase.
  4. 4
    Read the logNote when errors start, when the moved address answers again, and whether any request failed after the retries. That gap is your real failover time.
  5. 5
    Bring the node backWatch the address return, or stay put if you disabled preemption. Either is fine if it is what you expect.
Terminal
# Count the source addresses across new connections.
for i in $(seq 1 20); do
  curl -s --proxy "$FIXEDMARK_PROXY_URL" https://fixedmark.com/api/ip
done | sort | uniq -c

# During the test: one request per second, with time and source IP.
while true; do
  printf '%s ' "$(date +%T)"
  curl -s --max-time 5 --proxy "$FIXEDMARK_PROXY_URL" https://fixedmark.com/api/ip || echo FAIL
  sleep 1
done

Each curl run opens a new connection. Your app may reuse pooled connections, which fail differently, so repeat the test with your real client. Check against the partner too, because the echo service accepts any address and the partner does not. On a managed service you cannot kill a node yourself. The first loop still proves both addresses are in use, which is the part partners depend on.

Doing this with Fixedmark

Fixedmark runs this pattern as a service. Each region runs at least two proxy nodes. Your app gets a pair of static IPv4 addresses, one primary on each node, and each new connection leaves from one of them. When a node fails, the other node takes over its address. When Fixedmark replaces a node, the address moves to the new one, because addresses are tracked separately from servers. The details are in IP pairs and high availability.

The client-side rules above still apply. Allowlist both addresses, because traffic is spread across the pair. Expect resets on connections that were open on a failed node, and let retries and pools recover. To see both addresses yourself, follow verify your egress IP.

A pair lives in one region and cannot move to another. Plans with two regions give you a pair in each, so partners allowlist four addresses. Automatic failover across regions is on the roadmap, not built. Starter and the trial use a shared pair. Pro and higher plans get a dedicated pair, which is what you want when the allowlist is a security control.

Fixedmark is in early access and not generally available. Planned prices start at $29 per month for a dedicated pair on Pro. See pricing and regions, including Mumbai for Indian banks and brokers.

Sources

Checked November 2026. Confirm current details on the vendor's site before you decide. Prices and limits change.

Blog

Frequently asked questions

Do I need two static IPs for high availability?

You need two hosts that fail separately. One floating address that moves between them works, but the standby path sits idle and untested. Two active addresses, where each host can take over the other's, keep both paths proven every day.

Should the partner allowlist both IPs if only one is primary?

Yes. In an active pair both carry traffic, and in any pair a failover or a change can move traffic to the other one. An allowlist with one address either fails part of the time or fails at the worst moment.

Do open connections survive an IP failover?

No. TCP state stays on the host that failed. The new holder of the address answers old connections with a reset, so clients must reconnect. New connections leave from the same address as before.

Is it safe to retry a POST after a connection reset?

Only if the API supports an idempotency key and you resend the same key and body, or if you can confirm the first attempt was never applied. A reset after sending does not tell you whether the server acted.

Make it fixed.

Fixedmark is in early access. Join the list to get dedicated static IPs when your region opens.