Get the FREE Ultimate OpenClaw Setup Guide →

hcloud-networking

npx machina-cli add skill danjdewhurst/hcloud-skills/hcloud-networking --openclaw
Files (1)
SKILL.md
16.9 KB

Hetzner Cloud Networking

Networks

Create a Network

hcloud network create --name <name> --ip-range <cidr>
FlagDescription
--nameNetwork name (required)
--ip-rangeNetwork IP range in CIDR notation (required)
--labelUser-defined labels as key=value (repeatable)
--enable-protectionEnable protection: delete
--expose-routes-to-vswitchExpose routes to connected vSwitch
-o, --outputOutput options: json|yaml

List Networks

hcloud network list

Columns: id, name, ip_range, servers, age, created, labels, protection, expose_routes_to_v_switch

FlagDescription
-l, --selectorFilter by label selector
-s, --sortSort results
-o, --outputOutput options: noheader|columns=...|json|yaml

Describe a Network

hcloud network describe <network>
FlagDescription
-o, --outputOutput options: json|yaml|format

Delete Networks

hcloud network delete <network>...

Accepts one or more networks by name or ID.

Update a Network

hcloud network update --name <name> <network>

Add a Subnet

hcloud network add-subnet --network-zone <zone> --type <cloud|server|vswitch> <network>
FlagDescription
--network-zoneName of network zone (required)
--typeSubnet type: cloud, server, or vswitch (required)
--ip-rangeRange to allocate IPs from
--vswitch-idID of the vSwitch (required when type is vswitch)

Remove a Subnet

hcloud network remove-subnet --ip-range <cidr> <network>
FlagDescription
--ip-rangeIP range of the subnet to remove (required)

Add a Route

hcloud network add-route --destination <cidr> --gateway <ip> <network>
FlagDescription
--destinationDestination network or host in CIDR notation (required)
--gatewayGateway IP address (required)

Remove a Route

hcloud network remove-route --destination <cidr> --gateway <ip> <network>
FlagDescription
--destinationDestination network or host in CIDR notation (required)
--gatewayGateway IP address (required)

Change IP Range

hcloud network change-ip-range --ip-range <cidr> <network>

The new range must contain the existing range. You can only expand, not shrink.

Expose Routes to vSwitch

hcloud network expose-routes-to-vswitch [--disable] <network>

Enables exposing routes to the connected vSwitch. Use --disable to remove exposed routes.

Labels and Protection

hcloud network add-label [--overwrite] <network> <key=value>...
hcloud network remove-label <network> (--all | <key>...)
hcloud network enable-protection <network> delete
hcloud network disable-protection <network> delete

Firewalls

Create a Firewall

hcloud firewall create --name <name>
FlagDescription
--nameFirewall name (required)
--rules-fileJSON file containing rules (use - for stdin); structure must match the API
--labelUser-defined labels as key=value (repeatable)
-o, --outputOutput options: json|yaml

List Firewalls

hcloud firewall list

Columns: id, name, rules_count, applied_to_count, age, created, labels

FlagDescription
-l, --selectorFilter by label selector
-s, --sortSort results
-o, --outputOutput options: noheader|columns=...|json|yaml

Describe a Firewall

hcloud firewall describe <firewall>
FlagDescription
-o, --outputOutput options: json|yaml|format

Delete Firewalls

hcloud firewall delete <firewall>...

Accepts one or more firewalls by name or ID.

Update a Firewall

hcloud firewall update --name <name> <firewall>

Add a Rule

hcloud firewall add-rule [options] (--direction in --source-ips <ips> | --direction out --destination-ips <ips>) (--protocol <tcp|udp> --port <port> | --protocol <icmp|esp|gre>) <firewall>
FlagDescription
--directionDirection: in or out (required)
--protocolProtocol: tcp, udp, icmp, esp, or gre (required)
--portPort or port range (e.g. 80 or 80-85); only for tcp/udp
--source-ipsSource IPs in CIDR notation (required when direction is in)
--destination-ipsDestination IPs in CIDR notation (required when direction is out)
--descriptionDescription of the rule

Delete a Rule

