Skip to main content

Guest roles and firewall rules

This describes the rules currently generated by the Terraform configuration. Roles are selected with guests.<name>.role; omitting role selects workload. Each role receives the shared rules below, plus its automatic permissions and any declared connections, public_ports, or internet_egress_ports.

These policies apply equally to type = "vm" (the default) and type = "lxc". Both use the same fixed-slot addressing, role/dependency generation and ordered policy. Firewall resources target the QEMU vm_id or LXC container_id endpoint as appropriate, with net0 as the firewall selector for both. Network isolation is shared; LXC uses the host kernel and is created unprivileged. See LXC setup and storage for templates, mounts, root SSH access and backup behavior.

Roles​

RoleAutomatic permissions beyond the shared rulesRestrictions and explicit configuration
workloadNo additional permissions.Declare service dependencies with connections. Public ports are allowed when explicitly listed.
public_proxyNo additional network permissions. Eligible as a DNS proxy_name target.Declare listener ports, such as TCP 80/443, in public_ports, and backend access in connections.
private_proxyWhen selected by private_proxy_name, accepts TCP 443 from each service_vpn guest and any configured service_access_cidrs. Eligible as a DNS proxy_name target.public_ports must be empty. Backend access requires connections. Other private proxies do not automatically receive family VPN or LAN service access.
admin_vpnMay initiate TCP 22 to every other declared guest, and TCP 22/8006 to host_address for Proxmox SSH/API access. Matching SSH ingress is added to the destination guests.Declare the VPN listener separately in public_ports. Host-side management permission depends on host firewall ownership, described below.
service_vpnMay initiate TCP 443 to the private proxy selected by private_proxy_name, plus TCP 3128 to the optional forward proxy selected by http_proxy_name. Matching ingress is added on each destination.Requires a declared private_proxy target. Additional outgoing connections are restricted to those same targets and ports. Declare the VPN listener in public_ports. Shared DNS/NTP and explicitly configured internet_egress_ports still apply.
managementNo additional permissions. Receives the same admin VPN SSH access as other guests.public_ports must be empty. This role grants no automatic outgoing guest administration or Proxmox management access.
monitoringMay initiate TCP and UDP on ports 1–65535 to every other declared VM or LXC, with matching ingress on each destination. Also receives direct outgoing internet TCP 80/443 by default.Guest access is scoped to each destination's /32; it grants no automatic access to the Proxmox host or other LAN addresses. Direct web egress follows protected-network drops. Additional internet ports and public listeners require explicit configuration.

Every guest can receive SSH from other guests with the admin_vpn role. With multiple admin VPN gateways, they can SSH to each other too. A role grants network permissions to the guest's assigned IP, rather than assigning permissions to individual VPN users.

Set role = "monitoring" on a guest to enable monitoring access; no connections entries are needed, and newly declared guests are included automatically. Multiple monitoring guests can monitor each other. Reply traffic is statefully allowed; the monitoring role grants no permission for other guests to initiate connections back to a monitor beyond their existing permissions. The role's TCP 80/443 internet defaults remain enabled when its internet_egress_ports list is empty.

VPN/proxy software, user authentication, TLS, DNS aliases, and reverse proxy hostname/backend routes are configured separately. The role does not select or install a software package.

Shared rules for every role​

  • Incoming and outgoing default policies are DROP.
  • The guest NIC firewall is enabled, MAC filtering is enabled, and ipfilter-net0 permits the assigned IPv4 source; HE participants also receive their single assigned ULA and the unspecified address for tightly scoped DAD. Native MAC-derived link-local filtering remains. The entry uses a bare IP, equivalent to /32, because Proxmox removes /32 on read-back; matching that form avoids unnecessary IP-set replacements.
  • With HE off (the default), incoming/outgoing IPv6 are explicitly dropped. Optional HE IPv6 assigns private IPv6 to guests with mapped ingress or effective internet egress, permits only those application rules plus scoped NDP/DAD/errors, and retains default deny. DHCP, automatic NDP and router-advertisement allowances stay disabled.
  • Outgoing DNS to each dns_servers IP is allowed on TCP and UDP 53, independently of internet_egress_ports.
  • Outgoing NTP to each ntp_servers IP is allowed on UDP 123, independently of internet_egress_ports.
  • LAN, other guest networks, host addresses, and the protected ranges are blocked except where an earlier explicit exception allows traffic.
  • Reply traffic for allowed connections is handled by Proxmox's stateful firewall. A permitted connection describes who can initiate it, rather than permitting the destination to initiate unrelated connections back.

