Platform Engineering · Lesson 159

Hybrid Cloud: Connecting On-Premises and Cloud with Shared Networking, DNS, Identity, and Operations

Most organisations that use the cloud still run systems in their own data centres, and a hybrid cloud joins the two so that workloads on either side can call each other privately and be run as one estate. That takes a non-overlapping IP plan, a dedicated interconnect with a VPN as backup and routing that fails over the same way in both directions, DNS that forwards each private zone to the side that owns it, workload identity federation instead of stored keys, and one inventory, policy, and monitoring view across both sides. This lesson follows one request from an on-premises service to a cloud storage account behind a private endpoint, and shows two failures: DNS that resolves the public address, and a failover that sends replies back by a different route.

Difficulty: Advanced · Know this first: Lesson 158, Lesson 152

What you will learn

By the end of this lesson you can work at four levels:

This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.

Run it as:

When it breaks, I check

One thing to remember

Where the time goes

This bar adds up milliseconds for one request from the on-premises service to the cloud storage account and back. It is a worked example, not a measurement. The DNS and routing hops decide whether the request takes the private path, and whether the reply comes back the same way.

Try it: does your hybrid request take the private path, both ways?

Pick the on-premises DNS setup, the link in use, and how the backup is designed.

privatepath
18 msnetwork round trip
about 1 soutage during failover

Check yourself

Three questions. No score is saved anywhere — this is just you against the material.

Basic to master

Hybrid cloud grows in four levels: a working link, private names and paths, resilience you have tested, and one estate.

Basic — A working link

At the basic level the two sides can reach each other.

  • An inventory of flows between the sites.
  • An address plan with no overlaps between on premises and every cloud network.
  • A site-to-site VPN or an interconnect with BGP.

Where it breaks: a cloud network created with a range already used on premises, which can never be routed to.

Try it: Basic

A team wants a new cloud network using 10.10.0.0/16, which the data centre already uses. What do you say?

Now do it: Check your cloud networks against your on-premises ranges.

Intermediate — Private names and paths

At the intermediate level traffic stays private, by name.

  • Conditional forwarders in both directions for every private zone.
  • Private endpoints for managed services, with public access disabled.
  • A hub firewall with rules per inventoried flow.

Try it: Intermediate

Why disable public access once a private endpoint exists?

Now do it: List services with private endpoints and public access still on.

Advanced — Resilience you have tested

At the advanced level the link survives failures, and you have proved it.

  • Two circuits at different locations, a VPN backup, and BFD on every session.
  • The same failover order in both directions, with the cloud's own route preferences taken into account.
  • Failover tests that check the request and the reply path, every quarter.

Try it: Advanced

In a failover test, what proves the design works?

Now do it: Add a reply-path check to your next failover test.

Master — One estate

At the master level both sides are operated as one.

  • Federated identity for people and workloads; no long-lived cloud keys on premises.
  • One inventory, tags, policies, patching, and monitoring through the clouds' hybrid control planes.
  • Synthetic checks across the link from both sides, and cost and capacity reports for the circuits.

Trade-off: a hybrid estate keeps the data centre's control and the cloud's services at once, and pays for it in two sets of networking, DNS, and identity to keep consistent; each flow should justify staying hybrid rather than moving.

Try it: Master

Users report errors only from the data centre, never from the cloud. Which check would have caught it first?

Now do it: Run one synthetic check from on premises to each private endpoint.

Go deeper

Conditional forwarding on an on-premises Unbound resolver, sending the private endpoint zone to the cloud's inbound resolver and everything else to the usual upstream (a Windows DNS server does the same with a conditional forwarder):

forward-zone:
    name: "privatelink.blob.core.windows.net."
    forward-addr: 10.20.0.4          # the cloud's inbound resolver endpoint
    forward-addr: 10.20.0.5
forward-zone:
    name: "."
    forward-addr: 10.10.0.53         # the usual upstream

To check it from on premises, resolve the account name: dig +short ordersdata.blob.core.windows.net should end with a private address (10.20.4.10 here), not a public one.

