Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

UFW (Uncomplicated Firewall) is Ubuntu’s simpler command-line front end for host firewall rules. A safe baseline is to deny unsolicited incoming connections, allow outgoing connections, permit SSH before switching the firewall on, and then add only the services your machine must expose. Check the rule list before deleting anything, and use man ufw on the target system for the syntax supported by its installed version.

What UFW is and when to use it

UFW makes common IPv4 and IPv6 host-firewall tasks easier than writing equivalent rules directly for iptables. It is available by default in Ubuntu installations since Ubuntu 8.04 LTS, although it ships disabled. While inactive, rules can be stored without being enforced; enforcement starts only after sudo ufw enable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That simplicity is also its boundary. Ubuntu Server documentation describes UFW as an easy interface for adding and removing simple rules, not a complete firewall-functionality interface. If you need an unusually complex packet-filtering design, inspect the capabilities of the underlying firewall stack and the documentation for your distribution rather than assuming every feature has a UFW command.

Inspect the current state before changing anything

Start by finding out whether UFW is active and what it will do. Nearly all administrative UFW commands require root privileges, so the examples use sudo.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
Command What it shows or does
sudo ufw status Reports whether the firewall is active.
sudo ufw status verbose Adds the default policies and logging level to the status output.
sudo ufw status numbered Lists rules with numbers, which you need when deleting a rule by number.
sudo ufw app list Shows application profiles installed on the system.

An inactive status means UFW is not enforcing its rules. It does not necessarily mean that every previously entered rule has vanished; enable the firewall only after verifying that remote access and required services are allowed.

A safe first-time setup

For a typical Ubuntu server, enter the following sequence. The order matters: the SSH exception is created before activation so a remote session is not cut off by the new incoming default.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. sudo ufw default deny incoming
    Set unsolicited inbound traffic to be denied by default.
  2. sudo ufw default allow outgoing
    Permit outbound connections unless a more specific rule changes that behavior.
  3. sudo ufw allow OpenSSH
    Allow the installed OpenSSH application profile. If that profile is unavailable, use sudo ufw allow ssh or an explicit port rule such as sudo ufw allow 22/tcp.
  4. sudo ufw enable
    Turn enforcement on. Confirm the warning before proceeding.
  5. sudo ufw status verbose
    Verify that the firewall is active, the defaults are correct, and the SSH rule is present.

If you administer the machine over SSH, never skip step 3. Enabling UFW with a deny-incoming policy and no matching SSH rule can terminate your remote access. For a new server, establish a second management path—such as a provider console or local terminal—before experimenting with rules that could affect your only connection.

Allowing services and ports

Allow a TCP or UDP port

Use an explicit port and protocol when you know exactly what should be reachable:

  • sudo ufw allow 22/tcp allows TCP port 22, commonly used for SSH.
  • sudo ufw allow 53/udp allows UDP port 53, commonly used for DNS queries.

Specifying the protocol avoids opening the other transport unnecessarily. Add only ports for services that are actually listening and that clients need to reach.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Allow a named service

For common services, UFW can use a service name instead of a numeric port:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • sudo ufw allow http
  • sudo ufw allow https

Named services depend on the service definitions available to UFW. If a name is rejected or does not map to the port you expect, use an explicit port/protocol rule and confirm the result with sudo ufw status.

Allow an application profile

Application profiles bundle a service name with its expected ports. List what is installed with sudo ufw app list, then use the displayed name. For example, sudo ufw allow OpenSSH permits the OpenSSH profile. Profile names are system-dependent, so copy the spelling shown by the command rather than assuming a profile exists.

Restrict an allowance by source address

A rule can be narrower than “any source on the internet.” To allow an entire subnet:

sudo ufw allow from 192.168.10.0/24

To allow one host to reach SSH:

sudo ufw allow from 192.168.1.7 port ssh

Source restrictions are useful for administration networks and private services. Make sure the source address or subnet is stable and is the address actually seen by the server; NAT or a proxy can make that different from the client’s local address.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Denying, rejecting, and rate-limiting traffic

Deny a port

A specific deny rule can block a service even when the port might otherwise be reachable. The documented example is:

sudo ufw deny 3306/tcp

Use a deny rule when you want an explicit exception in the rule set. Remember that a default deny-incoming policy already blocks unsolicited inbound connections that have no allow rule.

Limit repeated SSH connections

sudo ufw limit 22/tcp applies UFW’s rate-limiting behavior to TCP port 22. It is intended to slow repeated SSH connection attempts, such as brute-force bursts, while still permitting normal access. It is not a replacement for strong authentication, timely updates, or account protections.

Reject instead of silently dropping

A reject action tells the sender that the traffic was refused rather than silently discarding it. Use the reject action when that response behavior is appropriate for the service and your troubleshooting needs. Because exact argument forms can vary with the installed UFW version and rule syntax, verify the command in man ufw before applying it to a production rule set.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Delete, reload, and reset rules

Delete by rule number

First display numbered rules:

sudo ufw status numbered