The protected ranges include the platform aggregate, host_address/32, all configured protected_cidrs, and these fixed IPv4 ranges:

0.0.0.0/8 10.0.0.0/8 100.64.0.0/10
127.0.0.0/8 169.254.0.0/16 172.16.0.0/12
192.168.0.0/16 224.0.0.0/4 240.0.0.0/4

Settings that add permissions​

SettingGenerated behavior
connectionsConnects two declared guests, a guest to an external bare IPv4 address, or an external IPv4 host to a guest. External sources accept a bare address or /32 suffix; all external addresses must be outside platform_cidr. Guest pairs get outgoing/incoming rules; external destinations get only guest egress, and external sources get only guest ingress. Each exception is limited to its TCP/UDP destination port and precedes protected-network drops. Service VPN destination restrictions still apply.
bootstrap = trueOn that guest only, allows incoming TCP 22 from each IPv4 /32 in bootstrap_admin_cidrs, before protected-source blocks. Available to every role and defaults to false. Set it back to false and apply after setup to remove the exception. Guest bootstrap works independently of manage_host_firewall.
public_portsAllows incoming TCP/UDP on each listed destination port from 0.0.0.0/0, after protected-source blocks. There is no public source-IP allowlist. Ports 22 and 8006 are rejected for every role; private_proxy and management reject all public ports. Defaults to empty.
public_ports_lan_cidrsTop-level IPv4 subnet list in the module "hsp" block in home/main.tf, default []. These LAN sources may reach each guest's declared public_ports before protected-source drops. guests without public ports receive no exception. Subnets must be canonical, narrower than /0, and must not overlap platform_cidr.
service_access_cidrsTop-level IPv4 subnet list, default []. Allows only incoming TCP 443 to the guest selected by private_proxy_name, before protected-source drops. Requires a declared private_proxy target. Sources must be canonical IPv4 CIDRs narrower than /0, outside platform_cidr. Does not grant LAN access to Squid, SSH, Proxmox management, or other guests.
internet_egress_portsThe top-level list applies to every guest; each guest's list adds its own permissions. Lists are combined with role defaults (monitoring adds TCP 80/443), and duplicate entries removed. Both configured lists default to []. Outgoing TCP/UDP is allowed only on the declared destination ports; { protocol = "icmp" } allows portless IPv4 ICMP. Destinations must be outside protected ranges. Protected-network blocks precede these allowances.
http_proxy_nameOptional top-level guest name, default null. Every other declared guest, including service_vpn, receives outgoing TCP 3128 to that guest, with matching ingress for each client's /32. New guests are included automatically. Configure the proxy guest's internet egress separately.

Example VPN listener declarations use UDP 51820 and 51821; those ports are inventory choices, not automatic role defaults. EdgeRouter forwarding and a listening VPN service are separate requirements. Likewise, public_proxy does not automatically open TCP 80/443.

Access to existing servers during migration​

Add explicit IPv4 destinations to the existing top-level connections list in the module "hsp" block in home/main.tf, for example:

connections = [
# Keep existing guest-to-guest dependencies here too.
{ from = "http-proxy", to = "172.16.10.30", protocol = "tcp", port = 80 },
{ from = "http-proxy", to = "172.16.10.30", protocol = "tcp", port = 443 },
]

This allows http-proxy to initiate connections to that single address on TCP 80/443, including when it is inside a protected private range. Other destination addresses and ports retain their existing restrictions. The remote server's firewall and network routes are managed separately. Remove the temporary entries and apply after migration.

Use declared guest names for destinations inside platform_cidr so Terraform can configure both guests' firewalls. IP destinations accept bare IPv4 addresses, without CIDR suffixes; subnets, hostnames, and IPv6 are not supported. The service_vpn role remains restricted to its selected private and HTTP proxies.

Access from an external host​

Use an external IPv4 address as from and a declared guest name as to to allow that host to initiate a connection:

connections = [
# Keep existing connections here too.
{ from = "192.168.50.42/32", to = "cloud", protocol = "tcp", port = 443 },
]

This adds incoming TCP 443 on cloud from only 192.168.50.42/32, before protected-source drops. A bare source address such as 192.168.50.42 has the same effect. Sources must be outside platform_cidr; wider subnets, IPv6, hostnames, and connections between two external addresses are rejected. Replies use the stateful firewall; the guest receives no permission to initiate connections to the external host. Routes and the external host's firewall are managed separately.

LAN access to public ports​

