Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallUse UFW as the manager and place any custom iptables rules in /etc/ufw/before.rules or /etc/ufw/after.rules. UFW loads the “before” rules first, its own user rules next, and the “after” rules last. Reload UFW, then verify with sudo iptables -S or sudo ufw show raw; ufw status lists only rules created through UFW commands.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
The safe way to combine iptables and UFW
UFW (Uncomplicated Firewall) is a rule-management layer that generates and connects iptables chains to the kernel’s built-in INPUT, FORWARD and OUTPUT chains. You can still use iptables-specific matches, forwarding rules or NAT, but do not append ad-hoc rules at the shell and expect UFW to maintain them. Put persistent custom rules in UFW’s restore files instead.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
/etc/ufw/before.rules: loaded before rules created withufw alloworufw deny./etc/ufw/after.rules: loaded after UFW’s user rules.- IPv6: use
/etc/ufw/before6.rules,/etc/ufw/user6.rulesand/etc/ufw/after6.rulesfor the corresponding IPv6 policy.
Rules in these files use iptables-restore syntax, not a sequence of interactive commands. Every table block must end with its own COMMIT line. A syntax error can prevent UFW from enabling, so keep a console or a second SSH session available while testing.
Think of the files as configuration input, not scripts. A line beginning with -A appends to a named chain in the current table; it is not preceded by sudo iptables. Chain declarations and policies already present in the file are part of the same ruleset, so preserve them when editing. If you need a new chain, declare it in the relevant table before appending rules to it.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
How UFW’s chains fit into iptables
UFW creates chains including ufw-before-input, ufw-user-input, ufw-user-limit and ufw-user-limit-accept. It then jumps to those chains from the built-in chains. A command such as ufw allow 22/tcp contributes to UFW’s user-rule chains; it does not directly edit the built-in INPUT chain in the way a manually typed iptables -A INPUT ... command does.
The normal evaluation order is:
- Rules loaded from
before.rules(orbefore6.rulesfor IPv6). - UFW’s generated user rules, including rules created with
ufw allowandufw deny. - Rules loaded from
after.rules(orafter6.rules).
Within a path, the first terminating verdict that matches a packet determines what happens. Put a narrow exception before a broad drop or reject rule. A rule in before.rules can therefore accept or reject traffic before a later UFW allow rule is reached; an after.rules rule cannot override a verdict that has already terminated processing.
These are processing positions, not merely file names. A rule that returns to its caller instead of accepting or dropping lets evaluation continue, while an ACCEPT, DROP or REJECT can end the path. When diagnosing an unexpected result, identify the built-in chain, follow its jump into the relevant UFW chain, and locate the first matching terminating rule.
Which method should you use?
| Method | Survives UFW reload | Order | Visible in ufw status |
Use case |
|---|---|---|---|---|
Custom rule in before.rules |
Yes, when the file remains in place | Before UFW user rules | No; inspect iptables or ufw show raw |
Exceptions, early filtering and rules that must run before ordinary UFW allows |
Custom rule in after.rules |
Yes, when the file remains in place | After UFW user rules | No; inspect iptables or ufw show raw |
Additional filtering that should not precede UFW’s normal policy |
Interactive iptables -A |
No reliable UFW-managed persistence | Wherever the command appends it | No | Short-lived diagnostics or emergency testing only |
ufw allow or ufw deny |
Yes through UFW’s configuration | UFW’s user-rule position | Yes | Simple port, protocol and address policy |
Use the UFW command line for ordinary port policy. Use the restore files when you need iptables-specific matching, a custom chain, forwarding policy or NAT. Direct shell commands are useful for observing or testing a live ruleset, but they are outside UFW’s management model and can conflict with subsequent UFW operations.
The key trade-off is visibility versus control. A rule entered with ufw allow is easy for another administrator to find with ufw status, but it is limited to UFW’s supported policy syntax. A restore-file rule gives precise placement and match options, yet it will be invisible in the short UFW listing. Document both kinds in the same change record so no one mistakes an incomplete ufw status output for the complete firewall.
Before changing the firewall
Confirm the current policy
Record the active UFW policy and the complete iptables view before editing anything:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →sudo ufw status verbose
sudo iptables -S
sudo ufw show raw
ufw status verbose is useful for the policy you deliberately created with UFW, but it is not a complete view of the kernel ruleset. The other two commands expose chains and rules that UFW’s short status output omits. Save this output with your change notes; it gives you a before-and-after comparison if the reload behaves differently than expected.
Keep an alternate management path
Keep an already authenticated SSH session open, or use a provider console. If the new rule blocks SSH, the existing session may remain usable long enough to undo the change. Do not close that session until you have tested a new connection. Ideally, test from the same source address and protocol family that real administrators will use, because an IPv4 success does not prove IPv6 access works.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
Back up the files
sudo cp -a /etc/ufw/before.rules /etc/ufw/before.rules.bak
sudo cp -a /etc/ufw/after.rules /etc/ufw/after.rules.bak
sudo cp -a /etc/ufw/before6.rules /etc/ufw/before6.rules.bak
sudo cp -a /etc/ufw/after6.rules /etc/ufw/after6.rules.bak
Back up only the files that exist on your installation. The copies let you restore the previous configuration from a console if UFW will not start. Preserve ownership and permissions when restoring them, and keep a dated copy if you are making several firewall changes in succession.
Add a custom filter rule
Edit the existing filter table
Open the file with an editor that preserves root ownership:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →sudoedit /etc/ufw/before.rules
Most UFW installations already contain a *filter section, chain declarations and a final COMMIT. Add your rule inside that existing section, commonly in the ufw-before-input chain, and leave the table’s COMMIT at the end. Do not paste a second complete ruleset over the file.
# Example: allow TCP/2222 only from the documentation address 192.0.2.44
-A ufw-before-input -p tcp --dport 2222 -s 192.0.2.44 -j ACCEPT
The address and port above are examples. Replace them with the source network, destination port and interface policy appropriate for your server. If you add a general drop rule, place required administrative exceptions first; otherwise the drop can make later allows unreachable. Check that the service is actually listening on the selected protocol and port before concluding that the firewall rule failed.
Mirror the policy for IPv6 when needed
An IPv4 rule in before.rules does not filter IPv6 traffic. If the service is reachable over IPv6, apply an equivalent rule in /etc/ufw/before6.rules using IPv6 addresses and matches. Review both address families explicitly rather than assuming that an IPv4 policy protects the host completely. Conversely, do not copy IPv4 literals into an IPv6 file; use the correct address notation and IPv6 restore syntax.
Use after.rules for late-stage additions
If the custom rule should be evaluated only after UFW’s user rules, add it to /etc/ufw/after.rules instead. This placement is appropriate for supplementary logging or filtering that must not take precedence over an existing UFW allow. It is not the right place for an exception intended to override a broad earlier rule. If an allow in the user chain already terminates processing, an after-rule cannot undo it.
Add forwarding and NAT rules
Forwarded traffic
For routed traffic, Ubuntu’s server documentation recommends putting extra FORWARD handling in the ufw-before-forward chain inside before.rules. Treat forwarded packets separately from traffic destined for the server itself: a rule in ufw-before-input does not automatically establish a forwarding policy.
# Insert an appropriate FORWARD rule in the existing *filter section
-A ufw-before-forward -s 192.0.2.0/24 -d 198.51.100.0/24 -j ACCEPT
Use networks that actually belong to your topology. Check both directions if the application requires return traffic, and account for connection tracking and the system’s IP-forwarding setting outside the firewall rule itself. A forwarding rule alone does not turn on routing; the host must be configured to forward packets, and interfaces and routes must be correct.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
NAT and masquerading
NAT belongs in a separate *nat table block placed after the existing *filter block. Give the NAT block its own COMMIT:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 192.0.2.0/24 -o eth0 -j MASQUERADE
COMMIT
The subnet and interface are examples; substitute the real internal network and egress interface. A UFW restart is required for this block to be loaded. Keep the NAT section syntactically complete and separate from filter-chain declarations. If the host has multiple uplinks, ensure the interface match reflects the actual egress path rather than assuming eth0 exists.
Recommended Free Tools
Apply the change and verify it
- Save the file and check that every table has a matching
COMMIT. - Reload UFW using the procedure supported by your release. The broadly documented fallback is:
sudo ufw disable
sudo ufw enable
Some releases also provide sudo ufw reload; use the command documented for the target release if it is available. Because disabling and enabling can briefly change the policy, perform this from the console or with the second SSH session still open. If enabling reports an error, do not repeatedly retry from a single remote connection; inspect the error, restore the backup if necessary, and correct one change at a time.
- Inspect the resulting chains:
sudo iptables -S
sudo ufw show raw
sudo ufw status verbose
Look for the rule in the intended chain and in the intended position. Test from an allowed source and a deliberately disallowed source, and test IPv6 separately when it is enabled. The absence of a rule from ufw status is expected when that rule came from a restore file. For NAT or forwarding, verify the corresponding table and path rather than checking only INPUT.
Why direct iptables commands disappear or conflict
A command such as sudo iptables -A INPUT ... changes the running ruleset but does not write the rule into UFW’s files. It can vanish on reboot, be displaced when UFW regenerates chains, or coexist with a contradictory UFW rule. For durable configuration, copy the rule into the appropriate restore file in restore syntax and then reload UFW.
UFW may also leave rules loaded from before.rules in place when you stop or restart the service. Launchpad bug 881137 describes this behavior: developers reportedly avoided clearing built-in chains because other software may depend on them. The exact result is version-dependent. Systems that need those chains cleared should investigate the release’s MANAGE_BUILTINS setting and the before.init/after.init scripts rather than assuming that ufw disable removes every custom rule.
This means “disabled” does not always mean “the kernel has no rules from the file.” After stopping UFW, inspect the live chains and decide whether another component owns them. Removing rules blindly can break software that inserted its own jumps into the same built-in chains.
Common conflicts and failure modes
UFW will not enable after installing persistence packages
iptables-persistent and netfilter-persistent can load a saved ruleset independently of UFW. Launchpad bug 1987227 records a failure mode in which UFW cannot enable when those packages are installed, potentially leaving traffic blocked. Check which service owns the saved rules, remove duplicate ownership, and restore from the backup if enabling UFW fails. Do not allow two startup services to restore different versions of the same policy.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
The rule is present but traffic is still blocked
- Confirm that the packet reaches the chain you edited: input, forward and output traffic take different paths.
- Check whether an earlier rule returns, rejects or drops the packet before your rule is reached.
- Verify the address family; an IPv4 rule cannot match IPv6 traffic.
- Inspect counters and the complete chain listing rather than relying on
ufw status. - Check interface, protocol and destination-port assumptions against the service’s actual listener.
- Remember that a rule in the filter table cannot perform NAT, and a NAT rule does not by itself authorize forwarded traffic through the filter table.
The new rule locks out SSH
Use the open session or console to restore the backup, remove the broad rule, or add a narrowly scoped administrative exception before it. Reapply UFW only after confirming the syntax and order. Do not test a firewall reload for the first time over your sole remote connection.
Docker changes the expected path
Container runtimes can install their own chains and forwarding rules. A community recipe commonly discussed for Docker adds a DOCKER-USER jump to ufw-user-input, includes returns for private ranges, and flushes those chains from an initialization script. That approach is community guidance, not official UFW documentation, and its behavior depends on current Docker and UFW versions. Treat it as a design requiring validation on the exact host; do not paste it unchanged into production. First map the packet path created by Docker, then decide where UFW should enforce the policy and who owns the custom chain.
iptables -S does not look as expected
Newer distributions may provide iptables through the iptables-nft compatibility layer. The exact display can therefore differ from a legacy iptables host. Identify whether the host uses the legacy backend or nftables compatibility mode, and validate with the tools supplied by that distribution before interpreting chain output. Do not assume that a familiar chain listing proves that every rule is being evaluated by the same backend.
Ordering rules without accidental overrides
Design the rules from most specific to most general. A source-and-port exception should precede a network-wide drop; an established-connection rule should be considered before rules that reject new traffic; and a rule intended to run after UFW’s user policy belongs in after.rules. When reviewing a change, trace a sample packet from the built-in chain into the UFW chain and identify the first terminating verdict. This is more reliable than judging order from the text file alone, because UFW inserts jumps and generated rules around your entries.
Write down the intended result for at least three cases before reloading: an allowed connection, a denied connection and an existing connection returning traffic. Then map each case to the chain and rule that should decide it. This simple review catches the common mistake of placing an exception after a broad drop or putting an input rule on a forwarding path.
Operational checklist
- Use
ufw allow/ufw denyfor simple UFW-managed port policy. - Put persistent iptables-specific rules in
before.rulesorafter.rules, not only at the shell. - Keep IPv4 and IPv6 files aligned with the services you expose.
- Preserve each table’s chain declarations and
COMMITline. - Back up the files and keep a console or second SSH session open.
- Reload UFW, then verify with
iptables -Sandufw show raw. - Check for persistence-package conflicts, container-managed chains and the host’s iptables backend.
- Document which component owns each rule so a later administrator does not load the same policy twice.
- Test both a permitted and a forbidden source, and test each enabled address family.
- Record the expected chain, order and reload method for the specific distribution release.
Bottom line
Combining iptables and UFW works when UFW remains the owner of its generated chains and your custom logic lives in the restore files it loads. Put early exceptions and forwarding rules in before.rules, late supplementary rules in after.rules, add a separate *nat block for masquerading, reload carefully, and verify the kernel rules directly. Expect version-specific behavior around chain cleanup, Docker integration, persistence packages and nftables compatibility.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesFrequently Asked Questions
Can I run iptables commands while UFW is enabled?
You can change the live ruleset, but direct commands are outside UFW’s management model. They may disappear on reboot or conflict with a later UFW reload. Put any rule you need to keep in the appropriate UFW restore file instead.
Why does my custom rule not appear in ufw status?
ufw status lists rules created with UFW commands. Rules loaded from before.rules or after.rules are expected to be absent there. Inspect them with sudo iptables -S or sudo ufw show raw.
Best Value
Should a custom rule go in before.rules or after.rules?
Use before.rules when it must be evaluated before UFW user rules, such as an early exception, drop or forwarding rule. Use after.rules for supplementary logic that should run after ordinary UFW allows. A later rule cannot override an earlier terminating verdict.
How do I make a custom rule survive a UFW reload?
Add it to the relevant restore file using iptables-restore syntax, preserve the table structure and its COMMIT, then reload or disable and re-enable UFW using the procedure supported by your release.
Free tools Windows power users keep installed
One-click scans. No signup required.
Do I need separate rules for IPv6?
Yes. Rules in before.rules match IPv4 traffic. Use before6.rules, after6.rules and the IPv6 user rules for IPv6 addresses and traffic, and test both families when both are enabled.
Where do forwarding and masquerading rules belong?
Put extra FORWARD handling in the ufw-before-forward chain within the filter section. Put masquerading in a separate *nat block after the filter block, with its own COMMIT. Routing and IP forwarding must also be configured at the system level.
Why did disabling UFW leave my custom rules active?
Behavior varies by release. UFW may leave rules loaded from before.rules because other software can use built-in chains. Check the release’s MANAGE_BUILTINS setting and initialization scripts, and inspect the live rules before removing anything.
Can Docker and UFW share the same firewall?
They can, but Docker adds its own chains and forwarding paths. Community recipes that connect DOCKER-USER to UFW chains are version-dependent and not official UFW guidance. Map the actual packet path and validate the design on the exact Docker and UFW versions before deployment.
What should I check if UFW will not enable?
Check the restore-file syntax and every table’s COMMIT. Also look for iptables-persistent or netfilter-persistent loading a competing ruleset. Keep the backup and a console session available so you can restore safely.
The Bottom Line
Keep UFW in charge of its generated chains, store durable custom logic in before.rules or after.rules, and verify the live rules with iptables tools rather than relying on ufw status. Handle IPv6, forwarding, NAT, Docker and persistence services as separate integration points, and always reload from a safe management path.
Quick Recap
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.