hcloud firewall delete-rule [options] (--direction in --source-ips <ips> | --direction out --destination-ips <ips>) (--protocol <tcp|udp> --port <port> | --protocol <icmp|esp|gre>) <firewall>

Uses the same flags as add-rule to identify and remove the matching rule.

Replace All Rules

hcloud firewall replace-rules --rules-file <file> <firewall>

Replaces all rules from a JSON file. Use - to read from stdin. The JSON structure must match the Hetzner Cloud API format.

Apply Firewall to a Resource

hcloud firewall apply-to-resource --type <server|label_selector> <firewall>
FlagDescription
--typeResource type: server or label_selector (required)
--serverServer name or ID (required when type is server)
-l, --label-selectorLabel selector (required when type is label_selector)

Remove Firewall from a Resource

hcloud firewall remove-from-resource --type <server|label_selector> <firewall>

Uses the same flags as apply-to-resource.

Labels

hcloud firewall add-label [--overwrite] <firewall> <key=value>...
hcloud firewall remove-label <firewall> (--all | <key>...)

Floating IPs

Create a Floating IP

hcloud floating-ip create --type <ipv4|ipv6> (--home-location <location> | --server <server>)
FlagDescription
--typeIP type: ipv4 or ipv6 (required)
--home-locationHome location (mutually exclusive with --server)
--serverServer to assign the IP to (mutually exclusive with --home-location)
--nameFloating IP name
--descriptionDescription
--labelUser-defined labels as key=value (repeatable)
--enable-protectionEnable protection: delete
-o, --outputOutput options: json|yaml

List Floating IPs

hcloud floating-ip list

Columns: id, name, type, ip, server, home, dns, description, age, created, labels, protection, blocked

FlagDescription
-l, --selectorFilter by label selector
-s, --sortSort results
-o, --outputOutput options: noheader|columns=...|json|yaml

Describe a Floating IP

hcloud floating-ip describe <floating-ip>
FlagDescription
-o, --outputOutput options: json|yaml|format

Delete Floating IPs

hcloud floating-ip delete <floating-ip>...

Accepts one or more floating IPs by name or ID.

Update a Floating IP

hcloud floating-ip update <floating-ip>
FlagDescription
--nameNew name
--descriptionNew description

Assign a Floating IP

hcloud floating-ip assign <floating-ip> <server>

Unassign a Floating IP

hcloud floating-ip unassign <floating-ip>

Set Reverse DNS

hcloud floating-ip set-rdns [--ip <ip>] (--hostname <hostname> | --reset) <floating-ip>
FlagDescription
-i, --ipIP address for which the reverse DNS entry should be set
-r, --hostnameHostname to set as a reverse DNS PTR entry
--resetReset the reverse DNS entry to the default value

Protection and Labels

hcloud floating-ip enable-protection <floating-ip> delete
hcloud floating-ip disable-protection <floating-ip> delete
hcloud floating-ip add-label [--overwrite] <floating-ip> <key=value>...
hcloud floating-ip remove-label <floating-ip> (--all | <key>...)

Primary IPs

Create a Primary IP

hcloud primary-ip create --type <ipv4|ipv6> --name <name>
FlagDescription
--typeIP type: ipv4 or ipv6 (required)
--namePrimary IP name (required)
--locationLocation (ID or name)
--assignee-idAssignee (usually a server) to assign the IP to
--auto-deleteDelete the IP when the assigned resource is deleted
--labelUser-defined labels as key=value (repeatable)
--enable-protectionEnable protection: delete
-o, --outputOutput options: json|yaml

Note: The --datacenter flag is deprecated. Use --location or --assignee-id instead.

List Primary IPs

hcloud primary-ip list

Columns: id, name, type, ip, assignee, assignee_id, assignee_type, auto_delete, dns, age, created, labels, protection, blocked

FlagDescription
-l, --selectorFilter by label selector
-s, --sortSort results
-o, --outputOutput options: noheader|columns=...|json|yaml

Describe a Primary IP

hcloud primary-ip describe <primary-ip>
FlagDescription
-o, --outputOutput options: json|yaml|format