BGP choices on the data centre router decide the backup order outbound (local preference, highest wins); AS-path prepending on the routes you advertise influences which path the other side uses for replies. Each cloud documents its own preference order between circuits and VPNs. Write both down, side by side, for every failure case, before testing them.

One time it broke

This is a composite of a failure pattern that keeps repeating; the details are illustrative. The backup that worked one way.

Timeline

  • 02:10A fibre cut takes down interconnect A. BFD detects it in a second; the data centre's router moves outbound traffic for the cloud to its VPN, as designed.
  • 02:10The cloud learns site A's prefixes from the VPN and from interconnect B at the second data centre, and prefers the circuit. Replies go to site B, whose firewall drops them.
  • 02:14Synthetic checks from on premises fail; the on-call engineer sees both remaining paths up and the VPN carrying traffic, and spends 40 minutes before comparing the reply path.
  • 02:58The data centre router's preference is changed to send traffic through site B too, so both directions use interconnect B; requests succeed.

What changed after

A written failover table for both directions, using the cloud's documented route preferences; the router configuration made to match it; and a quarterly failover test that checks the reply path and the firewall that saw it.

Try it yourself, from scratch

Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.

Before you start: Linux with iproute2 (the ip command), sudo rights for network namespaces, and Python 3. Everything happens inside a throwaway namespace; your own routes are not touched.

1. Linux commands

Type each one, read what it prints, and compare it with the note above it.

  1. Create a namespace that stands in for the data centre router, with an interface on 10.10.4.0/24.

    sudo ip netns add onprem
    sudo ip -n onprem link add edge0 type dummy
    sudo ip -n onprem addr add 10.10.4.5/24 dev edge0
    sudo ip -n onprem link set edge0 up
    sudo ip -n onprem addr show edge0 | grep -w inet

    Options: ip netns add creates an isolated network stack; -n onprem runs each command inside it; a dummy interface needs no cable.

    Expect: inet 10.10.4.5/24 scope global edge0.

    Clean up: sudo ip netns del onprem removes the namespace with its interface and routes.

  2. Add two routes to the cloud's 10.20.0.0/16: the interconnect (next hop 10.10.4.1) preferred, and the VPN (10.10.4.2) as backup.

    sudo ip -n onprem route add 10.20.0.0/16 via 10.10.4.1 metric 100
    sudo ip -n onprem route add 10.20.0.0/16 via 10.10.4.2 metric 200
    sudo ip -n onprem route show 10.20.0.0/16
    sudo ip -n onprem route get 10.20.7.9

    Options: For the same prefix, the lower metric wins; route get shows the route the kernel would choose for one address.

    Expect: Both routes listed, and 10.20.7.9 via 10.10.4.1 dev edge0 src 10.10.4.5: the interconnect.

  3. Fail the interconnect by removing its route, and see the backup take over.

    Changes a real system: On real routers this happens through BGP when a session drops; use BFD so it takes a second, and test it with the reply path in view.

    sudo ip -n onprem route del 10.20.0.0/16 via 10.10.4.1 metric 100
    sudo ip -n onprem route get 10.20.7.9

    Expect: 10.20.7.9 via 10.10.4.2 dev edge0 src 10.10.4.5: the VPN. This is only the outbound half; which way the replies come back is decided by the other side's routes.

  4. Add a more specific route through a third next hop, with a worse metric, and see which one wins.

    sudo ip -n onprem route add 10.20.7.0/24 via 10.10.4.3 metric 500
    sudo ip -n onprem route get 10.20.7.9
    sudo ip -n onprem route get 10.20.9.9

    Options: The longest matching prefix is chosen first; metrics only decide between routes of the same length.

    Expect: 10.20.7.9 via 10.10.4.3 despite metric 500, and 10.20.9.9 via 10.10.4.2. A more specific route advertised by mistake overrides every preference you set.

  5. Remove the namespace.

    sudo ip netns del onprem
    ip netns list | grep -c onprem || true

    Expect: 0: the namespace and everything in it are gone.

2. Python: hybrid_check.py

