Network and security

Additional IP addresses on Hetzner and OVH: order and set up

You order an additional IPv4 address or subnet for your server from us in a ticket and configure it on the server yourself. Here is what to put in the order, how to add the address on Ubuntu, Debian and Windows, and what virtual machines need.

  • Time: 15 minutes
  • Level: Intermediate

In short

  • Order addresses in a ticket: say how many you need and what for. The purpose is required because Hetzner assigns IPv4 only when there is a technical need.
  • The address comes from the same region as the server. We tell you the price in the ticket before payment; additional IPs are not refunded once provided (clause 6.6 of the offer).
  • On the server, add the address to the main network interface with a /32 mask and leave the gateway alone: in netplan on Ubuntu, in /etc/network/interfaces on Debian, in the IPv4 properties on Windows.
  • Virtual machines in bridged mode need a virtual MAC for each address. Traffic from an unregistered MAC triggers a complaint from the data center.
Contents
  1. How to order an address or subnet
  2. Linux: test the address temporarily first
  3. Ubuntu and other systems with netplan: the address in a YAML file
  4. Debian without netplan: the address in /etc/network/interfaces
  5. Windows Server: the address in the network adapter properties
  6. Addresses for virtual machines: virtual MAC
  7. Reverse DNS (PTR) for the new address
  8. How to check that the address works
  9. If the address does not work
  10. FAQ

You will need

How to order an address or subnet

We order additional addresses for your server. You cannot order an address with the Hetzner Robot login from ABCD. We pay the data center for an OVH server on your account, and paid options for it must not be ordered in OVH at our expense: the client reimburses such costs (clause 3.3.1 of the offer). So order addresses for an OVH server from us as well.

  1. Decide how many addresses you need

    You can order one address, several separate addresses or a subnet: /29 is a block of 8 addresses, /28 a block of 16. We will tell you in the ticket which options your server has.

  2. Write in a ticket what the addresses are for

    Hetzner assigns IPv4 only when there is a technical need, under RIPE rules, so no address is issued without a purpose. If the addresses are for virtual machines in bridged mode, say so too: each address will need a virtual MAC.

    Server: #1234567
    Needed: 2 additional IPv4 addresses
    Purpose: two virtual machines in Proxmox, each needs its own public address
    Virtual MACs: needed, the machines are connected in bridged mode
  3. Pay the invoice from your balance

    In our reply we will give you the monthly price of the address and the one-time setup fee, if there is one, and issue an invoice. You can pay it from your balance.

  4. Get the address, mask and gateway

    When the address is connected, we will send it to you together with the mask and gateway. Then you need to configure the address on the server, which the next sections cover.

A few limitations that are worth knowing before you order:

  • The address comes from the same region as the server: you cannot attach an address from another country to the server.
  • At OVH, additional addresses are called Additional IP (formerly Failover IP). In the OVHcloud panel they are listed under NetworkPublic IP Addresses, and the list has an Additional IP filter. For a server already transferred to your OVH account, connecting an address sometimes takes several days.
  • If your server is from the Kimsufi range, ask in a ticket before ordering whether an additional address can be connected to it.
  • You do not need to order IPv6 separately: every Hetzner server already has a /64 subnet, and the IPv6 gateway is fe80::1.

The addresses belong to us or to the data center and are assigned to you for the duration of the service. They do not become your property and may change if the service has to be moved to other hardware or another data center (clause 3.4 and clause 5.4). We announce a move at least 7 days in advance, or as soon as possible in case of an outage or a data center’s requirement. So wherever you can, reach the server by its domain name: if the address changes, you only need to update one DNS record.

Linux: test the address temporarily first

A mistake in the network settings cuts the server off from the internet. After that, you can only fix it through the console or Rescue. So first add the address with a temporary command that is forgotten on reboot, and write it into the files only once it works.

  1. Find the main network interface

    The command lists the interfaces and their addresses. You need the one that has the server’s main IP, enp0s31f6 in the example.

    ip -br addr
    lo               UNKNOWN        127.0.0.1/8 ::1/128
    enp0s31f6        UP             203.0.113.10/32 2001:db8:1234::2/64 fe80::1a2b:3cff:fe4d:5e6f/64
  2. Add the address until the next reboot

    The command adds the new address to the interface with a /32 mask. Put in your own address and interface name.

    sudo ip addr add 198.51.100.20/32 dev enp0s31f6
  3. Check the address from your computer

    Run ping 198.51.100.20 on your computer. If the address responds, it reaches the server, and you can write it into the settings. If not, check the server’s firewall and write in a ticket. You can remove the temporary address with sudo ip addr del 198.51.100.20/32 dev enp0s31f6.

