Skip to content
Serverküche
Search

Loading search … (only available on the published site).

Netcup Difficulty: Intermediate

Setting up the netcup firewall in the SCP (with the stateless-UDP trick)

Set up the netcup firewall as network protection in front of the server: composable policy templates in the SCP – with the trick for stateless UDP (DNS & NTP).

· 11 min read ·Duration: approx. 25 minutes
Table of contents

netcup comes with a firewall in front of your server – in the Server Control Panel, before a packet even reaches the operating system. Built correctly, it’s a strong shield. But there’s a trick many people fail at: the netcup firewall is stateless for UDP. This tutorial shows you a clean, reusable firewall – and why DNS and NTP otherwise suddenly get stuck.

What are we building?

In the netcup SCP we build a network firewall from composable policy templates: a base template (that every server needs), one for SSH, and one for web (HTTP/HTTPS). You assign these building blocks to your server as needed – a web server gets base + SSH + web, a server without a website only base + SSH. By the end, everything inbound is blocked except what you deliberately allow.

A netcup-specific detail makes the difference: for UDP the firewall works statelessly – which is why services like DNS and NTP need their own inbound rule, otherwise they suddenly get stuck. Why that is and how the base template solves it is shown in step 2.

Network firewall ≠ host firewall

The netcup firewall works in the network in front of the server and does not replace the firewall on the server itself (UFW). Both together are “defense in depth”: if one layer fails or is misconfigured, the other kicks in. Feel free to set up both.

Prerequisites

  • A netcup server, e.g. your first VPS.
  • Your SCP credentials (customer number + SCP password from the netcup welcome email – different from your SSH login).
  • Clarity about your SSH port: the default is 22, and it stays that way when hardening SSH. If you changed it elsewhere, use your real port – otherwise you lock yourself out when activating.
🍳 Recommendation Ad

VPS 1000 G12

4 vCores · 8 GB RAM · 256 GB NVMe

from €10.36/month

The firewall is included in the SCP with every netcup server.

Go to netcup →

💶 5 € voucher for new netcup customers: 36nc17844976032 (new customers only, no domains)

Step by step

Step 1: Open Firewall Policies in the SCP

Log into the Server Control Panel and open the Firewall Policies menu item at the top. Here you create reusable rule sets (“policies”) – independent of the individual server. You only assign them later.

Step 2: Build the base template

Click Create firewall policy, give it the name Serverküche Base and, via Add rule, create these four rules – all INBOUND and ACCEPT:

DescriptionProtocolSource port (Src)Destination port (Dst)
DNS replies (stateless)UDP53any
NTP replies (stateless)UDP123any
ICMP (ping/PMTU)ICMP
ICMPv6 (Neighbor Discovery)ICMPv6

The base template in the netcup SCP with four inbound ACCEPT rules: DNS and NTP via the source port, plus ICMP and ICMPv6
The base template: DNS/NTP replies come in via source port 53/123

Two things that make the difference here:

  • DNS/NTP via the Src Port, not the destination port. Your server queries DNS/NTP (outbound); the reply comes back from port 53 or 123. Because UDP is stateless, you need this inbound rule – otherwise there’s no name resolution and no time synchronization, even though “everything else” seems to work.
  • Never forget ICMPv6. Without Neighbor Discovery, IPv6 breaks completely. ICMP (v4) on top is useful for ping and path MTU discovery. netcup’s default policy “Ping allow” does already cover ICMP – it’s deliberately in the base template again so your foundation stays complete even if you ever remove the netcup defaults.

As soon as one rule exists, netcup blocks the rest automatically

You do not need to create a final “block everything”. Without an assigned policy, everything inbound is allowed. But as soon as you assign the server at least one of your own policies, netcup switches the default to “block all” – from then on everything inbound is blocked that none of your rules explicitly allows. So the whitelist arises on its own; outbound stays open.

Does your server use DHCP?

netcup VPS are usually configured statically (iface … inet static) – then there’s nothing to do here. netcup’s network does run a DHCP server, but because UDP is stateless, the DHCP reply (source port 67) is discarded by the whitelist. If your server is exceptionally configured via DHCP, add INBOUND · UDP · ACCEPT · Src 67 to the base template (for DHCPv6 additionally Src 547) – otherwise it loses its IP at the next lease renewal.

