Security & Backups9 min read•Last updated: •By SkyRain Cloud Team

Firewall Setup Best Practices for Dedicated Servers

Run a quick port scan against a freshly installed server and you will often find more open doors than you expected: a database listening on all interfaces, a forgotten admin panel, a test service from setup day. Every open port is something an attacker can probe. A good dedicated server firewall closes everything that does not need to be public and controls exactly who can reach the rest.

The short answer: start from "deny all inbound", allow only the ports your services need, restrict admin access to known IPs or a VPN, cover IPv6 as well as IPv4, log what you drop and test from outside. This guide explains the principles, gives example rules for UFW, nftables and Windows Firewall, and shows how the server firewall fits with your provider's network protection.

Quick answer

Best practice for a dedicated server firewall is a default-deny inbound policy, explicit allow rules only for required services (for example SSH from trusted IPs, HTTP and HTTPS), databases and admin panels bound to localhost or a private network, rate limits on login and connection floods, matching rules for IPv6, logging of dropped traffic, and regular external testing. Combine it with your provider's upstream DDoS protection, which handles floods before they reach the server.

Where the server firewall fits

A firewall is one of the oldest and most reliable security controls, and on a dedicated server you control it completely. That freedom is powerful, but it also means nobody else will notice if a rule is wrong. Protection works in layers. The provider's network filters large floods and attack traffic before it reaches your port; see protecting a dedicated server from DDoS attacks. The firewall on your server decides which connections reach which services. Applications then authenticate users and enforce permissions. Each layer catches what the others miss.

LayerHandlesDoes not handle
Provider DDoS protectionVolumetric floods, protocol attacksWhich services you expose
Server firewallPort access, source restrictions, rate limitsLarge floods that fill the port
Web application firewallMalicious HTTP requestsNon-web services
ApplicationAuthentication, authorisationNetwork-level attacks
Dedicated server firewall – SkyRain Cloud bare metal servers in India

Dedicated server firewall principles

  1. Default deny inbound. Nothing is reachable unless a rule allows it.
  2. Least exposure. Only public services (usually 80 and 443) are open to everyone.
  3. Restrict admin access. SSH, RDP, control panels and IPMI only from office IPs or through a VPN.
  4. Bind internal services privately. Databases, caches and queues listen on localhost or a private network.
  5. Rate-limit new connections to login services.
  6. Cover IPv6. A locked-down IPv4 firewall with open IPv6 is a common gap.
  7. Log and review dropped connections.
  8. Document every rule and why it exists.

Typical ports for a business server

ServicePortWho should reach it
HTTP / HTTPS80 / 443Everyone
SSH22 (or custom)Admin IPs or VPN only
Remote Desktop3389VPN or gateway only, never public
MySQL / PostgreSQL3306 / 5432Localhost or private network
Redis6379Localhost only
Mail (SMTP, submission, IMAP)25, 587, 993As needed if you host mail
VPN (WireGuard)51820/udpStaff devices
Control panelVariesAdmin IPs or VPN

Example: UFW on Ubuntu

UFW is a simple front end for the Linux firewall. The Ubuntu UFW guide covers all options. A typical web server:

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 203.0.113.10 to any port 22 proto tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw limit 22/tcp
sudo ufw enable
sudo ufw status verbose

Replace the example IP with your office or VPN address. Make sure IPV6=yes is set in UFW's defaults so the same rules apply to IPv6.

Example: nftables

For more control, nftables (the modern replacement for iptables) lets you write rules directly. The nftables wiki is the reference. A minimal policy accepts established connections, loopback traffic, HTTPS from anywhere and SSH from a trusted range, and drops the rest. Keep rules in a file under version control so changes are reviewed.

Windows Firewall on Windows Server

  • Keep Windows Defender Firewall enabled on all profiles.
  • Restrict Remote Desktop to a VPN subnet or gateway, never to "Any".
  • Remove broad allow rules created by installers you no longer need.
  • Use group policy to manage rules consistently on several servers.

Rate limiting and brute-force protection

Firewall rate limits slow down attackers trying many connections. Combine them with Fail2ban, which reads logs and blocks IPs that fail authentication repeatedly. For web applications, also rate-limit login, search and API endpoints at the web server or reverse proxy level; our guide to setting up a reverse proxy shows where those limits live. Tune limits carefully: set them too tight and legitimate users behind a shared office or mobile network IP may be blocked, so start generous, watch the logs and tighten gradually.

Watch out for Docker

Docker manipulates firewall rules directly, and published container ports can bypass UFW rules. Publish ports only on localhost (for example 127.0.0.1:8080:80) and put a reverse proxy in front, or configure Docker's firewall integration deliberately. Test from outside after every change.

Do not forget outbound rules

Most guides focus on inbound traffic, but outbound rules matter too. If an attacker does get in, one of the first things they try is connecting out: downloading tools, sending spam or joining a botnet. Many servers allow all outbound traffic by default, which is convenient but generous. For higher-risk servers, consider allowing outbound connections only to what the server genuinely needs: package repositories, your backup destination, payment and email APIs, DNS and time servers. At minimum, block outbound SMTP on servers that should never send mail directly, which stops a compromised web app from becoming a spam cannon and damaging your IP reputation.

Designing admin access properly

The cleanest pattern for small and mid-size businesses is to put every administrative service behind a VPN. Staff connect to a WireGuard or OpenVPN endpoint on the server, then reach SSH, control panels and databases over private addresses. From the public internet, only the VPN port and your public websites are visible. This removes most brute-force noise, makes access easy to revoke when someone leaves and gives auditors a simple answer about how administrators connect. If a VPN is not practical, allow admin ports only from fixed office IPs, and keep a documented, secure way in through IPMI or iLO for emergencies.

Making firewall changes safely

Firewall mistakes can lock you out or silently expose a service. Make changes in a calm window, keep an existing SSH session open while you test a new rule from a second session, and on Linux consider a timed rollback: apply a rule set with an automatic revert in a few minutes unless you confirm it works. Record every change with the date, the person and the reason, so the rule list never becomes a mystery.

Test from the outside

  1. From another machine, scan your server's public IPv4 and IPv6 addresses with nmap.
  2. Compare open ports with your documentation.
  3. Check that databases and admin panels are not reachable.
  4. Repeat after every software install or configuration change.

Common firewall mistakes

  • Enabling a firewall without first allowing SSH, then losing access.
  • Opening database ports to the internet for "temporary" testing.
  • Forgetting IPv6 rules.
  • Docker exposing container ports past UFW.
  • Allowing RDP from anywhere.
  • Never reviewing or cleaning up old rules, so nobody remembers why a port is open.

For the complete first-day routine, follow how to secure a dedicated server; for SSH specifics, see SSH security best practices.

Why businesses choose SkyRain Cloud dedicated servers

SkyRain Cloud dedicated servers give your firewall strong backing:

  • Indian data centers, Indian latency. Intel Xeon dedicated servers are hosted in Mumbai and Delhi, close to customers across India.
  • The whole machine is yours. 100% unshared hardware: no other tenants competing for CPU, memory or disk.
  • DDoS protection included on the network, so a flood aimed at your IP does not have to become your problem alone.
  • Full control. Root or Administrator access plus iLO/IPMI out-of-band management to reboot, reinstall or mount your own ISO.
  • Real support channels. 24/7 support tickets, WhatsApp and a Discord community, plus a public status page.
  • Simple billing. Monthly billing in rupees with UPI, net banking and cards.

Frequently Asked Questions

Which firewall should I use on a Linux dedicated server?
UFW is simple and good for most servers. nftables offers more control for complex setups. Both configure the same underlying Linux firewall.
Which ports should be open on a web server?
Usually only 80 and 443 for everyone, plus SSH restricted to admin IPs or a VPN. Databases and caches should not be reachable from the internet.
Does a server firewall stop DDoS attacks?
It helps with small floods and connection limits, but large volumetric attacks fill your port before the firewall sees them. Upstream provider protection is needed for those.
Why does Docker bypass my UFW rules?
Docker inserts its own firewall rules for published ports. Publish ports on localhost only, use a reverse proxy, or configure Docker's firewall integration carefully.
What if I lock myself out with a firewall rule?
Use IPMI, iLO or KVM console access to log in locally and fix the rule. SkyRain Cloud dedicated servers include iLO access for this.
Should I change the SSH port?
It reduces log noise from automated scans but is not real security on its own. Use SSH keys, disable password login and restrict access by IP or VPN.

Conclusion

A strong dedicated server firewall is simple in principle: deny by default, open only what must be public, restrict admin access, keep internal services private, cover IPv6 and test from outside. Pair it with provider DDoS protection and application security for layered defence.

Compare SkyRain Cloud's plans below, or see the full specs on our dedicated server page.

SkyRain Cloud Dedicated Server Plans

Unshared Intel Xeon bare-metal servers in Mumbai and Delhi data centers with 1 Gbps connectivity. Every plan includes iLO / IPMI out-of-band management, DDoS protection, Full root / Administrator access, Additional IPv4 addresses available and Billed monthly.

PlanCores / ThreadsRAMStorageNetworkPriceGood forBuy
Business
2× Intel Xeon E5-2699 v4 (Mumbai / Delhi)
44 / 88 (2.2 GHz base, 3.6 GHz turbo)128 GB DDR4 ECC1 TB NVMe SSD1 Gbps₹17,999/monthBusiness websites, stores, databases, ERP and many client sitesOrder
Enterprise
2× Intel Xeon Platinum 8269CY (Mumbai / Delhi)
52 / 104 (2.5 GHz base, 3.8 GHz turbo)128 GB DDR4 ECC1 TB NVMe SSD1 Gbps₹19,999/monthVirtualization hosts, large databases, SaaS and container platformsOrder
CustomMore RAM or storage, a second server for failover, or several servers for a cluster: quoted by the team.Clusters, failover pairs, unusual specsAsk

Prices are monthly in INR as listed on the SkyRain Cloud store (verified 2026-11-23). Live stock and final price are shown at checkout.

Instant UPI • ₹649/mo
Fast KVM Cloud Provisioning