Architecture

Last change on 2025-04-25 • Created on 2025-04-25 • ID: NE-431E1

Routing within Hetzner Networks

This section assumes you are familiar with the difference between switches and routers and have a basic understanding of the layers in the OSI model.

Communication within Hetzner Networks happens via two different communication layers depending on the subnet type:

Communication
Cloud subnet Layer 3
vSwitch subnet Layer 2
  • vSwitch subnet at Layer 2 (Ethernet / Data Link Layer):

    On-link (Direct) Communication

    Source
    dedicated server
    Destination
    dedicated server

    Both dedicated servers are directly connected via a switch. This allows the source to use ARP to resolve the MAC address of the destination and send packets directly to the destination without additional hops in between.


  • Cloud subnet at Layer 3 (IP / Network Layer):

    Off-link (Routed) Communication


    Cloud servers only:

    Source
    cloud server
    Cloud
    Gateway
    Destination
    cloud server

    Cloud server and dedicated server:

    Source / Desti.
    dedicated server
    vSwitch
    Gateway
    Cloud
    Gateway
    Des. / Source
    cloud server

    The servers are not directly connected. The source has to use ARP to resolve the MAC address of the gateway and send packets to the gateway. The gateway forwards the packet to the destination or the next hop towards the destination.

Example visualization
  • 10.0.0.0/16
  • 10.0.0.0/24
  • 10.0.1.0/24
  • Network
    subnet
    subnet of type vSwitch
    directly connected
    directly connected via switch
Subnet Gateway
10.0.0.1 00:00:5E:00:53:01
Cloud Server
10.0.0.2
00:00:5E:00:53:02
Load Balancer
10.0.0.3
00:00:5E:00:53:03
vSwitch Gateway
10.0.1.1
00:00:5E:00:53:04
Dedi. Server A
10.0.1.2
00:00:5E:00:53:05
Dedi. Server B
10.0.1.3
00:00:5E:00:53:06
Example routes

Following shows the routes needed to reach the private IPs in the example visualization above.

ℹ   Meaning of "on-link"
The source can directly look up or ARP the MAC address of the destination.

On the cloud server:

Destination CIDR Netmask Gateway Local IP
10.0.0.0 /16 255.255.0.0 10.0.0.1 10.0.0.2
10.0.0.1 /32 255.255.255.255 On-link 10.0.0.2

On dedicated server A:

Destination CIDR Netmask Gateway Local IP
10.0.0.0 /16 255.255.0.0 10.0.1.1 10.0.1.2
10.0.1.0 /24 255.255.255.0 On-link 10.0.1.2

Routing through several networks

Gateway 10.0.0.1
public network
Cloud Server router
Private IP
10.0.0.2
Public IP
203.0.113.1
Cloud Server client
Private IP
10.0.0.3


When you send packets between the Internet and the client, they pass through two networks — the private network and the public network.

As explained in the FAQ about technical details, the MTU of Hetzner cloud servers is different in private and public interfaces.

Public Network to Private Client
public
network
1500 B
⸺>
Server
router
1450 B
⸺>
Gateway

1450 B
⸺>
Server
client

In the example above, an incoming packet with an MTU of 1500 bytes should be able to reach the cloud server router without any issues. However, if the router cannot perform IP fragmentation, it cannot forward the packet through the private interface and the packet is dropped.

You can run ip link show to check the MTUs of all interfaces on your system.

Routing from network-isolated environments

If you have a network-isolated environment on your system (e.g. Docker container or LXC), it will usually have its own interface settings.

In the example below, the network-isolated environment and the underlying host can exchange packets with an MTU of 1500 bytes:

Cloud Server client
Host
private interface
MTU 1450
bridge interface
MTU 1500

network-isolated env
bridge interface
MTU 1500

If the network-isolated environment uses the underlying host as a router, the host from the example above will forward the packet via the private interface with an MTU of 1450 bytes.

If the network-isolated environment sends a packet with an MTU of 1500 bytes, it should be able to reach the underlying host without any issues. However, if the host cannot perform IP fragmentation, it cannot forward the packet through the private interface and the packet is dropped.

Configuring multi-network routes

If routing is implemented correctly, the setup should look similar to this:

Private Network Gateway 10.0.0.1
0.0.0.0/0

NAT server
198.51.9.1 10.0.0.2
routing table
default via public interface
10.0.0.0/16 via 10.0.0.1
client server
10.0.0.3
routing table
default via 10.0.0.1
10.0.0.0/16 via 10.0.0.1

Before configuring routes in a NAT/client setup as visualized above, it is important to understand how packets are expected to move through the network.

Example:

A private client with the private IP 10.0.0.3 sends a request to the public IP 203.0.13.1.

On the Cloud side, traffic is configured to be routed via the NAT server (private IP 10.0.0.2, public IP 198.51.9.1). The client servers can reach the NAT server via the private network gateway.


Request to public target
Target IP:
203.0.13.1
Gateway:
10.0.0.1
Source IP:
10.0.0.3
Client
|
10.0.0.1
Private Network Gateway
|
0.0.0.0/0
NAT
Forwarded request
Target IP:
203.0.13.1
Source IP:
198.51.9.1
NAT
|
203.0.13.1
Target

Response to private client
Target IP:
198.51.9.1
Source IP:
203.0.13.1
Target
|
198.51.9.1
NAT
Forwarded response
Target IP:
10.0.0.3
Gateway:
10.0.0.1
Source IP:
203.0.13.1
NAT
|
10.0.0.1
Private Network Gateway
|
10.0.0.3
Client

Request to public target:

  • The client server must have a static route that sends traffic destined for IPs outside its own network (e.g., public IPs such as 203.0.13.1 or private IPs such as 192.168.0.3) to the private network gateway, in this example 10.0.0.1.

    # default route for public IPs
    ip route add default via 10.0.0.1
    
    # static route for traffic to a private network outside the server's own subnet
    ip route add 192.168.0.0/16 via 10.0.0.1

  • The private network must have a route that sends traffic destined for IPs outside its own network (e.g., public IPs such as 203.0.13.1 or private IPs such as 192.168.0.3) to the private IP of the NAT server, in this example 10.0.0.2. You can use the Hetzner Console or the Hetzner API.

    Default route for public IPs

    • Destination: 0.0.0.0/0
    • Gateway: private IP of the NAT server

    Route for traffic to a private network outside the own subnet

    • Destination: 192.168.0.0/16
    • Gateway: private IP of the NAT server

Finally, the NAT server must be configured to forward the traffic so the request can be sent out to the target.


Response to private client:

You don't need to configure any extra routes. For the response traffic, the NAT server only needs a route that directs packets to private IPs such as 10.0.0.3 via the private network gateway 10.0.0.1. Servers in a private network have this route automatically.

Table of Contents