HF Cloud
Docs / Networking

Networking

Private networks, security groups, firewalls with NAT, port forwards and VPN (WireGuard, IPsec), reserved IPs and VIPs, IPv6 and reverse DNS.

Every server gets a public IPv4 address (and IPv6 where the location offers it) unless you create it without one (public_ip: false). Around it you can build private networks, filter traffic and publish services.

Private network

Each organization can have one private network per location: its own isolated network (for example 10.21.0.0/24) that other organizations never reach. Load balancers and firewalls need it.

  • Turn it on: Network → Networks → Set up private network, or POST /networks with a location. It is usually ready within a minute.
  • Connect a server: Connect on the networks page or on the server, or PATCH /servers/{id} with "private_network": true (Terraform: private_network = true). Servers get addresses from .10 up; .1 to .9 are reserved for gateways and appliances.
  • The server gets a second interface, eth1, within a minute. Restart the server once so it picks up its private address (cloud-init configures it on boot).
  • Disconnecting removes eth1 and the address at once. A server that is a target of a load balancer or a firewall port forward cannot be disconnected.

By default, all traffic from your private network to a server's private interface is allowed. Switch the server to Only by security groups to allow only your own load balancers and firewalls, plus what your security groups allow (for example "TCP 5432 from the private network").

Security groups

Security groups are the server's inbound firewall, applied outside the server (it cannot be turned off from inside).

  • With no groups, incoming traffic is closed and outgoing traffic is open.
  • Outgoing port 25 (e-mail) is closed until support opens it for your organization.
  • A server can have several groups; a group can be used by many servers. GET /security-groups lists the shared groups we prepare and your own. The console's rule editor has presets (SSH, HTTP, HTTPS, Ping, MySQL, PostgreSQL, RDP, DNS, WireGuard).

A group has 1 to 20 rules, kept in order (the first rule that matches decides):

{"direction": "in", "action": "accept", "protocol": "tcp", "port": "80,443", "source": null, "comment": "web"}
Field Values
direction in (default) or out; outgoing rules can only block
action accept (default), drop, reject
protocol tcp, udp (both need a port), icmp, any
port "443", "80,443" or a range "8000-8100"
source a CIDR, "private" (your private network) or empty for anywhere

Manage them in Network → Security groups, with GET/POST/PUT/DELETE /security-groups, or with the Terraform hfcloud_security_group resource. Attach them with security_groups on the server.

Firewall: NAT, port forwards and VPN

A firewall is a managed appliance at the edge of your private network: two nodes sharing one public address, with the gateway .1 inside the network. One firewall per location. It needs the private network and is enabled by support for your organization.

  • NAT: servers in the private network (also ones without a public address) reach the internet through the firewall's public address when their default route points to the gateway. The firewall page shows the commands.
  • Port forwards: a public port (TCP or UDP) to a server and port in the private network, optionally only from listed sources (up to 20) and with a limit of connections per address. Up to 50 forwards. Everything else from the internet is dropped. The same public port can be forwarded twice for senders that do not overlap (for example SSH from the office to one server, from home to another); both forwards need a source list.
  • Connections per forward: each forward shows how many connections it has had; the count is kept when you change the rules (API: connections).
  • Keep the client's address (preserve_client_ip on a forward, off by default): the server sees the visitor's real address instead of the firewall's. Two conditions: the server's replies must go back through the firewall (its default route is the gateway .1, as on servers without a public address; a server with its own public address answers there and the connection fails), and its security groups must allow the port from the internet (or from the forward's sources), because the traffic no longer comes from the firewall's private address; otherwise saving is refused with the reason.
  • Hairpin NAT: servers inside the private network reach a forward on the firewall's public address too (for example your site's name pointing at the firewall); the connection arrives from the firewall's private address.
  • MTU: the firewall adjusts the TCP segment size to the path (MSS clamping), so large replies do not hang. New servers get the private network card with the network's MTU; on older servers set the MTU of the private interface to the one of the network (for example ip link set dev eth1 mtu 1450) if transfers between servers stall.
  • Fast path: established connections through the firewall take a kernel fast path; every new connection still goes through all rules.
  • Blocked sources: up to 200 addresses or networks that reach nothing behind the firewall, nor the firewall itself (VPN ports, ping).
  • State: the page shows whether both nodes loaded the rules; a node that refuses them keeps the previous ones and the page shows why, with Apply again. When only the VPN cannot start on a node (for example a site name that does not resolve), the rules still apply and the page says so (apply_state: partial).
  • Editing at the same time: a save over rules someone else changed meanwhile is refused with a message; reload and make your change again.
  • Protection: blocklists (Spamhaus DROP, FireHOL level 1), country filtering, brute-force and port-scan protection with automatic temporary blocking.

VPN

  • Remote access (WireGuard): add a device and get its configuration (and a QR code) once; the private key is never stored. By default only traffic to the private network and to the connected sites goes through the VPN; full tunnel sends everything. Devices reach the sites too: WireGuard sites directly (their AllowedIPs include the VPN network), IPsec sites as the firewall's gateway address, so nothing changes on the other side. Up to 100 devices. The VPN network must not overlap a site's networks.
  • Site-to-site (WireGuard): the other side's public key, optional endpoint and its networks. Up to 20 sites. The endpoint must be a public address (or a name that resolves to public addresses only).
  • Site-to-site (IPsec): IKEv2 with a pre-shared key to a router or another firewall, profile modern (AES-GCM, ECP384) or compatible (AES-CBC, MODP2048). The key is shown once with the settings for the other side. Up to 10 tunnels.