This program checks an address plan for overlaps between the data centre and the cloud networks, resolves a storage account name with and without a conditional forwarder for its private endpoint zone, and works out the request and reply paths before and after a circuit failure, flagging the asymmetric case and checking the fix. Save it as hybrid_check.py, then run it.

# hybrid_check.py
import ipaddress

ONPREM = ["10.10.0.0/16", "10.11.0.0/16", "192.168.0.0/16"]
CLOUD = {"hub": "10.20.0.0/22", "spoke-orders": "10.20.4.0/22", "spoke-analytics": "10.11.8.0/22", "spoke-ml": "172.16.0.0/20"}
print("address plan:")
for name, cidr in CLOUD.items():
    net = ipaddress.ip_network(cidr)
    clash = [o for o in ONPREM if net.overlaps(ipaddress.ip_network(o))]
    print(f"  {name:<16} {cidr:<15} {'OVERLAPS ' + ', '.join(clash) if clash else 'ok'}")
print()

PUBLIC = {"ordersdata.blob.core.windows.net": ("CNAME", "ordersdata.privatelink.blob.core.windows.net"),
          "ordersdata.privatelink.blob.core.windows.net": ("A", "203.0.113.10")}   # what the internet sees
CLOUD_RESOLVER = {"ordersdata.privatelink.blob.core.windows.net": "10.20.4.10"}    # the private zone

def resolve(name, forwarders):
    while True:
        zone = max((z for z in forwarders if name == z or name.endswith("." + z)), key=len, default=None)
        if zone:
            return CLOUD_RESOLVER[name], f"forwarded {zone} to the cloud resolver"
        kind, value = PUBLIC[name]
        if kind == "A":
            return value, "public DNS"
        name = value                                  # follow the CNAME

for label, fwd in (("with forwarder", ["privatelink.blob.core.windows.net"]), ("without forwarder", [])):
    ip, how = resolve("ordersdata.blob.core.windows.net", fwd)
    private = any(ipaddress.ip_address(ip) in ipaddress.ip_network(c) for c in CLOUD.values())   # inside our cloud networks
    print(f"{label:<18} -> {ip:<12} ({how}); {'private path' if private else 'public address: refused, public access is off'}")
print()

def best(routes, rank):
    up = [r for r in routes if r["up"]]
    return min(up, key=rank)["via"]

def paths(ic_a_up, onprem_pref_b):
    out = [{"via": "interconnect A", "pref": 300, "up": ic_a_up},          # data centre A's routes to the cloud
           {"via": "site B, interconnect B", "pref": 250 if onprem_pref_b else 100, "up": True},
           {"via": "VPN A", "pref": 200, "up": True}]
    back = [{"via": "interconnect A", "kind": 0, "aspath": 1, "up": ic_a_up},  # the cloud's routes to 10.10.0.0/16
            {"via": "site B, interconnect B", "kind": 0, "aspath": 3, "up": True},
            {"via": "VPN A", "kind": 1, "aspath": 1, "up": True}]           # a circuit (0) beats a VPN (1)
    return best(out, lambda r: -r["pref"]), best(back, lambda r: (r["kind"], r["aspath"]))

for label, up, pref_b in (("normal", True, False), ("interconnect A down", False, False),
                          ("A down, after the fix", False, True)):
    req, rep = paths(up, pref_b)
    state = "symmetric" if req == rep else "ASYMMETRIC: replies hit a firewall that never saw the connection"
    print(f"{label:<22} request via {req:<23} reply via {rep:<23} {state}")

Run it, and you should see this output:

$ python3 hybrid_check.py
address plan:
  hub              10.20.0.0/22    ok
  spoke-orders     10.20.4.0/22    ok
  spoke-analytics  10.11.8.0/22    OVERLAPS 10.11.0.0/16
  spoke-ml         172.16.0.0/20   ok

with forwarder     -> 10.20.4.10   (forwarded privatelink.blob.core.windows.net to the cloud resolver); private path
without forwarder  -> 203.0.113.10 (public DNS); public address: refused, public access is off