Step 3: Small building blocks for SSH and web

Instead of one big rule monolith, you create atomic templates that you freely combine. Create two more policies following the same pattern:

  • Serverküche SSH – one rule: INBOUND, TCP, ACCEPT, destination port 22.
  • Serverküche Web – two rules: INBOUND, TCP, ACCEPT, destination port 80 and 443.

The three composable firewall templates in the netcup SCP overview: base, SSH and web
Three small, reusable building blocks instead of one monolith

The gain: the base rules appear only once, not duplicated in every policy. If a service is added later (e.g. a mail server or WireGuard), you build another small template for it and plug it in – without touching the existing ones.

Step 4: Assign templates to the server

Switch to Server → your server → “Firewall” tab and click Edit firewall policies. Move the appropriate ones from Available firewall policies to Selected: for a web server Serverküche Base + Serverküche SSH + Serverküche Web.

The assignment dialog in the netcup SCP: on the left the available templates, on the right the ones selected for this server
Assign = plug together: base + SSH + web on a web server

Confirm with Apply and then Save. Check that the “Firewall active” switch is turned on. The assigned rules now appear in the list – together with netcup’s default policies (more on those below).

The server’s firewall tab with an active firewall and the assigned rules
Firewall active – rules are evaluated top to bottom, the first match wins

Don't lock yourself out

Only activate the firewall if the SSH rule (port 22 or your real port) is in it. During the switch, keep a second SSH session open and open a new connection in parallel to test access – only once that works do you close the old session. If you can’t get in at all, the VNC console under Display in the SCP helps.

Step 5: Ready-made templates for common services

Exactly following the pattern from step 3, here are ready-made templates for the most common self-hosting services. Each is its own small template, all rules are INBOUND and ACCEPT. Build only the ones you really need and plug them, as in step 4, into Serverküche Base + Serverküche SSH.

For UDP services: destination port, not source port

For UDP services you offer yourself (VPN, TURN, your own DNS server), the port is in the destination port (Dst) – because here clients connect to your server. That’s the opposite of the DNS/NTP rules from the base template: there the port is in the source port (Src), because your server is the querying client whose reply comes back. TCP replies aren’t affected by this (the firewall state only matters for UDP); outbound is allowed anyway.

Mail server (mailcow & co.)

DescriptionProtocolSource port (Src)Destination port (Dst)
SMTP (mail acceptance from others)TCP25
Submission (STARTTLS)TCP587
Submission (implicit TLS)TCP465
IMAP (STARTTLS)TCP143
IMAPSTCP993
POP3 (STARTTLS)TCP110
POP3STCP995
ManageSieve (filter rules)TCP4190

Two things that additionally belong to a mail server:

  • Web UI and certificates: mailcow needs 80/443 for the web interface and the Let’s Encrypt retrieval – just assign the Serverküche Web template along with it.
  • Enable outbound SMTP: a mail server must be able to deliver on port 25 outbound. netcup blocks that with the default policy “netcup Mail block” – you have to remove it on the server (see “When things go wrong”). And without a correct PTR/reverse-DNS entry your mails land in spam.

WireGuard VPN

DescriptionProtocolSource port (Src)Destination port (Dst)
WireGuardUDP51820

51820 is the usual default – use the value from your ListenPort. Only this one inbound rule is needed; the replies to the clients go out outbound.

OpenVPN

DescriptionProtocolSource port (Src)Destination port (Dst)
OpenVPN (UDP, default)UDP1194
OpenVPN (TCP fallback)TCP1194

The default is UDP 1194. The TCP rule only if you deliberately run OpenVPN over TCP (some additionally put it on TCP 443 to get through restrictive foreign networks) – otherwise leave it out.

Zabbix monitoring

Here it depends on the server’s role:

RoleDescriptionProtocolDestination port (Dst)
Monitored host (Zabbix agent)passive checks from the serverTCP10050
Zabbix servertrapper (active agents/proxies)TCP10051

The Zabbix server additionally needs 80/443 for the web frontend (Serverküche Web). If you run active checks, the agent connects outbound to the server on 10051 – for that, no inbound rule is needed on the agent host.

Checkmk

RoleDescriptionProtocolDestination port (Dst)
Monitored host (agent)agent controller, pull modeTCP6556
Checkmk server (optional)agent receiver (push/registration)TCP8000
Checkmk server (optional)Livestatus (distributed monitoring)TCP6557

