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

To block an IPv4 address or service with iptables and keep the rule after a reboot, add a correctly ordered rule to the appropriate chain, test the complete ruleset, save the working configuration to /etc/iptables/rules.v4, and have a persistence service load it at startup. A rule entered at the shell is temporary: Debian documents that iptables rules are flushed at the next reboot unless they are saved and restored.

The safest workflow is narrow and reversible. Inspect the active rules first, preserve loopback, established connections, and management access, add the DROP rule, test from a second administration session, save only the known-good rules, then verify a manual reload and a reboot.

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

What an iptables block rule does

iptables evaluates packets against chains in order. A matching DROP target discards the packet without sending a response. The chain determines where the packet is being considered:

Chain Traffic considered Typical blocking use
INPUT Traffic entering the local host Block an incoming address or a service port exposed by this host
OUTPUT Traffic leaving the local host Prevent the host from contacting a destination address or service
FORWARD Traffic routed through the host Block traffic transiting a router or gateway

For example, an incoming address belongs in INPUT, while traffic the machine itself must not send belongs in OUTPUT. A forwarded packet needs a rule in FORWARD. Selecting the wrong chain is a common reason a rule appears in the listing but has no effect.

#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: 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.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

Inspect the active rules and firewall backend

Do not append a DROP rule until you know what is already loaded. Capture both the human-readable listing and the restorable form:

sudo iptables -L -v --line-numbers
sudo iptables-save

The listing shows each chain, rule order, packet and byte counters, and targets. The saved form reveals the complete table configuration that can be restored later. Look specifically for loopback and established/related accepts, existing management rules, default chain policies, and any earlier broad accept that would prevent a later DROP from being reached.

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.

Also establish whether the host is using legacy iptables or an iptables-nft compatibility layer. Debian has used nftables as its default firewall framework since Debian 10 (Buster), while the iptables command may still be the interface administrators use. Do not assume that a command written for one backend behaves identically on every installed version; check the backend and the version supplied by the host before building a long-lived rules file.

Write a narrowly scoped DROP rule

Use the smallest match that answers the security requirement. These examples use 203.0.113.10, an address reserved for documentation; substitute the address or port you actually need to control.

Block an incoming IPv4 address

sudo iptables -A INPUT -s 203.0.113.10 -j DROP

This appends a rule to INPUT that drops packets whose source address matches. It affects traffic arriving at this host, not packets the host sends and not traffic merely routed through it.

Block an incoming TCP service port

sudo iptables -A INPUT -p tcp --dport 25 -j DROP

This blocks TCP destination port 25 on the local host. The protocol and destination-port match make it narrower than blocking every packet from a source address. If the service uses another protocol or port, the match must reflect that service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Block an outgoing destination

sudo iptables -A OUTPUT -d 203.0.113.10 -j DROP

This prevents locally generated packets destined for the address from leaving through the host. It does not block another machine from reaching that address through this host unless the traffic is routed and handled in FORWARD.

Choose between an address block and a service block

Requirement Match to use Scope
Stop one known source from reaching this host -A INPUT -s address -j DROP All protocols and ports from that source, subject to earlier rules
Stop everyone from reaching one local TCP service -A INPUT -p tcp --dport port -j DROP That TCP destination port on this host
Stop this host contacting one destination -A OUTPUT -d address -j DROP Locally generated traffic to that destination

A broad address DROP can have unintended side effects if the address is shared by legitimate users or services. A port-specific rule is usually safer when the actual requirement is to disable one service.

Put safety and management rules before broad blocks

Rule order is decisive. iptables stops processing a packet when an earlier rule accepts or drops it. A broad DROP placed before your SSH or other administration accept can lock you out; an earlier accept means a later DROP will never see that packet.

A practical filter table normally keeps these categories in a deliberate order:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Accept loopback traffic so local processes can communicate through the loopback interface.
  2. Accept packets belonging to established or related connections.
  3. Accept the administration service, such as SSH, from the addresses or networks that must manage the host.
  4. Accept any other explicitly required services.
  5. Apply narrow DROP rules for unwanted sources, destinations, or ports.

