Minimal security group rules for servers
Last updated on
By default, every security group contains rules that allow all outgoing (egress) traffic. If you remove these default rules, your security group must still contain the rules described on this page. Without them, your server may not boot or behave otherwise in unforeseeable ways:
- It doesn’t receive an IP address via DHCP.
- It can’t reach the metadata service, so no hostname is set, no SSH keys are added and no user-data is applied.
Keep in mind individual services (e.g. SFS) may require additional rules. This only documents the bare minimum needed to get a functioning server.
Stateful security groups
Section titled “Stateful security groups”Stateful security groups automatically allow replies to permitted outgoing traffic. Your security group needs the following egress rules:
| Description | Protocol | Direction | Destination type | Destination | Start port | End port |
|---|---|---|---|---|---|---|
| DHCP (initial lease) | UDP | Egress | IP range | 255.255.255.255/32 |
67 | 67 |
| DHCP (lease renewal) | UDP | Egress | IP range | Your network’s IPv4 prefix | 67 | 67 |
| Metadata service | TCP | Egress | IP range | 169.254.169.254/32 |
80 | 80 |
- DHCP (initial lease): When your server boots, it sends a broadcast request to obtain its IP address.
- DHCP (lease renewal): To renew its IP address lease, your server sends a request directly to the DHCP server in your network.
- Metadata service: Your server retrieves its hostname, SSH keys and user-data from the metadata service at
169.254.169.254.
Stateless security groups
Section titled “Stateless security groups”Stateless security groups don’t automatically allow replies. In addition to the three egress rules above, add the following ingress rule:
| Description | Protocol | Direction | Source type | Source | Start port | End port |
|---|---|---|---|---|---|---|
| Metadata replies | TCP | Ingress | IP range | 169.254.169.254/32 |
1024 | 65535 |
Your server’s operating system sends each request to the metadata service from a randomly chosen local port, and the reply returns to that port. The rule therefore covers the full range of ports your operating system may use.
Replies from the DHCP server are allowed automatically and don’t require an ingress rule.
Create the rules in the STACKIT Portal
Section titled “Create the rules in the STACKIT Portal”-
On the pane on the left, click Security Groups. You can find it in the Networking section.
-
Click the security group you want to add the rules to.
-
On the pane on the right, click Create security rule.
-
Fill in the fields as listed in the tables above. Depending on the Direction you select, the portal shows Source type and Source (ingress) or Destination type and Destination (egress). Select IP range as the type.
-
Click Create.
-
Repeat these steps for each rule.
To find your network’s IPv4 prefix, click Networks in the Networking section and open the network your server’s network interface is attached to.
For general instructions, see Create and manage security groups and rules.
Recommended: DNS
Section titled “Recommended: DNS”The rules above are enough for your server to boot and apply its configuration. To resolve hostnames, for example to install updates or packages, your server also needs to reach the DNS servers configured for your network. You can find them in the details of your network.
Add the following egress rules for each DNS server:
| Description | Protocol | Direction | Destination type | Destination | Start port | End port |
|---|---|---|---|---|---|---|
| DNS | UDP | Egress | IP range | <DNS server IP>/32 |
53 | 53 |
| DNS (TCP) | TCP | Egress | IP range | <DNS server IP>/32 |
53 | 53 |
For stateless security groups, also add ingress rules for the replies:
| Description | Protocol | Direction | Source type | Source | Start port | End port |
|---|---|---|---|---|---|---|
| DNS replies | UDP | Ingress | IP range | <DNS server IP>/32 |
1024 | 65535 |
| DNS replies (TCP) | TCP | Ingress | IP range | <DNS server IP>/32 |
1024 | 65535 |
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause |
|---|---|
Your server shows the image’s default hostname (for example, ubuntu) and you can’t log in. |
Your server can’t reach the metadata service. Check the metadata service rule and, for stateless security groups, the metadata replies rule. |
| Your server has no IP address. | The DHCP (initial lease) rule is missing. |