Delete Primary IPs

hcloud primary-ip delete <primary-ip>...

Accepts one or more primary IPs by name or ID.

Update a Primary IP

hcloud primary-ip update <primary-ip>
FlagDescription
--nameNew name
--auto-deleteDelete the IP when the assigned resource is deleted

Assign a Primary IP

hcloud primary-ip assign --server <server> <primary-ip>

Unassign a Primary IP

hcloud primary-ip unassign <primary-ip>

Set Reverse DNS

hcloud primary-ip set-rdns [--ip <ip>] (--hostname <hostname> | --reset) <primary-ip>
FlagDescription
-i, --ipIP address for which the reverse DNS entry should be set
-r, --hostnameHostname to set as a reverse DNS PTR entry
--resetReset the reverse DNS entry to the default value

Protection and Labels

hcloud primary-ip enable-protection <primary-ip> delete
hcloud primary-ip disable-protection <primary-ip> delete
hcloud primary-ip add-label [--overwrite] <primary-ip> <key=value>...
hcloud primary-ip remove-label <primary-ip> (--all | <key>...)

Load Balancers

Create a Load Balancer

hcloud load-balancer create --name <name> --type <type>
FlagDescription
--nameLoad balancer name (required)
--typeLoad balancer type ID or name (required)
--algorithm-typeAlgorithm: round_robin or least_connections
--locationLocation (ID or name)
--networkNetwork (ID or name) to attach on creation
--network-zoneNetwork zone
--labelUser-defined labels as key=value (repeatable)
--enable-protectionEnable protection: delete
-o, --outputOutput options: json|yaml

List Load Balancers

hcloud load-balancer list

Columns: id, name, type, ipv4, ipv6, location, network_zone, health, age, created, labels, protection

FlagDescription
-l, --selectorFilter by label selector
-s, --sortSort results
-o, --outputOutput options: noheader|columns=...|json|yaml

Describe a Load Balancer

hcloud load-balancer describe <load-balancer>
FlagDescription
--expand-targetsExpand all label_selector targets
-o, --outputOutput options: json|yaml|format

Delete Load Balancers

hcloud load-balancer delete <load-balancer>...

Accepts one or more load balancers by name or ID.

Update a Load Balancer

hcloud load-balancer update --name <name> <load-balancer>

Add a Service

hcloud load-balancer add-service [options] (--protocol http | --protocol tcp --listen-port <1-65535> --destination-port <1-65535> | --protocol https --http-certificates <ids>) <load-balancer>
FlagDescription
--protocolProtocol: http, tcp, or https (required)
--listen-portListen port of the service
--destination-portDestination port on targets
--http-certificatesIDs or names of certificates (for https)
--http-redirect-httpRedirect port 80 to port 443
--http-sticky-sessionsEnable sticky sessions
--http-cookie-nameSticky sessions cookie name
--http-cookie-lifetimeSticky sessions cookie lifetime
--proxy-protocolEnable proxy protocol

Health check flags:

FlagDefaultDescription
--health-check-protocolHealth check protocol
--health-check-portHealth check port
--health-check-interval15sInterval between health checks
--health-check-timeout10sTimeout before marking unhealthy
--health-check-retries3Retries before marking as failed
--health-check-http-domainDomain for HTTP health checks
--health-check-http-pathPath for HTTP health checks
--health-check-http-responseExpected response body
--health-check-http-status-codesExpected status codes
--health-check-http-tlsVerify TLS certificate on health check

Update a Service

hcloud load-balancer update-service --listen-port <port> <load-balancer>

Identifies the service by --listen-port and accepts all the same flags as add-service to modify properties.

Delete a Service

hcloud load-balancer delete-service --listen-port <port> <load-balancer>

Add a Target

hcloud load-balancer add-target [options] (--server <server> | --label-selector <selector> | --ip <ip>) <load-balancer>
FlagDescription
--serverServer name or ID
--label-selectorLabel selector for server targets
--ipIP address for IP targets
--use-private-ipConnect to target via private network

Remove a Target

hcloud load-balancer remove-target [options] <load-balancer>
FlagDescription
--serverServer name or ID
--label-selectorLabel selector
--ipIP address of an IP target