normal                 request via interconnect A          reply via interconnect A          symmetric
interconnect A down    request via VPN A                   reply via site B, interconnect B  ASYMMETRIC: replies hit a firewall that never saw the connection
A down, after the fix  request via site B, interconnect B  reply via site B, interconnect B  symmetric

3. What to notice

4. Advanced: every step as one Bash script

The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/hybrid-cloud-networking-dns-identity-and-operations && cd ~/labs/hybrid-cloud-networking-dns-identity-and-operations) and save this as lab.sh.

#!/usr/bin/env bash
# The Linux steps of "Hybrid Cloud: Connecting On-Premises and Cloud with Shared Networking, DNS, Identity, and Operations", as one script (save it as lab.sh).
#
#   ./lab.sh          run every step, in order
#   ./lab.sh 2 4      run only steps 2 and 4
#   ./lab.sh --list   list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.

STEPS=(
  'Create a namespace that stands in for the data centre router, with an interface on 10.10.4.0/24.'
  'Add two routes to the cloud'\''s 10.20.0.0/16: the interconnect (next hop 10.10.4.1) preferred, and the VPN (10.10.4.2) as backup.'
  'Fail the interconnect by removing its route, and see the backup take over.'
  'Add a more specific route through a third next hop, with a worse metric, and see which one wins.'
  'Remove the namespace.'
)

step_1() {
sudo ip netns add onprem
sudo ip -n onprem link add edge0 type dummy
sudo ip -n onprem addr add 10.10.4.5/24 dev edge0
sudo ip -n onprem link set edge0 up
sudo ip -n onprem addr show edge0 | grep -w inet
}

step_2() {
sudo ip -n onprem route add 10.20.0.0/16 via 10.10.4.1 metric 100
sudo ip -n onprem route add 10.20.0.0/16 via 10.10.4.2 metric 200
sudo ip -n onprem route show 10.20.0.0/16
sudo ip -n onprem route get 10.20.7.9
}

step_3() {
sudo ip -n onprem route del 10.20.0.0/16 via 10.10.4.1 metric 100
sudo ip -n onprem route get 10.20.7.9
}

step_4() {
sudo ip -n onprem route add 10.20.7.0/24 via 10.10.4.3 metric 500
sudo ip -n onprem route get 10.20.7.9
sudo ip -n onprem route get 10.20.9.9
}

step_5() {
sudo ip netns del onprem
ip netns list | grep -c onprem || true
}

# print a step that has to be run by hand, instead of running it
by_hand() {
  echo "  (run this one yourself: $1)"
  sed 's/^/    /'
}

RESULTS=()
run_step() {
  local n=$1 start=$SECONDS code
  printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
  "step_$n"
  code=$?
  RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}

summary() {
  echo
  echo "== summary"
  local r
  for r in "${RESULTS[@]}"; do echo "  $r"; done
}

case "${1:-}" in
  -h|--help) sed -n '2,6p' "$0"; exit 0 ;;
  --list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac

