{"id":534,"date":"2026-06-28T03:12:18","date_gmt":"2026-06-28T03:12:18","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=534"},"modified":"2026-08-17T22:13:20","modified_gmt":"2026-08-17T22:13:20","slug":"vps-firewall-configuration-guide-ufw-iptables-nftables-2026","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/","title":{"rendered":"iptables vs nftables on a VPS: Which to Run and How to Migrate"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">iptables and nftables are not two competing firewalls so much as two generations of the same one. If you still write rules with the classic <code>iptables<\/code> commands, there is a good chance they are being executed through a translation layer on top of nftables without you knowing it. Before you tune either, make sure the underlying host is worth the effort: compare managed and unmanaged plans on our <a href=\"https:\/\/virtualserversvps.com\/#providers\">VPS comparison table<\/a>, because no firewall setting can compensate for an oversold or rate-limited server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why nftables Is the Default on Modern Distros<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">nftables has been in the kernel since 3.13 (2014), and every major distribution now ships it as the firewall backend. On Debian 10+, Ubuntu 18.04+, and recent RHEL releases, the <code>iptables<\/code> binary you type at the shell is almost certainly <code>iptables-nft<\/code> \u2014 a compatibility shim that translates legacy syntax into nftables netlink calls. You can confirm this in seconds:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># On any modern distro this prints \"(nf_tables)\"\niptables --version\n\n# And nftables itself is present\nnft --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That has two practical consequences. First, legacy iptables rules still work, so there is no emergency migration pressure. Second, mixing both tools on one host is asking for confusion: the <code>iptables<\/code> shim and native <code>nft<\/code> manage the same kernel ruleset but expose different views of it, and rules you add with one can silently surprise you when you inspect with the other. Pick one interface and standardize on it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Actually Differs Under the Hood<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Aspect<\/th><th>iptables (legacy)<\/th><th>nftables<\/th><\/tr><\/thead><tbody><tr><td>Rule storage<\/td><td>Four hardcoded tables (filter, nat, mangle, raw)<\/td><td>Named tables and chains, your own structure<\/td><\/tr><tr><td>Atomic updates<\/td><td>Per-rule append\/insert; full reload via iptables-restore<\/td><td><code>nft -f<\/code> applies an entire ruleset atomically<\/td><\/tr><tr><td>Complex matches<\/td><td>Repeated -m modules, verbose flags<\/td><td>Sets, maps, and concatenations in one rule<\/td><\/tr><tr><td>Rule count performance<\/td><td>Linear walk per packet<\/td><td>Set\/hash lookups scale better with many rules<\/td><\/tr><tr><td>Tooling<\/td><td>iptables, ip6tables, arptables, ebtables<\/td><td>One <code>nft<\/code> binary, plus the compat shims<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The differences that matter on a small VPS are atomic reloads and sets. Atomic reloads mean you can stage a full ruleset and swap it in without a window where a rule is missing mid-apply \u2014 exactly what you want when you are firewalling the port you are SSH&#8217;d into. Sets let you express &#8220;allow these 20 ports&#8221; as one rule instead of twenty.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Same Policy, Both Syntaxes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A typical single-VPS policy is: allow loopback, established traffic, SSH, and HTTP\/S; drop everything else. In classic iptables that looks like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iptables -A INPUT -i lo -j ACCEPT\niptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT\niptables -A INPUT -p tcp --dport 22 -j ACCEPT\niptables -A INPUT -p tcp --dport 80 -j ACCEPT\niptables -A INPUT -p tcp --dport 443 -j ACCEPT\niptables -P INPUT DROP<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same policy in native nftables fits in one file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>table inet filter {\n  chain input {\n    type filter hook input priority filter; policy drop;\n    ct state established,related accept\n    iif \"lo\" accept\n    tcp dport { 22, 80, 443 } accept\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Load it with <code>nft -f \/etc\/nftables.conf<\/code> and enable the service so it survives reboots: <code>systemctl enable --now nftables<\/code>. Note the <code>inet<\/code> family \u2014 one table covers both IPv4 and IPv6, which the legacy syntax never did without a second set of ip6tables rules.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Migrating Without Locking Yourself Out<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you have an existing iptables ruleset, let the tooling do the translation instead of hand-converting every line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Dump current rules\niptables-save &gt; \/tmp\/rules.v4\n\n# Translate to nft syntax\niptables-restore-translate -f \/tmp\/rules.v4 &gt; \/tmp\/rules.nft\n\n# Review, then test-apply without touching the live ruleset\nnft -c -f \/tmp\/rules.nft<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-c<\/code> flag performs a dry run: it parses and validates the file without loading it. Review the generated <code>rules.nft<\/code> \u2014 the translator is mechanical, so comments and some compound matches will need manual cleanup. Then apply in a way that lets you bail out: keep your current SSH session open, load the new ruleset, and only close the session after confirming from a second terminal that <code>ssh<\/code> still connects and <code>nft list ruleset<\/code> shows what you expect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verifying the Firewall Is Actually Doing Something<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><code>nft list ruleset<\/code> \u2014 shows every rule, table, and chain currently loaded; the single source of truth.<\/li><li><code>systemctl status nftables<\/code> \u2014 confirms the service is active and the config file parsed cleanly at boot.<\/li><li><code>nft -c -f \/etc\/nftables.conf<\/code> \u2014 re-validates the file after every edit, before you reload it.<\/li><li>Port scans from outside (or a second server) \u2014 confirm that closed ports actually drop instead of answering with RST.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">One habit worth stealing from production teams: commit your <code>nftables.conf<\/code> to version control, and always test the new file with <code>nft -c<\/code> before a reload. On a box you administer over SSH, a broken firewall rule is one reboot away from a support ticket.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For most VPS workloads, the pragmatic answer is: keep whatever the distro default is, but manage it through <code>nft<\/code> so you get atomic reloads and a single syntax to learn. If you are choosing a new host and want one where the control panel does not fight your host firewall, our <a href=\"https:\/\/virtualserversvps.com\/#features\">feature comparison<\/a> lists which providers expose raw firewall access. And if your current box is too small to hold both your app and your ruleset comfortably, browse the <a href=\"https:\/\/virtualserversvps.com\/#providers\" rel=\"noreferrer noopener sponsored\">ranked VPS provider list<\/a> for plans with more headroom.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>iptables and nftables are not two competing firewalls so much as two generations of the same one. If you still write rules with the classic iptables commands, there is a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":13,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-534","post","type-post","status-publish","format-standard","hentry","category-security-compliance"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>iptables vs nftables on a VPS: Which to Run and How to Migrate - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"iptables vs nftables on a VPS: Which to Run and How to Migrate\" \/>\n<meta property=\"og:description\" content=\"iptables vs nftables on a VPS: Which to Run and How to Migrate\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-28T03:12:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-17T22:13:20+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/\",\"name\":\"iptables vs nftables on a VPS: Which to Run and How to Migrate - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-06-28T03:12:18+00:00\",\"dateModified\":\"2026-08-17T22:13:20+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"iptables vs nftables on a VPS: Which to Run and How to Migrate\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"iptables vs nftables on a VPS: Which to Run and How to Migrate - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/","og_locale":"en_US","og_type":"article","og_title":"iptables vs nftables on a VPS: Which to Run and How to Migrate","og_description":"iptables vs nftables on a VPS: Which to Run and How to Migrate","og_url":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-06-28T03:12:18+00:00","article_modified_time":"2026-08-17T22:13:20+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/","url":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/","name":"iptables vs nftables on a VPS: Which to Run and How to Migrate - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-06-28T03:12:18+00:00","dateModified":"2026-08-17T22:13:20+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/vps-firewall-configuration-guide-ufw-iptables-nftables-2026\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"iptables vs nftables on a VPS: Which to Run and How to Migrate"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=534"}],"version-history":[{"count":4,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/534\/revisions"}],"predecessor-version":[{"id":906,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/534\/revisions\/906"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}