{"id":1347,"date":"2026-10-09T23:06:57","date_gmt":"2026-10-09T23:06:57","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1347"},"modified":"2026-10-09T23:06:57","modified_gmt":"2026-10-09T23:06:57","slug":"auditing-outbound-egress-firewall-rules-vps-security","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/","title":{"rendered":"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Most firewall reviews focus on inbound ports. That is backwards for a VPS threat model. An attacker who has already executed code does not need inbound access; they need <em>outbound<\/em> reachability to move your data somewhere else. Auditing egress rules is the highest-value security exercise most small deployments never do. This article covers how to inspect what your nftables or ufw rules really allow outbound, and how to build a baseline that surfaces unexpected traffic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Default Policies Decide Everything<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The single most important setting is the OUTPUT chain policy. A default of <code>accept<\/code> means every process on the box, including a compromised one, can open any outbound connection it likes. Start by reading the live ruleset rather than assuming what an installer created.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># nftables: show the full ruleset with handles\nsudo nft list ruleset\nsudo nft -a list chain inet filter output\n\n# ufw: show the raw backing rules, not the friendly summary\nsudo ufw status verbose\nsudo iptables -S OUTPUT\nsudo iptables -L OUTPUT -n -v<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">ufw&#8217;s <code>status verbose<\/code> hides a lot. Always drop to <code>iptables -S<\/code> to see the actual ACCEPT and DROP rules, including the ones ufw inserts above your own. If you see <code>-P OUTPUT ACCEPT<\/code> with no restrictive chain, you have no egress control at all.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Legitimate Egress Looks Like<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you can block, you must enumerate. A typical web or API VPS legitimately talks to: DNS resolvers (53\/853), package repositories (80\/443), NTP (123), your database replica, your object storage endpoint, and your monitoring\/APM collector. Everything else deserves a reason.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Direction<\/th><th>Purpose<\/th><th>Typical dest<\/th><th>Default action<\/th><\/tr><\/thead><tbody><tr><td>UDP 53\/853<\/td><td>DNS resolution<\/td><td>Configured resolvers<\/td><td>Allow, pin to resolver IPs<\/td><\/tr><tr><td>TCP 80\/443<\/td><td>Updates, APIs, object storage<\/td><td>Known CIDRs<\/td><td>Allow to allowlist<\/td><\/tr><tr><td>UDP 123<\/td><td>NTP time sync<\/td><td>NTP pool<\/td><td>Allow<\/td><\/tr><tr><td>TCP 25\/465\/587<\/td><td>SMTP<\/td><td>Relay only<\/td><td>Block direct, allow relay<\/td><\/tr><tr><td>TCP 1-1024<\/td><td>(no common need)<\/td><td>any<\/td><td>Log and block<\/td><\/tr><tr><td>TCP 4444\/1337\/31337<\/td><td>common C2 ports<\/td><td>any<\/td><td>Block<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Building a Logging-First Egress Policy<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Do not jump straight to DROP. First log outbound attempts for a week to build a baseline, then restrict. With nftables, create a dedicated chain and log before the decision.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>table inet audit {\n  chain egress {\n    type filter hook output priority 0; policy accept;\n\n    ct state established,related accept\n    oifname \"lo\" accept\n\n    # log and count new outbound connections\n    ct state new log prefix \"EGRESS-NEW: \" level info\n    ct state new counter\n  }\n}\n# load it\nnft -f \/etc\/nftables.d\/audit-egress.nft\n# watch the log\njournalctl -k -f | grep EGRESS-NEW<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With ufw you can approximate this using a LOG rule placed before your allow rules, but nftables gives far better control over chain order and counters. Whichever you use, the point is the same: establish what normal looks like before you break something in production.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Red Flags in the Baseline<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Reviewing the baseline log, look for these patterns, which are classic exfiltration and command-and-control indicators:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Outbound connections from a web server process to a bare IP, not a hostname.<\/li><li>Traffic on ports with no business use: 4444, 8080 to an unknown host, 53\/TCP tunneling.<\/li><li>Periodic beaconing at regular intervals with small payloads.<\/li><li>Large sustained uploads to a destination outside your provider&#8217;s ASN.<\/li><li>DNS queries to domains not in your resolver&#8217;s expected set, especially unusually long subdomains (DNS tunneling).<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Confirming a Suspected Exfiltration Channel<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once a rule fires, attribute the traffic to a process. <code>ss<\/code> with process info and <code>lsof<\/code> on the socket will tell you who owns it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># live outbound connections with owning process\nss -tunp state established\nss -tnp state established '( dport = :443 or dport = :4444 )'\n\n# which binary opened a socket\nlsof -i -n -P | grep ESTABLISHED<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A sudden outbound connection from <code>\/tmp<\/code>, a deleted binary (<code>\/proc\/PID\/exe (deleted)<\/code>), or a process whose parent is <code>cron<\/code> and should not be making network calls are all signals worth investigating immediately. Correlate with file integrity monitoring and authentication logs. The <a href=\"https:\/\/virtualserversvps.com\/managed-vs-unmanaged\">managed versus unmanaged server comparison<\/a> explains how much of this monitoring is typically handled for you, and where self-managed deployments must build it themselves. For getting the instance hardened before you layer egress rules on top, see the <a href=\"https:\/\/virtualserversvps.com\/blog\/auditing-cron-job-failures-email-alerting-small-vps\">cron auditing walkthrough<\/a>, since scheduled tasks are a common exfiltration trigger point.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Keep the audit as an ongoing control, not a one-time review. Rotate the baseline monthly, alert on new egress destinations, and re-run <code>ss -tunp<\/code> whenever the box has been exposed to a newly disclosed network-facing CVE.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Most firewall reviews focus on inbound ports. That is backwards for a VPS threat model. An attacker who has already executed code does not need inbound access; they need outbound&#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":3,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1347","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>Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"Most firewall reviews focus on inbound ports. That is backwards for a VPS threat model. An attacker who has already executed code does not need inbound\" \/>\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\/auditing-outbound-egress-firewall-rules-vps-security\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration\" \/>\n<meta property=\"og:description\" content=\"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-09T23:06:57+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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/\",\"name\":\"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-10-09T23:06:57+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"Most firewall reviews focus on inbound ports. That is backwards for a VPS threat model. An attacker who has already executed code does not need inbound\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration\"}]},{\"@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":"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration - Virtual Servers VPS Blog","description":"Most firewall reviews focus on inbound ports. That is backwards for a VPS threat model. An attacker who has already executed code does not need inbound","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\/auditing-outbound-egress-firewall-rules-vps-security\/","og_locale":"en_US","og_type":"article","og_title":"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration","og_description":"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration","og_url":"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-10-09T23:06:57+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/","url":"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/","name":"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-10-09T23:06:57+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"Most firewall reviews focus on inbound ports. That is backwards for a VPS threat model. An attacker who has already executed code does not need inbound","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/auditing-outbound-egress-firewall-rules-vps-security\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Auditing Outbound Egress Rules with nftables and ufw to Catch Data Exfiltration"}]},{"@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\/1347","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=1347"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1347\/revisions"}],"predecessor-version":[{"id":1350,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1347\/revisions\/1350"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}