Debian’s examples include loopback, established/related state, outbound traffic, and service-port rules. Adapt those principles to the host instead of copying a blanket policy. If you administer the machine remotely, keep a second management session open while testing so that a mistake can be corrected through the other session.

Build a complete rules.v4 file

/etc/iptables/rules.v4 is a complete IPv4 ruleset, not a fragment containing only the new DROP line. A minimal filter-table file has table and chain declarations, the rules in their intended order, and a terminating COMMIT:

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【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.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -s 203.0.113.10 -j DROP
COMMIT

The example permits loopback, established and related traffic, and TCP port 22 before dropping the selected source. The chain policies shown are ACCEPT; changing a policy to DROP is a separate, much broader design decision and should not be inferred from this example. Include every rule the host needs, not just the one being added.

Because this file is for IPv4, it does not by itself govern IPv6 traffic. If the host is reachable over IPv6, it needs a corresponding IPv6 firewall policy managed through the host’s chosen firewall framework.

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

Apply and test the complete configuration

There are two safe ways to reach a known-good file: add a command-line rule, inspect the resulting complete ruleset, then save it; or edit a prepared file, restore it, and test before saving anything over the previous copy. In either case, restore the complete file with:

sudo iptables-restore < /etc/iptables/rules.v4

Restoring a complete file makes the ordering explicit and lets you test the same configuration that will be loaded at boot. From a remote session, retain a second session and test both the intended block and required administration access. Generate a packet that should match the DROP, then confirm that legitimate traffic still works. Counters in the verbose listing provide evidence that the expected rule is seeing packets:

sudo iptables -L -v --line-numbers

Check the chain, line number, target, and packet/byte counters. A zero counter does not prove a rule is wrong; it can mean the test traffic used a different protocol, port, direction, address family, or chain. Conversely, a counter increasing on an earlier ACCEPT explains why a later DROP is ineffective.

Save the known-good active rules to rules.v4

Once the complete ruleset has passed testing, serialize the rules currently loaded in the kernel:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 iptables-save | sudo tee /etc/iptables/rules.v4

This writes the active IPv4 configuration to the conventional persistent path. Using tee avoids the common shell-redirection mistake in which sudo applies to iptables-save but not to the file-opening redirection. A root shell with a redirection also works, but the command above makes the privilege boundary explicit.

Save only after testing. If you save a locked-out or syntactically incorrect configuration first, you have replaced the known-good startup file with the problem you are trying to diagnose.

Load rules automatically at startup

iptables rules in memory are not persistent. Debian states: "As IP-Tables are not persistent, they will be deleted ("flushed") with the next reboot." The Debian persistence package provides startup integration for the rules file.

Save through netfilter-persistent

When the persistence package is installed, its save operation invokes plugins to store the currently loaded rules:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo netfilter-persistent save

This is an alternative to calling iptables-save directly and is useful when the package’s plugin system manages more than one firewall backend.

Load the saved file

The package’s start operation loads persistent rules:

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.
sudo netfilter-persistent start

Use the startup integration supplied by the Debian package for the host’s release. Debian’s package template documents that current IPv4 rules can be saved to /etc/iptables/rules.v4 and loaded automatically during startup; it also points administrators to iptables-save(8) for ongoing updates. Rules may be saved automatically during package installation, but you should still inspect and verify the resulting file rather than assuming it contains the policy you intended.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify persistence without waiting for a reboot

A manual reload exercises the same file-reading path used for recovery:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Record the current listing and counters with sudo iptables -L -v --line-numbers.
  2. Reload the file with sudo iptables-restore < /etc/iptables/rules.v4.
  3. Run the verbose, numbered listing again.
  4. Confirm that the expected chains, order, targets, and management accepts are present.