The temporary address disappears on reboot. To keep it, write it into the network settings. If the server has an /etc/netplan/ folder (Ubuntu, some Debian installations), the settings are in netplan; if not, they are in the /etc/network/interfaces file.

Ubuntu and other systems with netplan: the address in a YAML file

Netplan describes the network in YAML files in the /etc/netplan/ folder. The first command shows which files are there, the second opens the right file in an editor:

ls /etc/netplan/
sudo nano /etc/netplan/01-netcfg.yaml

Find the addresses list of your interface and add one line with the new address right after the main one. Indent with spaces, exactly like the neighboring lines. Leave the rest of the file as it is: the routes block with the route via the gateway must stay, or the server will lose its connection. On a Hetzner server the file looks roughly like this, with the new line marked by a comment:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s31f6:
      addresses:
        - 203.0.113.10/32
        - 198.51.100.20/32    # new address
        - 2001:db8:1234::2/64
      routes:
        - on-link: true
          to: 0.0.0.0/0
          via: 203.0.113.1
        - to: default
          via: fe80::1

Save the file: Ctrl+O, Enter, then Ctrl+X.

On OVH servers, the top of the file sometimes says that it is generated by cloud-init and that changes will not survive a reboot. Do not edit such a file: create a separate one next to it, for example /etc/netplan/60-additional-ip.yaml, and under ethernets give the same interface name as in the main file:

network:
  version: 2
  ethernets:
    enp0s31f6:
      addresses:
        - 198.51.100.20/32

Netplan warns you if the settings file can be read by all users. The command leaves access to the file to root only:

sudo chmod 600 /etc/netplan/60-additional-ip.yaml

Apply the settings with the command that can roll back. It switches on the new configuration and waits 120 seconds for you to confirm. If you still have a connection to the server, press Enter at Press ENTER before the timeout to accept the new configuration. If the connection is lost, the old settings come back after 120 seconds.

sudo netplan try

After confirming, check with ip -br addr that the new address is on the interface next to the main one.

Debian without netplan: the address in /etc/network/interfaces

If there is no /etc/netplan/ folder, the network is described in /etc/network/interfaces. Open the file:

sudo nano /etc/network/interfaces

Add a block with the new address at the end of the file. The interface name is the same as for the main address. A separate block for the same interface is fine: when the network starts, the system applies all the addresses.

iface enp0s31f6 inet static
    address 198.51.100.20/32

Save the file. You do not need to restart the network: the address already works after the temporary command, and the entry in the file brings it back after a reboot. Check this at the next planned reboot, when you have a console at hand.

Windows Server: the address in the network adapter properties

If the adapter gets its address via DHCP, the button for adding addresses is unavailable. First the adapter is switched to a static address, with the main IP, mask, gateway and DNS entered from the ipconfig /all output. A mistake in these fields will cut off RDP, so do this when you have console access, or ask for help in a ticket.

  1. Open Network Connections

    Press Win+R, type ncpa.cpl and press Enter.

  2. Open the adapter’s IPv4 properties

    Right-click the adapter, choose Properties, then Internet Protocol Version 4 (TCP/IPv4) and Properties again.

  3. Click Advanced and add the address

    Click Advanced…, and on the IP Settings tab, under the list of addresses, click Add….

  4. Enter the address and the mask 255.255.255.255

    In the IP address field, enter the new address, and in Subnet mask, 255.255.255.255, which is the same /32 mask. Click Add, then OK in all the windows. Do not change the gateway.

You can do the same in PowerShell run as administrator. The first command shows the adapter name and where its address comes from: Manual means static, Dhcp means via DHCP. The second adds the address. The -SkipAsSource option keeps the main IP as the address for outgoing connections, so that mail, for example, does not start going out from the new address.

