{"id":5952,"date":"2021-07-06T22:38:01","date_gmt":"2021-07-06T22:38:01","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=5952"},"modified":"2021-07-06T22:38:01","modified_gmt":"2021-07-06T22:38:01","slug":"securing-ipfs-with-ufw-firewall-on-debian-10","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2021\/07\/06\/securing-ipfs-with-ufw-firewall-on-debian-10\/","title":{"rendered":"Securing IPFS with UFW Firewall on Debian 10"},"content":{"rendered":"<p>First lets install UFW<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo apt-get install ufw\n<\/pre>\n<p>Check the Status<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw status verbose\n<\/pre>\n<p>By default, UFW is disabled so you should see something like this:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ Status: inactive\n<\/pre>\n<p>Let\u2019s set your UFW rules back to the defaults so we can be sure that you\u2019ll be able to follow along with this tutorial. To set the defaults used by UFW, use these commands:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw default deny incoming\n<\/pre>\n<p>Output:<br \/>\nDefault incoming policy changed to &#8216;deny&#8217;<br \/>\n(be sure to update your rules accordingly)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw default allow outgoing\n<\/pre>\n<p>Output:<br \/>\nDefault outgoing policy changed to &#8216;allow&#8217;<br \/>\n(be sure to update your rules accordingly)<\/p>\n<p>Allow SSH Connections<\/p>\n<p>To configure your server to allow incoming SSH connections, you can use this UFW command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow ssh\n<\/pre>\n<p>Output:<br \/>\nRules updated<br \/>\nRules updated (v6)<br \/>\nthis command works the same as the one above:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow 22\n<\/pre>\n<p>Or if ssh is on a different port<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow 2222\n<\/pre>\n<p>Now that your firewall is configured to allow incoming SSH connections, we can enable it<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw enable\nCommand may disrupt existing ssh connections. Proceed with operation (y|n)? y\nFirewall is active and enabled on system startup\n<\/pre>\n<p>Now lets add the port access for IPFS<br \/>\n4001 &#8211; default libp2p swarm port &#8211; should be open to public for all nodes if possible<br \/>\n5001 &#8211; API port &#8211; provides write\/admin access to the node &#8211; should be locked down or only to your IP.<br \/>\n8080 &#8211; Gateway<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow 4001\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow 5001\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow 8080\/tcp\n<\/pre>\n<p>Reload<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw reload\n<\/pre>\n<p>Remove a Port<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw status numbered\nStatus: active\n\n     To                         Action      From\n     --                         ------      ----\n&#x5B; 1] 22\/tcp                     ALLOW IN    Anywhere\n&#x5B; 2] 4001                       ALLOW IN    Anywhere\n&#x5B; 3] 5001                       ALLOW IN    Anywhere\n&#x5B; 4] 8080\/tcp                   ALLOW IN    Anywhere\n&#x5B; 5] 22\/tcp (v6)                ALLOW IN    Anywhere (v6)\n&#x5B; 6] 4001 (v6)                  ALLOW IN    Anywhere (v6)\n&#x5B; 7] 5001 (v6)                  ALLOW IN    Anywhere (v6)\n&#x5B; 8] 8080\/tcp (v6)              ALLOW IN    Anywhere (v6)\n\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw delete 2\n<\/pre>\n<p>Delete all firewall rules<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw reset\n<\/pre>\n<p>To Allow connections for the Webui on a specific IP:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ sudo ufw allow from 1.2.3.4 to any port 5001\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo ufw reload\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>First lets install UFW $ sudo apt-get install ufw Check the Status $ sudo ufw status verbose By default, UFW is disabled so you should see something like this: $ Status: inactive Let\u2019s set your UFW rules back to the defaults so we can be sure that you\u2019ll be able to follow along with this &#8230; <a title=\"Securing IPFS with UFW Firewall on Debian 10\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2021\/07\/06\/securing-ipfs-with-ufw-firewall-on-debian-10\/\" aria-label=\"Read more about Securing IPFS with UFW Firewall on Debian 10\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,51],"tags":[],"class_list":["post-5952","post","type-post","status-publish","format-standard","hentry","category-firewall","category-ipfs"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/5952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=5952"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/5952\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=5952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=5952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=5952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}