<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Firewalls on datahacker</title>
		<link>https://datahacker.blog/reference/networking/firewalls/</link>
		<description>Recent content in Firewalls on datahacker</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Mon, 23 Nov 2026 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://datahacker.blog/reference/networking/firewalls/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Chart: iptables Command Matrix</title>
				<link>https://datahacker.blog/reference/networking/firewalls/chart-iptables-command-matrix/</link>
				<pubDate>Tue, 27 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/chart-iptables-command-matrix/</guid>
				<description>&lt;p&gt;This matrix summarizes common IPv4 iptables matches and targets. Each syntax cell is a &lt;strong&gt;rule fragment&lt;/strong&gt;, not a complete command. Add the table, chain operation, appropriate match restrictions, and target when assembling a rule.&lt;/p&gt;&#xA;&lt;p&gt;The placement column gives compatible table/chain pairs or explicit restrictions. Example placements are not an exhaustive list of every supported hook. Kernel, backend, and extension availability still apply. In particular, separate table and chain names cannot be freely combined: &lt;code&gt;filter/POSTROUTING&lt;/code&gt; does not exist.&lt;/p&gt;</description>
			</item>
			<item>
				<title>iptables Chains and Extensions</title>
				<link>https://datahacker.blog/reference/networking/firewalls/iptables-chains-and-extensions/</link>
				<pubDate>Sun, 25 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/iptables-chains-and-extensions/</guid>
				<description>&lt;p&gt;&lt;code&gt;iptables&lt;/code&gt; extensions add packet matches and target operations. A match tests a condition; a target performs an action after all the rule&amp;rsquo;s matches succeed. The kernel applies the installed rules to packets.&lt;/p&gt;&#xA;&lt;p&gt;Availability depends on the kernel, backend, and installed extensions. The tables below give valid example placements and important restrictions. A chain name alone is insufficient: for example, &lt;code&gt;POSTROUTING&lt;/code&gt; exists in &lt;code&gt;mangle&lt;/code&gt; and &lt;code&gt;nat&lt;/code&gt;, but not in &lt;code&gt;filter&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is a selection of common extensions. See &lt;a href=&#34;https://man7.org/linux/man-pages/man8/iptables-extensions.8.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34; title=&#34;Opens in a new tab&#34;&gt;iptables-extensions(8)&lt;/a&gt; for the complete interface, and the &lt;a href=&#34;https://datahacker.blog/reference/networking/firewalls/iptables-commands/&#34;&gt;command reference&lt;/a&gt; for explanations.&lt;/p&gt;</description>
			</item>
			<item>
				<title>iptables Commands</title>
				<link>https://datahacker.blog/reference/networking/firewalls/iptables-commands/</link>
				<pubDate>Sun, 25 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/iptables-commands/</guid>
				<description>&lt;p&gt;The &lt;code&gt;iptables&lt;/code&gt; command manages IPv4 packet-filtering and NAT rules in the Linux kernel. A rule can match addresses, protocols, interfaces, connection state, and other attributes before selecting a target.&lt;/p&gt;&#xA;&lt;p&gt;This reference covers command structure, chain and rule operations, common match extensions, and targets. It uses the traditional iptables table and chain names. &lt;code&gt;iptables -V&lt;/code&gt; identifies whether the installed command uses the legacy or nftables backend; kernel configuration and installed extensions determine which features are available.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Follow the (ip) Rules</title>
				<link>https://datahacker.blog/reference/networking/firewalls/follow-the-ip-rules/</link>
				<pubDate>Sat, 24 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/follow-the-ip-rules/</guid>
				<description>&lt;p&gt;Hopefully, you have already read and/or understand these concepts:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://datahacker.blog/reference/networking/routing/policy-based-routing/&#34;&gt;Policy Based Routing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://datahacker.blog/reference/networking/routing/iproute-and-routing-tables/&#34;&gt;iproute and Routing Tables&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://datahacker.blog/reference/networking/routers-routes-subnets-and-netmasks/&#34;&gt;Routers, Routes, Subnets, and Netmasks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now, it&amp;rsquo;s time to talk about &lt;em&gt;ip rules&lt;/em&gt;. The Routing Policy Database (RPDB) selects an action, often a lookup in a routing table. The usual IPv4 rules consult &lt;code&gt;local&lt;/code&gt;, &lt;code&gt;main&lt;/code&gt;, and &lt;code&gt;default&lt;/code&gt;. Those lookups choose routes; they do not grant firewall permission to all traffic.&lt;/p&gt;&#xA;&lt;p&gt;Routes and rules added at the command line affect the live kernel state. Save or reapply them through the system&amp;rsquo;s network configuration if they should survive reboot. Firewall-rule persistence is a separate concern; see &lt;a href=&#34;https://datahacker.blog/tutorials/networking/firewalls/persistence-making-iptables-changes-stick/&#34;&gt;Persistence: Making iptables Changes Stick&lt;/a&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Helpful Tips (iptables)</title>
				<link>https://datahacker.blog/reference/networking/firewalls/helpful-tips-iptables/</link>
				<pubDate>Sat, 24 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/helpful-tips-iptables/</guid>
				<description>&lt;p&gt;Here are a few helpful tips related to rule and route testing.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span id=&#34;section-1&#34;&gt;&lt;/span&gt;&lt;/p&gt;&#xA;&lt;h3 id=&#34;migration-heading-1&#34;&gt;Changes Take Effect Without a Routine Cache Flush&lt;/h3&gt;&#xA;&lt;p&gt;Successful &lt;code&gt;ip route&lt;/code&gt;, &lt;code&gt;ip rule&lt;/code&gt;, and &lt;code&gt;iptables&lt;/code&gt; changes update the running kernel configuration. A cache flush does not reload those settings from disk. Linux removed the old IPv4 route cache in kernel 3.6; do not use &lt;code&gt;ip route flush cache&lt;/code&gt; as a routine activation step.&lt;/p&gt;&#xA;&lt;p&gt;Inspect the affected rules and routes, then test a new connection while keeping recovery access available. Existing connection-tracking or NAT state can make an established connection behave differently from a new one.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Persistence: Making iptables Changes Stick</title>
				<link>https://datahacker.blog/tutorials/networking/firewalls/persistence-making-iptables-changes-stick/</link>
				<pubDate>Sat, 24 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/tutorials/networking/firewalls/persistence-making-iptables-changes-stick/</guid>
				<description>&lt;p&gt;One of the challenges of &lt;em&gt;iptables&lt;/em&gt;, routes, and rules (&lt;em&gt;iprules&lt;/em&gt;) is making changes to them permanent. Any changes you make on-the-fly only last until the next system restart. However, there are several ways of making them persist through reboots.&lt;/p&gt;&#xA;&lt;p&gt;Choose one of the methods below to store your changes in user-manageable scripts that are run every time your server is restarted.&lt;/p&gt;&#xA;&lt;div id=&#34;section-1&#34;&gt;&lt;/div&gt;&#xA;&lt;div id=&#34;migration-heading-1&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;method-1-systemd-start-up-process&#34;&gt;Method #1: &lt;em&gt;systemd&lt;/em&gt; Start-Up Process&lt;/h2&gt;&#xA;&lt;p&gt;This method uses two services: one to establish the firewall before normal network configuration, and another to apply routing policy after the interface and source address are ready. The demonstrated network manager is &lt;em&gt;NetworkManager&lt;/em&gt;, with a dependency that requires successful firewall startup. The original example was written on Ubuntu 16.04. This revised design still needs validation on the system where you intend to use it.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Testing Your iptables Rules</title>
				<link>https://datahacker.blog/tutorials/networking/firewalls/testing-your-rules-iptables/</link>
				<pubDate>Sat, 24 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/tutorials/networking/firewalls/testing-your-rules-iptables/</guid>
				<description>&lt;p&gt;It may not be obvious, but you need to test your rules—both routing rules (via &lt;code&gt;ip rule&lt;/code&gt;) and &lt;em&gt;iptables&lt;/em&gt; rules—before you cement them in place.&lt;/p&gt;&#xA;&lt;p&gt;One useful thing about testing rules before making them permanent is that changes made only to the running configuration do not normally survive a reboot. If you make a catastrophic screw-up, restarting the server may get you back to a working configuration—provided nothing saves or reloads those changes at startup.&lt;/p&gt;</description>
			</item>
			<item>
				<title>iptables Protocols</title>
				<link>https://datahacker.blog/reference/networking/firewalls/iptables-protocols/</link>
				<pubDate>Tue, 20 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/iptables-protocols/</guid>
				<description>&lt;p&gt;The &lt;code&gt;-p&lt;/code&gt; or &lt;code&gt;--protocol&lt;/code&gt; option selects an IP protocol. TCP and UDP provide transport-layer source and destination ports; protocols such as ICMP use different fields and do not have TCP/UDP port numbers.&lt;/p&gt;&#xA;&lt;p&gt;Protocol-specific matches can be combined with other matches in one rule. Each condition must succeed. The examples below are rule fragments, not complete commands: the table, chain operation, other restrictions, and target belong to the surrounding rule.&lt;/p&gt;&#xA;&lt;p&gt;Ordinary &lt;code&gt;--sport&lt;/code&gt;/&lt;code&gt;--dport&lt;/code&gt; options accept one port or one colon-separated range. A comma-separated list requires &lt;code&gt;-m multiport&lt;/code&gt;; its list has at most 15 slots, with a range counting as two. That limit belongs to &lt;code&gt;multiport&lt;/code&gt;, not to the number of ports covered by an ordinary range. These forms follow &lt;a href=&#34;https://man7.org/linux/man-pages/man8/iptables-extensions.8.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34; title=&#34;Opens in a new tab&#34;&gt;the extension manual&lt;/a&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>iptables Process Flow: Chains, Tables, and Rules</title>
				<link>https://datahacker.blog/reference/networking/firewalls/iptables-process-flow-chains-tables-and-rules/</link>
				<pubDate>Mon, 19 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/iptables-process-flow-chains-tables-and-rules/</guid>
				<description>&lt;p&gt;The terms &lt;em&gt;table&lt;/em&gt;, &lt;em&gt;chain&lt;/em&gt;, and &lt;em&gt;hook&lt;/em&gt; describe different parts of packet filtering. A table contains chains, and each chain contains an ordered list of rules. Netfilter hooks are points in the kernel&amp;rsquo;s packet path. Built-in iptables chains are attached to those hooks; for example, &lt;code&gt;mangle/OUTPUT&lt;/code&gt; and &lt;code&gt;filter/OUTPUT&lt;/code&gt; are separate chains in separate tables at the OUTPUT hook.&lt;/p&gt;&#xA;&lt;p&gt;When no &lt;code&gt;-t&lt;/code&gt; option is supplied, iptables uses the &lt;code&gt;filter&lt;/code&gt; table. Specify the table and chain explicitly when their distinction matters. A rule in &lt;code&gt;filter/INPUT&lt;/code&gt; will not inspect ordinary forwarded traffic, which uses FORWARD instead. The available built-in chains differ by table; packets do not traverse all five tables and all five hooks.&lt;/p&gt;</description>
			</item>
			<item>
				<title>iptables and ipchains</title>
				<link>https://datahacker.blog/reference/networking/firewalls/iptables-and-ipchains/</link>
				<pubDate>Sat, 17 Aug 2019 00:00:00 +0000</pubDate>
				<guid>https://datahacker.blog/reference/networking/firewalls/iptables-and-ipchains/</guid>
				<description>&lt;p&gt;The &lt;a href=&#34;https://datahacker.blog/reference/networking/linux-netfilter-tools/#packet_routing_tree&#34;&gt;networking overview&lt;/a&gt; shows how routing decisions and Netfilter hooks fit into the packet path. &lt;code&gt;iptables&lt;/code&gt; is a userspace tool for configuring IPv4 filtering and related kernel rules. It is not the routing engine and is not specific to Ubuntu.&lt;/p&gt;&#xA;&lt;p&gt;Check the installed version and backend before following a historical example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;iptables --version&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Modern installations may use iptables syntax through the nftables compatibility backend. The &lt;a href=&#34;https://man7.org/linux/man-pages/man8/xtables-nft.8.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34; title=&#34;Opens in a new tab&#34;&gt;xtables-nft manual&lt;/a&gt; explains that distinction. The examples below use iptables syntax; table and extension availability depends on the installed tools and kernel.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