Then remove the unwanted entry by its displayed number:

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

sudo ufw delete NUMBER

Replace NUMBER with the actual value. Re-run status numbered after each deletion if you are removing several entries, because the remaining rules can be renumbered.

Delete by repeating the original rule

You can also prefix the original rule with delete. For example, a rule created with sudo ufw allow 53/udp can be removed with:

sudo ufw delete allow 53/udp

Use the numbered method when duplicate-looking rules or complex source restrictions make it difficult to reproduce the original command exactly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reload versus reset

  • sudo ufw reload reapplies the current rules.
  • sudo ufw reset clears all UFW rules. Treat this as a destructive operation: record the intended policy first and be prepared to recreate required SSH and service allowances.

Logging and verification

Enable firewall logging with:

sudo ufw logging on

Other logging levels can be selected with sudo ufw logging LEVEL; replace LEVEL with a level supported by the installed UFW version. Use sudo ufw status verbose to see the current logging level. Logging can help diagnose a blocked connection, but high-volume services can produce substantial log output, so choose a level that your storage and monitoring can handle.

After any change, verify the effective rule list with sudo ufw status numbered or sudo ufw status verbose. Also check the service itself: a firewall allow rule does not start a daemon, and a listening daemon does not make a port reachable if UFW still blocks it.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure cases and recovery

“ufw enable” locked me out

The usual cause is activating UFW over SSH without an SSH allow rule. Use an out-of-band console or local terminal supplied by the machine or hosting environment, then inspect the rules and add the correct allowance—for example, sudo ufw allow OpenSSH or the actual SSH port/protocol rule. If you cannot obtain console access, the machine operator must provide a recovery path; repeated remote attempts will not bypass a host firewall.

The expected service is still unreachable

  • Run sudo ufw status verbose and confirm the rule is active, not merely stored while UFW is inactive.
  • Check that the rule uses the right protocol. A UDP allowance does not permit TCP traffic on the same number.
  • Check the source restriction and address family. A rule limited to one host or subnet will not match a different source.
  • Confirm the service is listening on the expected interface and port; UFW cannot make a stopped service listen.
  • Use logging temporarily to identify blocked traffic, then return to an appropriate logging level.

A rule was deleted accidentally

Recreate it from the service requirement, then verify with sudo ufw status numbered. If many rules were removed or the policy is unclear, do not guess: reconstruct the intended baseline, ensure SSH is allowed, and only then enable or reload UFW.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical rule-design checklist

  • Inventory services that must accept inbound connections before writing allow rules.
  • Set deny incoming and allow outgoing as the starting policy when that matches your server’s role.
  • Allow administrative access before enabling enforcement.
  • Prefer a specific protocol, port, source host, or subnet over a broad allowance.
  • Use application profiles only after checking their names with sudo ufw app list.
  • Review numbered rules before deleting, and verify again afterward.
  • Use sudo ufw reset only when you intentionally want to remove the complete UFW rule set.
  • Consult man ufw on the actual machine for authoritative, version-specific syntax. The Ubuntu wiki identifies the ufw(8) manual as the reference for current commands.

UFW command quick reference

Goal Command
Check whether UFW is active sudo ufw status
Show defaults and logging sudo ufw status verbose
Show numbered rules sudo ufw status numbered
Deny incoming by default sudo ufw default deny incoming
Allow outgoing by default sudo ufw default allow outgoing
Allow SSH profile sudo ufw allow OpenSSH
Allow SSH service name sudo ufw allow ssh
Allow a port/protocol sudo ufw allow 22/tcp
Deny a port/protocol sudo ufw deny 3306/tcp
Allow a source subnet sudo ufw allow from 192.168.10.0/24
Allow one source host to SSH sudo ufw allow from 192.168.1.7 port ssh
Rate-limit SSH sudo ufw limit 22/tcp
List profiles sudo ufw app list
Enable logging sudo ufw logging on
Enable enforcement sudo ufw enable
Disable enforcement sudo ufw disable
Reload rules sudo ufw reload
Delete rule by number sudo ufw delete NUMBER
Clear all UFW rules sudo ufw reset

Frequently Asked Questions

Is UFW enabled by default on Ubuntu?

No. UFW ships disabled, so rules are not enforced until you run sudo ufw enable.

Why should SSH be allowed before enabling UFW?

A deny-incoming policy can block the SSH connection you are using to administer the machine. Add an OpenSSH, ssh-service, or correct port/protocol allowance first.

How do I know which rule number to delete?

Run sudo ufw status numbered, identify the unwanted entry, and then run sudo ufw delete NUMBER.

Does an allow rule prove that a service is working?

No. UFW controls packet filtering; the service must also be running and listening on the expected interface, port, and protocol.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Bottom Line

Use UFW as a focused host-firewall layer: inspect first, deny unsolicited inbound traffic by default, allow SSH before activation, add narrowly scoped service rules, and verify numbered rules after every change. For syntax beyond these straightforward operations, the installed system’s ufw(8) manual is the authoritative reference.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.