{
  "created": "2023-01-09T21:51:13Z",
  "hierarchy": [
    {
      "name": "ROOT",
      "type": "folder",
      "uri": "/ROOT"
    },
    {
      "name": "ufw Notes",
      "type": "article",
      "uri": "ufw_Notes"
    }
  ],
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\"/>\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>\n    <meta property=\"og:image\" content=\"/img/logo512.png\"/>\n    <meta property=\"og:site_name\" content=\"Nikhil's Personal Wiki\"/>\n    <link rel=\"og:image\" href=\"/img/logo512.png\"/>\n    <link rel=\"icon\" href=\"/img/favicon.png\"/>\n    <link rel=\"apple-touch-icon\" href=\"/img/logo192.png\"/>\n    <link rel=\"stylesheet\" href=\"/css/styles.css\"/>\n    <link rel=\"stylesheet\" href=\"/css/highlight.css\"/>\n    <title>ufw Notes &ndash; Nikhil's Personal Wiki</title>\n    <script type=\"text/javascript\" id=\"MathJax-script\" defer src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js\"></script>\n    <script defer data-domain=\"wiki.nikhil.io\" src=\"https://plausible.io/js/plausible.js\"></script>\n  </head>\n  <body>\n    <noscript>\n      👉 A few things won&#8217;t work if you have JavaScript disabled.\n    </noscript>\n    <div class=\"container article\">\n      <header>\n        <nav>\n          <ul>\n            <li>\n              <a href=\"/archive\"  title=\"Archive\">\n                <span>Archive</span>\n              </a>\n            </li>\n            <li>\n              <a href=\"/Home\"  title=\"Home\">\n                <span>Home</span>\n              </a>\n            </li>\n            <li>\n              <a href=\"/random\"  title=\"See a random article\">\n                <span>Random</span>\n              </a>\n            </li>\n            \n            \n              \n                <li>\n                  <a href=\"/ufw_Notes/raw.txt\"  title=\"View Source\">\n                    <span>Raw</span>\n                  </a>\n                </li>\n              \n              \n            \n            \n            \n            \n              \n                <li>\n                  <a href=\"/ufw_Notes/revisions\" >\n                    <span>Revisions</span>\n                  </a>\n                </li>\n              \n            \n            \n              \n                \n                  <li>\n                    <a href=\"/ufw_Notes/index.json\" title=\"View JSON Object\">\n                      <span>JSON</span>\n                    </a>\n                  </li>\n                \n              \n            \n          </ul>\n        </nav>\n      </header>\n      <main>\n        \n  <nav>\n  <ul>\n    \n      <li>\n        <a data-entity-type=\"folder\" href=\"/ROOT\" title=\"ROOT\">Root</a>\n      </li>\n    \n      <li>\n        <a data-entity-type=\"article\" href=\"/ufw_Notes\" title=\"ufw Notes\">ufw Notes</a>\n      </li>\n    \n    \n    \n    \n    \n  </ul>\n</nav>\n\n  <h1>ufw Notes\n    \n  </h1>\n  <p><code>ufw</code> is a simple wrapper around <code>iptables</code> (<a href=\"https://github.com/afreeorange/iptables\">which can be rather complicated</a>). You can view all the rules the CLI adds in <code>/etc/ufw/user.rules</code></p>\n<h3>Adding Rules and Enabling</h3>\n<p>Some basic stuff for all interfaces.</p>\n<pre tabindex=\"0\" class=\"chroma\"><code><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Block everything incoming</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw default deny incoming\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow all outgoing connections</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw default allow outgoing\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow a port</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow <span class=\"m\">3306</span>\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Show list of apps that have registered themselves with ufw</span>\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># These are in /etc/ufw/applications.d</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw app list\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Enable an app</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow Samba\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Show all added things (don&#39;t need a running firewall for this)</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw show added\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Enable the firewall</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw <span class=\"nb\">enable</span>\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Check (running) firewall&#39;s status</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw status verbose\n</span></span></code></pre><h3>Deleting Rules</h3>\n<pre tabindex=\"0\" class=\"chroma\"><code><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Get the rule number</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw status numbered\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Remove the offending rule</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw delete <span class=\"m\">3</span>\n</span></span></code></pre><h3>Denying Things</h3>\n<pre tabindex=\"0\" class=\"chroma\"><code><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Deny access to a port</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw deny <span class=\"m\">22</span>\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Deny a host and subnet</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw deny from 192.168.1.4\n</span></span><span class=\"line\"><span class=\"cl\">ufw deny from 192.168.1.0/24\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Deny an outgoing connection</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw deny out <span class=\"m\">22</span>\n</span></span></code></pre><h3>Other stuff</h3>\n<pre tabindex=\"0\" class=\"chroma\"><code><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow a port range</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow 8000:8008/tcp\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow 8000:8008/udp\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow an IP Address</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow from 192.168.1.19\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow access to an interface</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow in on eth1 to any port <span class=\"m\">80</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow in on eth1 to any port <span class=\"m\">443</span>\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow an IP Address to a specific port</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow from 192.168.1.19 to any port <span class=\"m\">3306</span>\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow an entire subnet</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow from 192.168.1.0/24\n</span></span><span class=\"line\"><span class=\"cl\">\n</span></span><span class=\"line\"><span class=\"cl\"><span class=\"c1\"># Allow an entire subnet to a specific port</span>\n</span></span><span class=\"line\"><span class=\"cl\">ufw allow from 192.168.1.0/24 to any port <span class=\"m\">3306</span>\n</span></span></code></pre><p>Note that <code>ufw</code> won&rsquo;t block <code>macvlan</code> ports for obvious reasons!</p>\n\n\n      </main>\n      <footer>\n        <p>\n          \n        </p>\n        <ul>\n          \n  <li>1,603 bytes</li>\n  \n    <li>Created on Monday, 9 January 2023 at 21:51 UTC</li>\n    <li>Modified on Tuesday, 13 January 2026 at 18:47 UTC</li>\n    <br/>\n    <li>\n      <a\n        href=\"https://github.com/afreeorange/wiki.nikhil.io.articles/edit/master/ufw Notes.md\"\n        title=\"Edit this article\">Edit this article</a>\n    </li>\n  \n\n          <li>\n            <a href=\"https://github.com/afreeorange/bock\" title=\"View the project that generates this wiki on Github\">bock\n            5.3.0-beta</a>\n          </li>\n        </ul>\n      </footer>\n    </div>\n    \n    \n      <script type=\"text/javascript\">\n        /**\n         * Quick shortcut to take me to the search box which is 90% of how I navigate\n         * this wiki anyway.\n         */\n        document.body.addEventListener(\n          \"keypress\", (e) => e.key === \"f\"\n          ? window.location.assign(\"/archive\")\n          : null);\n        window.MathJax = {\n          tex: {\n            inlineMath: [\n              [\n                '$', '$'\n              ],\n              [\n                '\\\\(', '\\\\)'\n              ]\n            ]\n          },\n          svg: {\n            fontCache: 'global'\n          }\n        };\n      </script>\n    \n  </body>\n</html></head></html>\n",
  "id": "65fb869e-ed3c-5bc6-9e42-5b720ceca3cc",
  "modified": "2026-01-13T18:47:28Z",
  "revisions": [
    {
      "authorEmail": "mail@nikhil.io",
      "authorName": "Nikhil Anand",
      "date": "2026-01-13T18:47:28Z",
      "id": "2436477560f26e23d00a24add1cbfeafdca4af78",
      "shortId": "24364775",
      "subject": "No compression\n",
      "content": "`ufw` is a simple wrapper around `iptables` ([which can be rather complicated](https://github.com/afreeorange/iptables)). You can view all the rules the CLI adds in `/etc/ufw/user.rules`\n\n### Adding Rules and Enabling\n\nSome basic stuff for all interfaces.\n\n```bash\n# Block everything incoming\nufw default deny incoming\n\n# Allow all outgoing connections\nufw default allow outgoing\n\n# Allow a port\nufw allow 3306\n\n# Show list of apps that have registered themselves with ufw\n# These are in /etc/ufw/applications.d\nufw app list\n\n# Enable an app\nufw allow Samba\n\n# Show all added things (don't need a running firewall for this)\nufw show added\n\n# Enable the firewall\nufw enable\n\n# Check (running) firewall's status\nufw status verbose\n```\n\n### Deleting Rules\n\n```bash\n# Get the rule number\nufw status numbered\n\n# Remove the offending rule\nufw delete 3\n```\n\n### Denying Things\n\n```bash\n# Deny access to a port\nufw deny 22\n\n# Deny a host and subnet\nufw deny from 192.168.1.4\nufw deny from 192.168.1.0/24\n\n# Deny an outgoing connection\nufw deny out 22\n```\n\n### Other stuff\n\n```bash\n# Allow a port range\nufw allow 8000:8008/tcp\nufw allow 8000:8008/udp\n\n# Allow an IP Address\nufw allow from 192.168.1.19\n\n# Allow access to an interface\nufw allow in on eth1 to any port 80\nufw allow in on eth1 to any port 443\n\n# Allow an IP Address to a specific port\nufw allow from 192.168.1.19 to any port 3306\n\n# Allow an entire subnet\nufw allow from 192.168.1.0/24\n\n# Allow an entire subnet to a specific port\nufw allow from 192.168.1.0/24 to any port 3306\n```\n\nNote that `ufw` won't block `macvlan` ports for obvious reasons!\n"
    },
    {
      "authorEmail": "mail@nikhil.io",
      "authorName": "Nikhil Anand",
      "date": "2023-01-09T21:57:58Z",
      "id": "4bc6f322b7686e8f565ee41f9aad01bdf5705536",
      "shortId": "4bc6f322",
      "subject": "Add note on location\n",
      "content": "`ufw` is a simple wrapper around `iptables` ([which can be rather complicated](https://github.com/afreeorange/iptables)). You can view all the rules the CLI adds in `/etc/ufw/user.rules`\n\n### Adding Rules and Enabling\n\nSome basic stuff for all interfaces.\n\n```bash\n# Block everything incoming\nufw default deny incoming\n\n# Allow all outgoing connections\nufw default allow outgoing\n\n# Allow a port\nufw allow 3306\n\n# Show list of apps that have registered themselves with ufw\n# These are in /etc/ufw/applications.d\nufw app list\n\n# Enable an app\nufw allow Samba\n\n# Show all added things (don't need a running firewall for this)\nufw show added\n\n# Enable the firewall\nufw enable\n\n# Check (running) firewall's status\nufw status verbose\n```\n\n### Deleting Rules\n\n```bash\n# Get the rule number\nufw status numbered\n\n# Remove the offending rule\nufw delete 3\n```\n\n### Denying Things\n\n```bash\n# Deny access to a port\nufw deny 22\n\n# Deny a host and subnet\nufw deny from 192.168.1.4\nufw deny from 192.168.1.0/24\n\n# Deny an outgoing connection\nufw deny out 22\n```\n\n### Other stuff\n\n```bash\n# Allow a port range\nufw allow 8000:8008/tcp\nufw allow 8000:8008/udp\n\n# Allow an IP Address\nufw allow from 192.168.1.19\n\n# Allow access to an interface\nufw allow in on eth1 to any port 80\nufw allow in on eth1 to any port 443\n\n# Allow an IP Address to a specific port\nufw allow from 192.168.1.19 to any port 3306\n\n# Allow an entire subnet\nufw allow from 192.168.1.0/24\n\n# Allow an entire subnet to a specific port\nufw allow from 192.168.1.0/24 to any port 3306\n```\n\nNote that `ufw` won't block `macvlan` ports for obvious reasons!\n"
    },
    {
      "authorEmail": "mail@nikhil.io",
      "authorName": "Nikhil Anand",
      "date": "2023-01-09T21:51:13Z",
      "id": "48bc8a84caecd06786e92933fbb57106c6374ed0",
      "shortId": "48bc8a84",
      "subject": "Create ufw Notes.md\n",
      "content": "`ufw` is a simple wrapper around `iptables` ([which can be rather complicated](https://github.com/afreeorange/iptables)).\n\n### Adding Rules and Enabling\n\nSome basic stuff for all interfaces.\n\n```bash\n# Block everything incoming\nufw default deny incoming\n\n# Allow all outgoing connections\nufw default allow outgoing\n\n# Allow a port\nufw allow 3306\n\n# Show list of apps that have registered themselves with ufw\n# These are in /etc/ufw/applications.d\nufw app list\n\n# Enable an app\nufw allow Samba\n\n# Show all added things (don't need a running firewall for this)\nufw show added\n\n# Enable the firewall\nufw enable\n\n# Check (running) firewall's status\nufw status verbose\n```\n\n### Deleting Rules\n\n```bash\n# Get the rule number\nufw status numbered\n\n# Remove the offending rule\nufw delete 3\n```\n\n### Denying Things\n\n```bash\n# Deny access to a port\nufw deny 22\n\n# Deny a host and subnet\nufw deny from 192.168.1.4\nufw deny from 192.168.1.0/24\n\n# Deny an outgoing connection\nufw deny out 22\n```\n\n### Other stuff\n\n```bash\n# Allow a port range\nufw allow 8000:8008/tcp\nufw allow 8000:8008/udp\n\n# Allow an IP Address\nufw allow from 192.168.1.19\n\n# Allow access to an interface\nufw allow in on eth1 to any port 80\nufw allow in on eth1 to any port 443\n\n# Allow an IP Address to a specific port\nufw allow from 192.168.1.19 to any port 3306\n\n# Allow an entire subnet\nufw allow from 192.168.1.0/24\n\n# Allow an entire subnet to a specific port\nufw allow from 192.168.1.0/24 to any port 3306\n```\n\nNote that `ufw` won't block `macvlan` ports for obvious reasons!\n"
    }
  ],
  "sizeInBytes": 1603,
  "source": "`ufw` is a simple wrapper around `iptables` ([which can be rather complicated](https://github.com/afreeorange/iptables)). You can view all the rules the CLI adds in `/etc/ufw/user.rules`\n\n### Adding Rules and Enabling\n\nSome basic stuff for all interfaces.\n\n```bash\n# Block everything incoming\nufw default deny incoming\n\n# Allow all outgoing connections\nufw default allow outgoing\n\n# Allow a port\nufw allow 3306\n\n# Show list of apps that have registered themselves with ufw\n# These are in /etc/ufw/applications.d\nufw app list\n\n# Enable an app\nufw allow Samba\n\n# Show all added things (don't need a running firewall for this)\nufw show added\n\n# Enable the firewall\nufw enable\n\n# Check (running) firewall's status\nufw status verbose\n```\n\n### Deleting Rules\n\n```bash\n# Get the rule number\nufw status numbered\n\n# Remove the offending rule\nufw delete 3\n```\n\n### Denying Things\n\n```bash\n# Deny access to a port\nufw deny 22\n\n# Deny a host and subnet\nufw deny from 192.168.1.4\nufw deny from 192.168.1.0/24\n\n# Deny an outgoing connection\nufw deny out 22\n```\n\n### Other stuff\n\n```bash\n# Allow a port range\nufw allow 8000:8008/tcp\nufw allow 8000:8008/udp\n\n# Allow an IP Address\nufw allow from 192.168.1.19\n\n# Allow access to an interface\nufw allow in on eth1 to any port 80\nufw allow in on eth1 to any port 443\n\n# Allow an IP Address to a specific port\nufw allow from 192.168.1.19 to any port 3306\n\n# Allow an entire subnet\nufw allow from 192.168.1.0/24\n\n# Allow an entire subnet to a specific port\nufw allow from 192.168.1.0/24 to any port 3306\n```\n\nNote that `ufw` won't block `macvlan` ports for obvious reasons!\n",
  "title": "ufw Notes",
  "untracked": false,
  "uri": "/ufw_Notes",
  "relativePath": "ufw Notes.md"
}
