Unit 3.2: Network Security: Firewall and Security Groups
Introduction
Unit 3.1 isolated FinCorp's tiers by LAN membership. Filtering is the second layer: it decides which flows are allowed between VMs that can already reach each other. IONOS CLOUD offers two mechanisms for this, and the platform's own guidance is clear about which one to prefer and about not mixing them.
The harder design question is coverage. Both mechanisms protect VMs and NICs. Anything that is not a VM or NIC you own, such as a managed load balancer, a Kubernetes node pool or a managed database, needs its control in a different place. The unit ends by building tier security groups for FinCorp and proving with a flow log that they do what the design says.
1. Two Filtering Mechanisms
1.1 The NIC-Based Firewall
The NIC-based firewall is configured per NIC. You activate it for one traffic flow type, Ingress, Egress or Bidirectional, and add rules for TCP, UDP, ICMP, ICMPv6, VRRP, GRE, AH and ESP, or any protocol. A rule can match the source MAC, the source IP or CIDR, a destination IP (useful for virtual IP addresses on the same interface), a port range, and the ICMP type and code. Four rule templates exist, Generic Webserver, Mailserver, Remote Access Linux and Remote Access Windows, and you can clone the rule set of another NIC.
Activation changes the default. Once activated, the firewall blocks all incoming traffic, and traffic passes only through explicitly enabled ports; activating it without rules blocks all incoming traffic. Outgoing traffic is generally permitted. For anything beyond simple protection of the hosts behind it, IONOS CLOUD recommends a dedicated firewall VM, even for small networks.
1.2 Network Security Groups
An NSG is a centralised firewall policy for VMs and NICs within one VDC. It contains ingress and egress rules over UDP, TCP, ICMP, ICMPv6, GRE, VRRP, ESP, AH or ANY, matched by source MAC (wildcards allowed), source IP, target IP, port range (TCP, UDP and ANY only) and ICMP type and code. Each security group acts as a stateful virtual firewall, so return traffic of an allowed flow needs no rule of its own.
NSGs come in two types. A VDC has at most one Default NSG, and every newly created VM in the VDC automatically becomes its member. Its four predefined rules are:
- Allow all IPv4 Egress traffic
- Allow all IPv6 Egress traffic
- Allow IPv4 Ingress traffic only from
10.0.0.0/24 - Allow IPv6 Ingress traffic only from the
/56IPv6 CIDR allocated to the data center
Custom NSGs carry the rules for a subset of VMs or NICs. A VM can be a member of up to 10 NSGs, and so can a NIC. When a VM is a member, all its NICs implicitly inherit the rules; when only a NIC is a member, the rules apply to that NIC alone.
The following table lists the quotas that bound the design. You can raise them through IONOS CLOUD Support.
| Limit | Value |
|---|---|
| NSGs per VDC | 200 |
| Rules per NSG | 100 |
| NSGs a VM can be a member of | 10 |
| NSGs a NIC can be a member of | 10 |
1.3 Evaluation: Allow Lists, Not Rule Sequences
Both mechanisms work as allow lists. NSG rules only permit traffic; any traffic not explicitly allowed by a rule is blocked. The NIC firewall, once active, passes only what a rule enables. Neither offers a deny rule, so there is no ordering of deny against allow to reason about. A flow passes when any applicable rule allows it.
The consequence for NSG design is that membership is additive. A VM that is a member of the Default NSG and of a custom NSG inherits the rules of both. A narrow tier group therefore cannot restrict a VM that a broad group already opens. If FinCorp's data servers stay in the Default NSG, the predefined rules still allow all egress and all ingress from 10.0.0.0/24, whatever the data-tier group says. Least privilege means editing or removing the broad default rules, or detaching the VM from the Default NSG, not adding a stricter group on top.
1.4 Choosing Between Them
IONOS CLOUD recommends NSGs for centralised, fine-grained firewall management, and advises against using NSGs in parallel with a NIC-based firewall on the same resources: NSGs act as bidirectional firewalls by default and can override or conflict with the NIC-based firewall's behaviour.
| Option | Advantages | Disadvantages | Best for |
|---|---|---|---|
| NSG per tier | One policy for many VMs; stateful; templates and cloning across data centers | Additive membership; the Default NSG's broad rules apply until you change them | Every tier with more than one VM |
| NIC-based firewall | Per-NIC precision; rule cloning between NICs | Managed NIC by NIC; must not be combined with NSGs | A single exceptional NIC that is not an NSG member |
| Firewall VM | Full control of routing and inspection | You run, patch and make it highly available | Requirements beyond allow-list filtering |
Two governance details complete the picture. Sub-users need the Create Network Security Groups privilege to create NSGs; turning the privilege off later does not stop them managing existing NSGs in a data center they can access. And after creation, every field of an NSG rule can be edited except Protocol and Type, so a wrong direction or protocol means a new rule.
2. Coverage: What NSGs Cannot Reach
2.1 The Boundary
User-created VMs and their NICs can be NSG members. Nodes of Managed Kubernetes node pools and suspended Cubes cannot be added. The managed load balancers apply their own controls: the Managed Network Load Balancer (NLB) comes with basic firewall rules derived from its forwarding rules that cannot be changed, and additional rules belong on the NICs of its targets. The following table places each control.
| Component | Where its traffic control lives |
|---|---|
| Compute Engine VMs, Cubes that are not suspended | NSGs on the VM or NIC |
| Managed Application Load Balancer, NLB | The balancer's own rules (listener, forwarding rules); NSGs on the target VMs |
| Managed Kubernetes worker nodes | In-cluster network policies (Unit 6.1) |
| Managed data services | Placement on a private LAN; NSGs on the VMs that call them |
2.2 Sources Must Match What Targets See
A managed load balancer terminates the client connection and opens its own connection to the target. Its backend exposes a private IP address to the targets as the source of client traffic, and that address defaults to x.x.x.225 in the target LAN. A tier rule that allows "the clients" therefore allows nothing useful. The rule on FinCorp's portal servers allows TCP from the ALB backend address on fc-app, and the rule on the data servers allows the database port from the NLB backend address on fc-data. Client-IP filtering, where it is needed, belongs at the balancer or in the application (Unit 3.3).
3. Flow Logs as Proof
Rules are a statement of intent; flow logs show what the platform did. A flow log captures IPv4 and IPv6 traffic flows of a VM network interface, the Managed NAT Gateway, the NLB or the Managed Application Load Balancer. Each record states whether the traffic was accepted or rejected by the software-defined network:
<version> <account-id> <interface-id> <srcaddr> <dstaddr> <srcport> <dstport> <protocol> <packets> <bytes> <start> <end> <action> <log-status>
The action field is ACCEPT or REJECT; log-status is OK, or SKIPDATA when records were skipped during the grouping interval. Records are aggregated over a 10-minute rotation interval and written to a bucket in IONOS CLOUD Object Storage as .log.gz objects named with your optional prefix and a Unix timestamp. No file is written for an interval without flows. Collection has no impact on customer resources or network performance.
The design constraints are strict:
- Immutable: you cannot change a flow log's configuration or record format after creation. To change it, delete it and create a new one.
- One per resource: one flow log per NIC, Managed NAT Gateway and NLB.
- Bucket type: flow logs operate in user-owned buckets, not contract-owned buckets.
- Retention is yours: objects stay until you delete them, or until a Lifecycle Policy on the bucket deletes them.
- Do not remove the writer: the objects are owned by the internal technical user
flowlogs@cloud.ionos.com. Deleting that user from the bucket disables the flow log service.
FinCorp runs one flow log per tier interface set to Rejected during build and test, so that every unexpected block is visible, and a Bidirectional, Any flow log on the NAT Gateway in production as egress evidence. The bucket's lifecycle policy implements the retention period that the security team signs off (Unit 5.2).
DCD Implementation Walkthrough
You will replace the broad default posture of fc-prod-fra-core with tier security groups and enable a flow log on a data-tier NIC. This realises the decision in Section 1.3: tier groups only work once the default rules no longer open the same traffic.
Prerequisites: the LANs and servers from Unit 3.1; a user-owned Object Storage bucket for flow logs (only contract administrators and owners can enable Object Storage); the Create Network Security Groups and Create Flow logs privileges, or the Administrator role.
Build goal: Apply firewall rules between tiers; enable a flow log to an Object Storage bucket.
Steps (in the Data Center Designer):
- Go to Menu > Security > Network Security Groups and select Create security group. Select the Datacenter
fc-prod-fra-core, enter Namefc-nsg-appand a Description of its purpose, and select Create. Repeat forfc-nsg-data. - Select the NAME of
fc-nsg-app(or View & Edit) and select Create Firewall Rule. Enter ProtocolTCP, TypeINGRESS, IP VersionIPv4, the ALB backend address onfc-appas Source IP, and the application port as Port Range Start and Port Range End. Select Create. - In
fc-nsg-data, create anINGRESSTCPrule from the NLB backend address onfc-datato the database port. Add anINGRESSTCPrule from your management source for SSH only if the runbook requires it; the Remote Access Linux template creates one that you can narrow. - Add
EGRESSrules each tier genuinely needs, for example DNS and HTTPS for patching through the NAT Gateway (Unit 3.6). Remember that Protocol and Type cannot be edited later. - Open the Default NSG and review its four predefined rules. Edit or delete the
INGRESSrule from10.0.0.0/24and the all-egress rules so that they no longer open traffic the tier groups are meant to restrict. - Back in the Network Security Groups window, select the checkbox of
fc-nsg-appand select Attach NSG to. Choose Server, selectfc-app-01, and choose Add selected security groups without affecting any existing ones. Repeat forfc-app-02, and attachfc-nsg-datato the data servers. - Confirm that no NIC of these servers has the NIC-based firewall activated: in the Network tab, the Firewall field should remain Disabled.
- Open
fc-prod-fra-core, selectfc-data-01, open the Network tab and the properties of its NIC. In the Flow Log drop-down list, enter a Name (it becomes the first part of the object prefix), choose DirectionIngressand ActionRejected, and enter the bucket name in Target Object Storage bucket. Do not use/or%2Fin the prefix. Select Add flow log; a green light on the NIC properties shows the configuration is valid for provisioning. - Select Provision changes and complete provisioning.
- Generate a test connection from a portal server to an unopened port on
fc-data-01, wait for the next 10-minute interval, and confirm aREJECTrecord for that flow in the bucket.
Common mistakes:
- Adding a strict tier group while the Default NSG still allows all egress and ingress from
10.0.0.0/24. Membership is additive. - Writing tier rules with the client's address as the source. Behind a managed load balancer, the source is the balancer's backend address.
- Running the NIC-based firewall and NSGs on the same NIC. The behaviours can conflict.
- Expecting an NSG to protect a managed load balancer or a Kubernetes worker node. They cannot be NSG members.
- Editing a flow log to change its direction or action. Delete it and create a new one.
- Writing flow logs to a contract-owned bucket, or removing the
flowlogs@cloud.ionos.comuser from the bucket.
Summary
FinCorp filters with NSGs per tier and keeps the NIC-based firewall off. Both mechanisms are allow lists with no rule order, so the work is in membership: the Default NSG's broad rules must be narrowed before tier groups mean anything, and every source must be what the target actually sees. NSGs end at VMs and NICs; load balancers, Kubernetes nodes and managed services get their controls elsewhere. Flow logs turn the rule set into evidence, within their immutable, one-per-resource design.
Key Points:
- NSG rules only permit traffic; anything not allowed is blocked, and rules from every group a VM belongs to add up.
- The Default NSG allows all egress and ingress from
10.0.0.0/24until you change it; every new VM joins it. - Do not run NSGs and the NIC-based firewall in parallel on the same NIC.
- Targets behind a managed load balancer see its backend address, by default
.225, as the source. - Flow logs record
ACCEPTandREJECTper flow every 10 minutes into a user-owned bucket; their configuration cannot be changed after creation.
Important Terminology:
- Additive membership: the property that a VM or NIC inherits the union of the rules of every NSG it belongs to.
- Backend address: the private address a managed load balancer uses as the source of client traffic toward its targets.