In the default pull mode, the Checkmk server fetches the data actively – so it connects outbound to 6556 of the agents. Inbound, therefore, only the monitored host needs port 6556. The Checkmk server itself gets by with 80/443 (Serverküche Web); 8000 and 6557 only if you use push mode or distributed monitoring.

Coturn / TURN server (Nextcloud Talk, Matrix)

DescriptionProtocolSource port (Src)Destination port (Dst)
STUN/TURNTCP3478
STUN/TURNUDP3478
STUN/TURN over TLSTCP5349
STUN/TURN over TLSUDP5349
Media relay (audio/video)UDP49152–65535

The large UDP relay range is the default – the actual audio/video streams run over it. You can narrow it in the coturn configuration (min-port/max-port) and then set the firewall rule to the same, smaller range.

Your own DNS server (AdGuard Home, Pi-hole, Unbound)

DescriptionProtocolSource port (Src)Destination port (Dst)
DNS queriesUDP53
DNS queries (large replies/TCP)TCP53
DNS-over-TLS (DoT)TCP853

Careful, this is exactly the opposite direction to the base template: there Src 53 allows the replies to your own DNS queries; here Dst 53 allows the queries of foreign clients to your DNS server. Both exist side by side without problems.

No open resolver

A globally open recursive DNS server is abused for DNS amplification attacks. Restrict access to your own networks (set the source address in the rule) or offer DNS exclusively encrypted (DoT/DoH) for registered clients – never open 53 “just quickly” for the whole world.

Remote database access (emergency only)

DescriptionProtocolSource port (Src)Destination port (Dst)
PostgreSQLTCP5432
MySQL / MariaDBTCP3306

Databases don't belong on the open internet

A directly reachable database is a preferred attack target. The right way is to not open the port at all and instead access it via a WireGuard tunnel or an SSH tunnel (ssh -L 5432:localhost:5432 …). If you must open the port anyway, then only with a source address restricted to your fixed admin IP in the netcup rule – never for everyone.

When things go wrong

After activating, name resolution stops working (apt update hangs, ping domain.de fails, but ping 1.1.1.1 works). The DNS replies are being blocked. Check the rule in the base template INBOUND UDP ACCEPT, Src port 53. Important: source port, not destination port.

The clock drifts, or TLS certificates are rejected due to the wrong time. The NTP replies are missing. Add INBOUND UDP ACCEPT, Src port 123.

IPv6 no longer works (v4 does). The ICMPv6 rule is missing. Without Neighbor Discovery, the server can’t even find its neighbor (router) over IPv6.

After activating, you can no longer get in via SSH. The SSH rule is missing or names the wrong port. Via the VNC console (SCP → Display) you can still reach the server; correct the policy and save again. That’s exactly what the “keep a second session open” rule above helps against.

The server can’t send emails (outbound port 25 doesn’t work). That’s not an error in your policy, but netcup’s default policy “netcup Mail block” – it blocks outbound SMTP (ports 25/465/587) as spam protection. For real mail sending you have to disable this netcup template on the server.

The server initially runs normally and is suddenly offline after one or two weeks. If the server uses DHCP, the lease renewal is blocked by the whitelist – the DHCP reply comes from UDP source port 67, which no rule allows, and UDP is stateless. Add INBOUND · UDP · ACCEPT · Src 67 to the base template. Statically configured netcup VPS (the default) aren’t affected.

Maintenance & backups

  • Test access after every change. Firewall rules are the classic way to lock yourself out. Keep a second session open, check a new connection, only then finish.
  • New services = new template. If you later need another port (game server, WireGuard VPN over UDP, database), create a small template of your own and assign it additionally. The existing building blocks stay untouched.
  • Mind the order. netcup evaluates the rules top to bottom; the first matching rule wins. For pure ACCEPT rules that doesn’t matter – but as soon as you use your own DROP rules, watch the order relative to the ACCEPTs.
  • Know netcup’s default policies. “netcup Mail block” (outbound SMTP on ports 25/465/587 blocked) and “netcup Ping allow” are predefined. Via Restore default policies you can, in an emergency, get back to a known, working baseline if you locked yourself out with your own rules – together with the VNC console, your second safety net.

Last updated: Jul 19, 2026

You might also like