Change Algorithm

hcloud load-balancer change-algorithm --algorithm-type <round_robin|least_connections> <load-balancer>

Change Type

hcloud load-balancer change-type <load-balancer> <load-balancer-type>

Attach to Network

hcloud load-balancer attach-to-network --network <network> <load-balancer>
FlagDescription
-n, --networkNetwork ID or name (required)
--ipIP address to assign (auto-assigned if omitted)
--ip-rangeSubnet IP range in CIDR notation (auto-assigned if omitted)

Detach from Network

hcloud load-balancer detach-from-network --network <network> <load-balancer>

Enable Public Interface

hcloud load-balancer enable-public-interface <load-balancer>

Disable Public Interface

hcloud load-balancer disable-public-interface <load-balancer>

Set Reverse DNS

hcloud load-balancer set-rdns [--ip <ip>] (--hostname <hostname> | --reset) <load-balancer>
FlagDescription
-i, --ipIP address for which the reverse DNS entry should be set
-r, --hostnameHostname to set as a reverse DNS PTR entry
--resetReset the reverse DNS entry to the default value

Protection and Labels

hcloud load-balancer enable-protection <load-balancer> delete
hcloud load-balancer disable-protection <load-balancer> delete
hcloud load-balancer add-label [--overwrite] <load-balancer> <key=value>...
hcloud load-balancer remove-label <load-balancer> (--all | <key>...)

Load Balancer Types

List Load Balancer Types

hcloud load-balancer-type list

Columns: id, name, description, max_connections, max_services, max_targets, max_assigned_certificates

FlagDescription
-l, --selectorFilter by label selector
-s, --sortSort results
-o, --outputOutput options: noheader|columns=...|json|yaml

Describe a Load Balancer Type

hcloud load-balancer-type describe <load-balancer-type>
FlagDescription
-o, --outputOutput options: json|yaml|format

Source

git clone https://github.com/danjdewhurst/hcloud-skills/blob/main/skills/hcloud-networking/SKILL.mdView on GitHub

Overview

Manage Hetzner Cloud networking resources—networks, subnets, routes, firewalls, IPs, load balancers, and vSwitch integration. This skill covers creating and updating networks, configuring firewall rules, allocating IPs, and wiring load balancers and services for scalable, secure deployments.

How This Skill Works

Use the hcloud CLI commands shown in the skill (for example, hcloud network create, hcloud firewall create, hcloud network add-subnet, hcloud network add-route, and hcloud network expose-routes-to-vswitch) to declare and modify networking resources. The tool executes these commands to apply the desired state and outputs structured results for automation.

When to Use It

  • When you need to create an isolated network for a project or cluster (specify a CIDR) and manage its subnets.
  • When you want to connect networks to a vSwitch by adding subnets and exposing routes to the vSwitch.
  • When enforcing access and traffic controls by creating and updating firewall rules.
  • When allocating and attaching floating or primary IPs for high availability or external access.
  • When deploying or reconfiguring load balancers, services, and targets to expose applications behind a stable endpoint.

Quick Start

  1. Step 1: Install and authenticate with the hcloud CLI.
  2. Step 2: Create a network: hcloud network create --name my-net --ip-range 10.0.0.0/16
  3. Step 3: Add a subnet and configure firewall rules, then attach IPs or set up a load balancer as needed.

Best Practices

  • Plan IP ranges and subnet topology before creating resources.
  • Label resources consistently for easy filtering and automation.
  • Start with restrictive firewall rules and test in staging.
  • Prefer vSwitch integration for cross-network connectivity where needed.
  • Regularly audit, back up configurations, and verify with describe outputs.

Example Use Cases

  • Create a new network with a specified CIDR (hcloud network create --name mynet --ip-range 10.0.0.0/16).
  • Add a subnet to a network with a chosen type (cloud, server, or vswitch) and zone.
  • Create a firewall with rules and apply it to a set of servers.
  • Allocate a floating IP and attach it to a server for external access or failover.
  • Create a load balancer and configure services and targets to expose an application.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers