Dev.to Security 🔐 Cybersecurity 👁 0 📖 4 min read

UFW on Ubuntu Servers with Addresses from a Free /48

Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end. UFW,

Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end.

UFW, the Uncomplicated Firewall, is the default firewall front end on Ubuntu. It hides most of the netfilter complexity behind short commands and handles IPv6 alongside IPv4. Servers with globally routable addresses from your own prefix need a firewall from the first boot, because there is no NAT in front of them. This guide sets up UFW on Ubuntu servers numbered from a free IPv6 /48 from IPYE. The management network is 2001:db8:100:5::/64 and the server's main address is 2001:db8:100:10::20.

Make sure IPv6 is on

UFW only creates IPv6 rules when IPv6 support is enabled in its configuration:

grep IPV6 /etc/default/ufw

The line should read IPV6=yes, which is the default on current Ubuntu releases. If it says no, change it before adding rules, otherwise UFW will silently leave IPv6 unfiltered or unconfigured depending on the rest of your setup.

Default policies

ufw default deny incoming
ufw default allow outgoing

Deny everything inbound, allow everything outbound. That is a sensible base for a server; you add exceptions for the services it provides.

SSH from the management network only

Add the SSH rule before enabling UFW, so you do not lock yourself out:

ufw allow from 2001:db8:100:5::/64 to any port 22 proto tcp
ufw enable
ufw status numbered

If you are currently connected from outside the management network, add a temporary rule for your current address first and remove it once you have confirmed access from a management host. UFW asks for confirmation when enabling over SSH for exactly this reason.

Public services

ufw allow 80/tcp
ufw allow 443/tcp

Rules without a source or destination apply to both families, and ufw status shows each one twice, once with (v6) appended. That is normal and tells you the IPv6 rule exists.

Address-specific rules

When a server has several addresses, restrict a service to one of them:

ufw allow proto tcp from any to 2001:db8:100:10::21 port 8443

This opens port 8443 only on ::21. Address-specific rules are also useful for servers that host several services on separate addresses from your /48, each with its own exposure.

Rate-limit SSH-style services

ufw limit proto tcp from any to any port 2222

limit denies a source that opens six or more connections within thirty seconds, which slows down password-guessing attempts. Note that IPv6 attackers can rotate addresses within a /64 cheaply, so a per-address limit is weaker than it is for IPv4. Combine it with key-only authentication, which matters far more.

ICMPv6 is handled for you

UFW's packaged rules in /etc/ufw/before6.rules allow the ICMPv6 types needed for neighbour discovery, router advertisements and path MTU discovery. Do not delete them. If you need to customise ICMPv6 handling, edit that file carefully and keep the neighbour discovery and packet-too-big rules in place.

Forwarding for containers and VMs

If the server routes part of the /48 to containers or VMs, UFW's default forward policy of DROP blocks that traffic. Change DEFAULT_FORWARD_POLICY in /etc/default/ufw only if you understand the consequences, or add specific routed rules:

ufw route allow in on eth0 out on br0 to 2001:db8:100:31::/64 port 443 proto tcp

ufw route rules apply to forwarded traffic, so you can open a service on a guest without opening everything behind the bridge.

Logging

ufw logging low
journalctl -k -g UFW --since "1 hour ago"

Low logging records blocked packets that do not match the default rate limits. Raise it temporarily while debugging, and lower it again on public servers that see constant scanning.

Audit what UFW generated

UFW writes ordinary netfilter rules underneath. To see exactly what is enforced, list the generated ruleset with ip6tables -S or nft list ruleset, depending on the backend. Reading them once helps you trust the short UFW commands later.

Before the firewall: reachability

A firewall only matters if traffic reaches the server. For the /48 that means an announcement your upstream accepts, backed by the LOA from the IPYE customer portal and the ROA IPYE creates.

Next step

Claim a free IPv6 /48, set IPV6=yes, and add the management SSH rule before you run ufw enable on the first server. Questions: [email protected].

About IPYE

IPYE (https://ipye.com) leases IPv4, IPv6 and ASN space with instant setup. Your first IPv6 /48 is free for the first year, a real allocation you can announce on your own ASN, with a LOA from the portal and the ROA created automatically. ASN and region changes apply automatically. IPv4 /24 to /22 leases include LOA, ROA and per-/24 rDNS; WHOIS is editable on IPv6 /44 and larger. Locations: Los Angeles, New York, Ashburn, Salt Lake City, London, Amsterdam, Frankfurt. Claim your free /48: https://my.ipye.com/products/ipv6-rental. Questions: [email protected].

Disclosure: I run IPYE

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.