Set this once at the top level of the module "hsp" block in home/main.tf to permit the chosen LAN subnets to reach all declared public services:

public_ports_lan_cidrs = ["192.168.100.0/24"]

For example, if vpn-admin.public_ports declares UDP 51821, the chosen LAN can reach that port. A public proxy declaring TCP 80/443 receives those same LAN allowances. All other guest ports retain their existing restrictions, and this setting grants no outgoing internet access. Bootstrap SSH continues to use bootstrap_admin_cidrs separately.

The EdgeRouter's aggregate route provides direct guest-IP reachability. Access through the router's public endpoint from the LAN also requires appropriate hairpin NAT. If hairpin NAT changes the source to the router's LAN IP, that address must fall inside an allowed subnet. Set the list back to [] and apply to remove the LAN public-port exceptions.

LAN access to private services​

Set this at the top level of the module "hsp" block in home/main.tf to let your LAN use the private reverse proxy directly:

private_proxy_name = "proxy"
service_access_cidrs = ["192.168.100.0/24"]

Only the selected private proxy receives TCP 443 ingress from these sources. The LAN can use the same HTTPS applications as service VPN clients without connecting to the VPN. This setting grants no Squid access on TCP 3128 and no SSH, backend, or Proxmox management access. Existing public-port LAN allowances remain controlled separately by public_ports_lan_cidrs.

The existing EdgeRouter aggregate route provides reachability; no router VLAN configuration is needed. DNS aliases for private applications must resolve to the private proxy, and the reverse proxy must have matching routes and backend connections. Replies use the stateful firewall; guests receive no new permission to initiate connections to the LAN. Set service_access_cidrs = [] and apply to remove this LAN HTTPS access.

Outbound internet ports​

Set top-level internet_egress_ports in the module "hsp" block in home/main.tf for permissions shared by every guest. Each guest's internet_egress_ports adds permissions for that guest. An empty guest list still inherits the global list. For example, add HTTPS and ICMP for one guest by setting this inside its entry:

internet_egress_ports = [
{ protocol = "tcp", port = 443 },
{ protocol = "icmp" },
]

Each entry accepts tcp or udp with an integer port from 1 to 65535, or icmp with port omitted or set to null. A numeric port on an ICMP entry is rejected. ICMP permits all IPv4 ICMP types, including ping; it does not add an incoming allowance, and replies use the stateful firewall. Allowed destinations cover IPv4 addresses outside the protected ranges; these rules do not restrict access to specific websites or package repositories. IPv6 remains blocked with HE off. With HE enabled, the same effective permissions also allow IPv6 TCP/UDP and portless ICMPv6 through the shared public source address, after protected/control drops. Egress-only guests receive IPv6 without a public forward. The former allow_updates flag has been replaced by this list. Only the monitoring role receives automatic TCP 80/443 internet access; other roles require explicit entries.

With both lists empty, replies to permitted inbound connections, approved DNS/NTP targets, and declared guest/IP dependencies remain allowed. public_ports controls incoming services separately. DNS and NTP targets remain allowed even if you configure external resolver or time-server addresses.

NTP pools​

For Debian's NTP pool, allow UDP destination port 123 globally instead of pinning pool server IPs. Pool DNS answers change over time; see the NTP Pool usage guide. Set these top-level values in the module "hsp" block in home/main.tf:

ntp_servers = []
internet_egress_ports = [
{ protocol = "udp", port = 123 },
]

ntp_servers controls fixed-IP firewall exceptions; an empty list removes those exceptions. The global UDP 123 entry allows every guest to reach public IPv4 NTP servers after protected-network drops. Replies are statefully permitted without a public inbound port. The Debian pool hostnames remain configured in the guests' time-sync service; Terraform does not configure that service or resolve the pool into a static allowlist.

Shared HTTP forward proxy​

The minimal starter does not include a forward proxy. To add one, declare an http-proxy guest with a direct DNS alias and outbound TCP 80/443, then set http_proxy_name = "http-proxy" in the HSP module call. Other guests can use http://http-proxy.home.example.com:3128 after Squid and their proxy settings are configured. Add UDP 123 explicitly if those guests use internet NTP pools.

This grants proxied web access to all declared guests, including the family VPN guest. Squid must listen on TCP 3128 and apply appropriate client and destination ACLs. Terraform provisions the guest and firewall/DNS rules; install Squid and configure proxy use inside clients separately. Access to the proxy is explicit HTTP proxying, rather than automatic redirection of all guest traffic. Proxmox blocks the proxy's connections to protected destinations except declared dependencies and narrow infrastructure exceptions. An IP dependency from http-proxy also allows Squid to relay matching requests for its clients, subject to its ACLs.