API: POST /firewalls, PATCH /firewalls/{id} (forwards incl. preserve_client_ip, blocked, nat, protection), PUT /firewalls/{id}/vpn, POST /firewalls/{id}/vpn/devices, /vpn/sites, /ipsec-tunnels.

Reserved IPs and VIPs

A reserved IP is a public IPv4 address that belongs to your organization until you release it.

  • Assign it to a server and move it to another one in one step (POST /reserved-ips/{id}/assign). The console shows the commands to add the address inside the server.
  • VIP: share one address between 2 to 4 servers with keepalived (VRRP over the private network, so all of them must be connected to it). The console shows a keepalived.conf for each server; the first one is the preferred master (POST /reserved-ips/{id}/vip).
  • Unassign the address before you release it; its reverse DNS is removed on release.
  • How many you can reserve depends on your plan.

Changing the IPv4 address

Server → Networking → Change IP (owners and members), or POST /servers/{id}/change-ip, gives a server a new public IPv4 address. The server restarts once (about a minute; a stopped server stays stopped). Afterwards update your DNS records and anything that allows the old address; reverse DNS is reset. The old address goes back to the pool: you cannot get it back. IPv6, reserved IPs and the private network stay. At most once every 10 minutes per server.

The new address is on the same network as the old one when that has a free address; otherwise (for example when a retiring range is replaced by one on another network) on another network. Reserved IPs work only on the network of the server's own address: if the server has reserved IPs and its network has no free address, the change is refused and the message lists them. Unassign them first, change the IP, then assign them again and use Change address: they get an address on the server's new network.

curl -X POST https://hfcloud.eu/api/cloud/v1/servers/$id/change-ip -H "Authorization: Bearer $HFCLOUD_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" -d '{"confirm":"web1"}'

When we retire an address range, servers on it show a notice in the portal and ipv4_retiring: true in the API: change their address at a time that suits you.

Price: every address change (servers, reserved IPs, load balancers, firewalls) costs a one-off fee (shown before you confirm, and as fee in the API answer), charged only when the change worked, as its own line on the next invoice. It is free while the current address is being retired.

Changing a reserved IP

Reserved IPs → Change address (owners and members), or POST /reserved-ips/{id}/change-address, replaces a reserved IP with a new address of the same location: label, mode (single or VIP) and servers move to it, and it gets a new id. While the address is assigned, send the current address as confirm and then configure the new one inside the servers: Setup commands show it (single: ip addr add and netplan, VIP: the new keepalived.conf). The old address keeps working next to the new one for about 24 hours (previous.works_until), then it is removed from the servers and goes back to the pool; Remove old address now ends that earlier. An address on no server is replaced at once. The new address is on the network of the servers' own addresses (after they changed their IP to another network, that one).

curl -X POST https://hfcloud.eu/api/cloud/v1/reserved-ips/$id/change-address -H "Authorization: Bearer $HFCLOUD_TOKEN" \
  -H "Content-Type: application/json" -d '{"confirm":"203.0.113.40"}'

Changing the address of a firewall

Firewall → Settings → Change public IP (owners), or POST /firewalls/{id}/change-ip with the name as confirm. Both nodes switch without a restart. Port forwards answer on both addresses until the old one stops (about 24 hours); outgoing NAT uses the new address at once. VPN: WireGuard device and site configs contain the endpoint address (Endpoint = <address>:<port>): change it to the new address (vpn_endpoint in the answer) or create the configs again; devices keep working through the old address until it stops. If your configs use a DNS name instead, update that DNS record. IPsec tunnels use the new address at once: the other side must set it as remote address and ID.

When the firewall's network has no free address (typically: its range is being retired and the new one is on another network), it moves to another network: the status shows upgrading and a progress block, the two nodes restart one after the other on the new network (standby first, about a minute each) and each gets a new own address there. The public address switches over to a moved node once — a few seconds, open connections are cut. The old address keeps working until the end of the grace period through a temporary second network card on each node (port forwards and VPN included), then that card is removed. The same applies to load balancers.

IPv6

Where the location has IPv6, a server with a public address also gets an IPv6 address (ipv6 in the API, a /64 prefix on the interface). Security groups apply to IPv4 and IPv6 alike.

Reverse DNS

Set the PTR record of a server's IPv4 address on Server → Network, or with PUT /servers/{id}/ptr:

curl -X PUT https://hfcloud.eu/api/cloud/v1/servers/$id/ptr -H "Authorization: Bearer $HFCLOUD_TOKEN" \
  -H "Content-Type: application/json" -d '{"hostname":"mail.example.com"}'

The name must be a fully qualified domain name with an A record pointing to the address first (forward-confirmed reverse DNS). The change is published within a minute (status goes from pending to ok). Without a name of your own the address has a default name; {"hostname": null} puts it back.

For the server's IPv6 address send "ip_version": 6; the name then needs an AAAA record pointing to that address, and {"hostname": null, "ip_version": 6} removes the record.