A restore normally resets the active state to what the file describes, so do not treat it as a harmless display command. Perform it from a console or from the protected second management session.

After a planned reboot, repeat the numbered listing and test traffic in both directions. If the rules disappear, the problem is persistence loading rather than the DROP syntax: inspect whether the file exists at the exact path, whether the persistence service is installed and enabled for that release, and whether the service’s backend matches the command used to create the file.

Command-line rules versus a declarative rules.v4 file

Approach Strength Risk or limitation Best use
Immediate command-line rule Fast response to a live incident Exists only in memory until explicitly saved; appending can put it after an earlier accept Short, controlled changes followed by inspection and a save
Declarative rules.v4 file Records the full order and can be restored consistently A malformed or unsafe file can replace the active policy when restored Repeatable configuration and recovery
Manual restore Explicit control over when a file is loaded Someone must run it after a change or reboot Testing, rollback, and maintenance windows
Boot-time netfilter-persistent loading Restores rules automatically at startup Depends on the package, plugins, service configuration, and matching backend Hosts that must retain filtering across reboots
Legacy iptables Uses the traditional implementation and rule syntax May differ from the host’s current firewall framework Systems deliberately running the legacy backend
iptables-nft compatibility layer Lets existing iptables commands operate with nftables underneath Backend-specific behavior and mixed tooling can confuse troubleshooting Debian systems using the modern default while retaining iptables commands

The important distinction is not whether a rule was typed or stored in a file; it is whether the final, ordered ruleset is known-good and whether the same backend loads it after a restart.

Troubleshoot common failures

The blocked traffic still succeeds

  • Confirm the packet direction. Incoming traffic belongs in INPUT, locally generated traffic in OUTPUT, and routed traffic in FORWARD.
  • Check that the address, protocol, and port match the packet you are generating.
  • Inspect line numbers and counters. An earlier ACCEPT may be terminating evaluation before the DROP.
  • Check whether the traffic is IPv6; an IPv4 rule in rules.v4 cannot match it.
  • Verify that the command and the listing refer to the same iptables backend used by the host.

SSH or another management service was locked out

Use the still-open second session or an out-of-band console to restore the known-good file. The immediate cause is usually a broad DROP before the management accept, or a source-address DROP that includes the administrator. Reorder the complete file so loopback, established/related state, and the required management rule appear before the broad block, restore it, verify access, and only then save it.

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 rules vanish after reboot

  • Check that the final rules were written to /etc/iptables/rules.v4, not merely left in memory.
  • Confirm that the Debian persistence package and its startup integration are installed for the release.
  • Use sudo netfilter-persistent start to test the loader manually.
  • Inspect the post-start listing and counters to determine whether the file loaded and whether traffic is reaching the intended rule.

iptables-restore rejects the file

Compare the file with the expected complete format: a table declaration such as *filter, chain declarations, correctly formed rules, and a final COMMIT. Check spelling and module options against the iptables version installed on the host. A legacy Debian manpage may not describe every behavior of a newer installation, so use the local command’s documentation when a match or target is rejected.

The file loads but behavior changes unexpectedly

Read the entire restored listing rather than examining only the new line. A file can contain an earlier accept, a different default policy, or a rule in another chain that explains the result. Compare the saved output from iptables-save with the numbered live listing and test one direction at a time.

Operational checklist

  • Inspect iptables -L -v --line-numbers and iptables-save before editing.
  • Identify whether the command uses legacy iptables or an iptables-nft compatibility layer.
  • Choose INPUT, OUTPUT, or FORWARD from the packet’s actual path.
  • Match only the source, destination, protocol, or port that must be blocked.
  • Place loopback, established/related, and required management accepts before broad DROP rules.
  • Keep a second administration session during remote changes.
  • Restore and test the complete file, not just an isolated command.
  • Save the known-good active rules to /etc/iptables/rules.v4.
  • Use the persistence service’s save and start operations where installed.
  • Reload manually and verify order, targets, and counters before relying on a reboot.

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.