For client configuration, follow Debian guest setup for login environment variables, APT downloads, and Docker Engine proxy and logging settings.

DNS target selection and firewall dependencies are configured separately. For example, pointing app.home.example.com at proxy also requires an appropriate proxy → app backend connection and a corresponding proxy route. A DNS alias alone adds no firewall exception.

Guest rule order​

Rules are generated in this order, with the default DROP policy handling anything left unmatched:

  1. Apply IPv6 policy: blanket incoming/outgoing drops by default; for HE participants, scoped control traffic, derived hairpin exceptions before protected-network drops, then derived TCP/UDP ingress/effective internet egress. The remaining rules below are IPv4.
  2. Allow enabled bootstrap SSH, declared dependencies, and role-generated dependencies, including admin VPN management access.
  3. Allow configured LAN service sources to reach the selected private proxy on TCP 443, then approved DNS and NTP destinations.
  4. Allow configured LAN sources to reach declared public ports.
  5. Drop protected IPv4 sources and destinations.
  6. Allow configured incoming public ports from remaining sources.
  7. Allow configured outgoing internet TCP/UDP destination ports, portless ICMP, and role defaults (monitoring TCP 80/443).

This order permits narrow private-network dependencies while keeping the public-port and HTTP/HTTPS allowances from granting general LAN or guest-network access.

Proxmox host management and VPN clients​

The admin VPN role always generates its guest-side egress allowance to host_address on TCP 22/8006. Terraform configures the corresponding host-side acceptance only when manage_host_firewall = true. With its default of false, equivalent host protection and management allowances must be configured separately.

When host firewall ownership is enabled, the generated host rules allow TCP 22/8006 from the declared bootstrap administrator /32 addresses and admin VPN guest /32 addresses. They then drop IPv6 arriving on guest VNets, traffic from the platform/protected networks, and remaining IPv4/IPv6 input. This resource owns the entire node rule list; inspect/import existing configuration before enabling it.

For the initial VPN model, clients use SNAT to the respective VPN gateway guest's address. VPN software must authenticate peers and enforce client restrictions; SNAT clients share the permissions of their gateway guest. Allowing an admin VPN source IP in Proxmox does not by itself authenticate the person behind it.

Inspect the generated configuration​

The full policies and host_policy outputs are marked sensitive so Terraform collapses them in automatic plan/apply output. After applying, request an output by name to display its contents explicitly:

terraform -chdir=home output policies
terraform -chdir=home output host_policy
terraform -chdir=home output public_forwards

host_policy is generated even when host firewall management is disabled; its presence does not prove that the policy was applied. Check effective rules and packet behavior on Proxmox during the deployment acceptance checks.

The source of truth is role/dependency generation, inventory validation, shared guest rule generation, and firewall resource configuration.

Optional IPv6 forwarding and egress​

The IPv6 guide explains the shared public address and per-slot ULA /64s. With HE enabled, guest TCP/UDP public_ports automatically generate IPv6 forwards. Each protocol/port pair must have one guest owner; duplicate ownership blocks planning. Existing named connections and role-generated administration/monitoring dependencies remain IPv4-only. Effective internet permissions also apply to IPv6; outgoing ICMP includes ping, while RA/RS/redirect/nonlocal NDP remain denied.

The host's independent HE INPUT guard closes undeclared listeners even when manage_host_firewall = false. In that mode, additional transport/control acceptance remains operator-owned and is described by ipv6_host_requirements; no full node-firewall takeover occurs. Required related ICMPv6 errors precede application-source protection, including errors from a protected tunnel peer. Native guest source/MAC filters and protected networks remain enforced.

A managed guest can reach a public TCP/UDP service through the VIP when its effective internet egress permits that protocol/port OR an explicit connections entry permits that directed source-to-target protocol/port. The same egress rule applies to self-hairpin. Public listeners alone do not authorize clients. Role-generated guest connections remain IPv4-only. Explicit-connection-only clients receive IPv6 without internet or listener allowances. Targets see their ULA gateway as the client; external ingress preserves real client identity. Exact outgoing VIP/128 and incoming gateway/128-to-target/128 exceptions precede protected drops, while the routed guard prevents direct ULA access. LAN/VPN-prefix and Proxmox-originated hairpin are excluded. See the hairpin contract and pending live checks.