Get-NetIPAddress -AddressFamily IPv4 | Format-Table InterfaceAlias, IPAddress, PrefixLength, PrefixOrigin
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 198.51.100.20 -PrefixLength 32 -SkipAsSource $true

Put the adapter name from the first command in place of Ethernet. If you have already added the address in the properties window, this command sets the same flag:

Set-NetIPAddress -IPAddress 198.51.100.20 -SkipAsSource $true

Ping is often blocked by the firewall on Windows Server, so check the new address on the RDP port: Test-NetConnection 198.51.100.20 -Port 3389 from your computer should show TcpTestSucceeded : True.

Addresses for virtual machines: virtual MAC

In bridged mode, each virtual machine goes out to the network with its own MAC address. The data center watches which MAC addresses traffic comes from and treats an unknown MAC as a violation. So each additional address used by a machine needs a virtual MAC issued by the data center.

  • Hetzner. A virtual MAC is created for a single additional address, and in bridged mode a server can have no more than 6 such addresses. Subnets work only in routed mode, without virtual MACs. We create virtual MACs when you ask in a ticket.
  • OVHcloud. Additional IPs also have virtual MACs (vMAC). If you cannot find where to create a vMAC in your panel, write in a ticket.

Traffic from an unregistered MAC triggers a complaint. Hetzner sends e-mails about MAC errors, and the server may be blocked. Do not let virtual machines onto the network in bridged mode until you have received virtual MACs for them. What to do if a complaint has already arrived is covered in the article on abuse complaints.

How to set up the Proxmox VE network for additional addresses in both modes is covered in the article on Proxmox on Hetzner.

Reverse DNS (PTR) for the new address

A PTR record links an address to a name, for example server.example.com. Recipients’ mail servers check it: mail from an address without a PTR record may be rejected or sent to spam. The A record of that name must point to the same address.

  • Hetzner. We set up PTR records on request (clause 3.4 of the offer): send the address and the name in a ticket. With your Robot login you can also change it yourself: on the IPs tab, click the record in the Reverse DNS entry column. One PTR record per address.
  • OVHcloud. On your own account you can set the record yourself: NetworkPublic IP Addressesyour IPReverse DNS, the Configure button, the Reverse DNS hostname field. OVH checks right away that the A record already points to this address, so create the A record first.

After changing the A record, give it time: DNS updates can take up to 24 hours.

How to check that the address works

From your computer, the address answers ping or, if ping is blocked, a port check: Test-NetConnection 198.51.100.20 -Port 22 on Windows, nc -vz -w 5 198.51.100.20 22 on Linux, nc -vz -G 5 198.51.100.20 22 on macOS. On the server, the address shows in ip -br addr or ipconfig. After a reboot, the address must still be there.

If the address does not work

What you seeWhyWhat to do
The temporary address does not answer pingPing is blocked by the server’s firewall, or the address is not yet connected to the serverCheck on an open port. If the port does not answer either, write in a ticket
The connection dropped after sudo netplan tryA mistake in the file: the wrong interface, broken indentation, the main address is missingDo not press anything: after 120 seconds the old settings come back. Then fix the file
Invalid YAML on netplan tryThe lines are indented with tabs or do not line up with the neighboring linesAlign the lines with spaces, as in the example
Permissions for /etc/netplan/… are too openThe file can be read by all usersRun sudo chmod 600 on that file
The address is gone after a rebootThe address was added only with the temporary command, or cloud-init overwrote the fileWrite the address into a separate file, as described above
The Add… button in Windows is grayed out, and the list says DHCP EnabledThe adapter gets its address via DHCPSwitch the adapter to a static address or write in a ticket

If none of this fits, send the address, the output of ip -br addr or ipconfig /all and what you have already done in a ticket.

FAQ

How much does an additional IP cost?
The price depends on the data center and the location. We will give it to you in the ticket before payment, together with the one-time setup fee, if there is one.
Can I get an address from another country?
No. An additional address comes from the same region as the server.
I no longer need the address. Will you refund me?
Additional IP addresses are not refunded once provided (clause 6.6 of the offer). To stop the address from renewing, write in a ticket.
Will the address stay with me if I move to another server?
We cannot guarantee that: addresses belong to us or to the data center and are assigned for the duration of a specific service (clause 3.4). Before moving, ask in a ticket what is possible in your case.

Did this guide help?

Questions?