[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
  if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
    echo "there is no step '$n'; try --list" >&2
    exit 2
  fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done

Then make it executable and run it:

chmod +x lab.sh
./lab.sh --list     # the steps
./lab.sh            # every step, then a summary of exit codes and times
./lab.sh 2 3        # only steps 2 and 3

5. Learn the basics behind it

New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.

If you remember nothing else

Design exercise

Your company has two data centres and is moving part of its estate to one cloud provider, with on-premises systems calling managed databases and storage, and cloud services calling an on-premises mainframe API. Design the hybrid connectivity and operations.

Clarifying questions to ask

Which flows cross the link, in which direction, and how much? What is the address plan? Which circuits and backups do you use, and how do they fail over in both directions? How does DNS work each way? How do workloads and people authenticate? How do you operate and monitor both sides?

Rough sizing

Say 3 Gbit/s at peak between the sites, a mainframe API that needs under 20 ms, 40 private endpoints, and 600 servers remaining on premises.

Shape of the answer

Two 10 Gbit/s interconnects from different data centres to different provider locations, plus a VPN backup; BGP with BFD and a written failover table for both directions; a central address plan; conditional forwarders for every private endpoint zone on premises and an outbound rule for corp.example.com in the cloud; private endpoints with public access off; workload identity federation for on-premises workloads; the cloud's hybrid control plane for inventory, policy, and patching of the remaining servers; synthetic checks in both directions; a quarterly failover test.

Trade-offs to name

Two circuits and a backup cost far more than a VPN and give predictable latency and bandwidth; a hybrid control plane brings on-premises servers into cloud tooling and adds an agent and a dependency on the cloud to every one of them.

Failure modes and how to troubleshoot them

Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.

ScenarioWhereEffectWhat goes wrong
DNS without a forwarderHop 2: DNSBreaksThe on-premises DNS has no forwarder for privatelink.blob.core.windows.net, so it follows the CNAME through public DNS and gets the storage account's public address. Nothing fails at this point: the name resolves, just to the wrong place.
DNS without a forwarderHop 3: RoutingDegradesThe public address uses the default route to the internet proxy.
DNS without a forwarderHop 4: InterconnectDegradesNot used: the traffic went to the internet.
DNS without a forwarderHop 8: ServiceBreaksThe request reaches the public endpoint through the internet proxy, and the account, with public network access disabled, refuses it with HTTP 403. The application logs "authorization failure", and the first hour of the investigation is spent on the identity.
Failover, asymmetric returnHop 3: RoutingBreaksWith interconnect A down, the data centre's next choice for 10.20.0.0/16 is its VPN. The cloud still learns 10.10.0.0/16 from two places: the VPN, and interconnect B at the second data centre, which reaches site A over the link between the data centres.
Failover, asymmetric returnHop 4: InterconnectDegradesInterconnect A down at 02:10, detected by BFD in a second; the VPN is carrying outbound traffic.
Failover, asymmetric returnHop 5: FirewallBreaksSite B's firewall drops replies for connections it never saw open.

How to troubleshoot

  1. Write down the symptom and when it started: what users see, which number moved, and what changed just before (a deploy, a config change, traffic).
  2. Walk the path in order, from the first hop to the last: App → DNS → Routing → Interconnect → Firewall → Private endpoint → Identity → Service → Operations. The first hop whose evidence is wrong is where to dig.
  3. At that hop, run the read-only check from the diagram or the lab first; change nothing until the evidence points at a cause.
  4. Fix the smallest thing that restores service, or roll back the last change, and confirm the symptom is gone with the same check.
  5. Write down what you found and the check that would have caught it sooner, so the next person starts there.

Architecture review checklist

Review the design in this lesson, or your own, against these ten areas. Tick an area when you can answer its question with evidence: a number, a test, a document, or an owner. Your ticks stay in this browser.

  1. Business outcomeWhich result for users or the business does this design serve, and which number shows it is working?
  2. SecurityWho and what can reach each part, how is identity proven, and how is data protected in transit and at rest?
  3. ReliabilityWhat is the target (SLO), which single failures does the design survive, and how was that tested?
  4. PerformanceWhat latency and throughput are required at peak, and where is the first bottleneck?
  5. OperationsHow is it deployed, observed, and changed safely, and who is paged when it breaks?
  6. CostWhat does it cost per month and per unit of work (request, tenant, model call), and what grows the bill?
  7. SustainabilityWhich resources sit idle, which region and hardware does it run on, and what can scale to zero?
  8. GovernanceWhich policies, guardrails, and compliance rules apply, and how are they enforced in code?
  9. OwnershipWhich team owns each component, its budget, and its on-call, and where is that written down?
  10. Failure and recovery planWhat is the RTO and RPO, what is the runbook for a region or dependency loss, and when was it last rehearsed?

References and review

The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.

Last updated . Next review due by November 2027. Found something out of date? Tell me.

Saved on this device, in this browser.
Next in this series · Lesson 160
Multi-Region Architecture: Active/Active, Active/Passive, RTO, and RPO

A single Region is a single failure domain. Running in two Regions protects against losing one, and the design choice comes down to two numbers the business sets:

Go to Lesson 160 →

Or browse the full course from the Lessons index.