<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Firewall on Wimpy's World</title><link>https://blog.wimpys.world/tags/firewall/</link><description>Recent content in Firewall on Wimpy's World</description><generator>Hugo -- gohugo.io</generator><language>en-gb</language><managingEditor>martin@wimpress.com (Martin Wimpress)</managingEditor><webMaster>martin@wimpress.com (Martin Wimpress)</webMaster><lastBuildDate>Sat, 09 Mar 2013 08:37:43 +0000</lastBuildDate><atom:link href="https://blog.wimpys.world/tags/firewall/rss.xml" rel="self" type="application/rss+xml"/><item><title>Uncomplicated Firewall (UFW) on Arch Linux</title><link>https://blog.wimpys.world/posts/uncomplicated-firewall-ufw-on-arch-linux/</link><pubDate>Sat, 09 Mar 2013 08:37:43 +0000</pubDate><author>martin@wimpress.com (Martin Wimpress)</author><guid>https://wimpysworld.com/posts/uncomplicated-firewall-ufw-on-arch-linux/</guid><description>&lt;p&gt;While migrating one of my VPS servers to &lt;a href="http://www.archlinux.org"&gt;Arch Linux&lt;/a&gt;
I deployed &lt;a href="https://wiki.ubuntu.com/UncomplicatedFirewall"&gt;Uncomplicated Firewall (UFW)&lt;/a&gt;
to handle basic firewall duties. I like &lt;code&gt;ufw&lt;/code&gt; as it provides simple host-based
firewall management and, in my opinion, one of the better projects to come out
of the Ubuntu camp.&lt;/p&gt;
&lt;p&gt;Install &lt;code&gt;ufw&lt;/code&gt; as follows.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo pacman -Syy -noconfirm --needed ufw
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Configuring &lt;code&gt;ufw&lt;/code&gt; is simple but make sure you have console access to the host
you are configuring just in case you lock yourself out.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE!&lt;/strong&gt; When enabling &lt;code&gt;ufw&lt;/code&gt; the chains are flushed and connections may be
dropped. You can add rules to the firewall before enabling it however, so if you
are testing &lt;code&gt;ufw&lt;/code&gt; on a remote machine it is recommended you perform&amp;hellip;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ufw allow ssh/tcp
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&amp;hellip;before running &lt;code&gt;sudo ufw enable&lt;/code&gt;. Once the firewall is enabled, adding and
removing rules will not flush the firewall, although modifying an existing rule
will.&lt;/p&gt;
&lt;p&gt;Set the default behaviour to deny all incoming connections.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ufw default deny
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open up TCP port 22 but with rate limiting enabled which will deny connections
from an IP address that has attempted to initiate 6 or more connections in the
last 30 seconds. Ideal for protecting &lt;code&gt;sshd&lt;/code&gt; but you should conisder other
&lt;a href="https://blog.wimpys.world/posts/ssh-brute-force-defense/"&gt;SSH brute force defense&lt;/a&gt;
techniques as well.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ufw limit tcp/22
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;m hosting a few websites on my VPS so I open http and https.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ufw allow 80/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ufw allow 443/tcp
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Enable the &lt;code&gt;ufw&lt;/code&gt; systemd unit.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; ufw
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo systemctl start ufw
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, &lt;code&gt;ufw&lt;/code&gt; is not enabled at this point. To enable the firewall you also
have to do the following.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ufw &lt;span class="nb"&gt;enable&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see the status of the firewall using &lt;code&gt;sudo ufw status&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On low-end servers it might be beneficial to disable logging.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ufw logging off
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point you should have a basic firewall configured and &lt;code&gt;ufw help&lt;/code&gt; or the
references below will assist you.&lt;/p&gt;
&lt;h4 id="references"&gt;References&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://wiki.archlinux.org/index.php/Uncomplicated_Firewall"&gt;https://wiki.archlinux.org/index.php/Uncomplicated_Firewall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.ubuntu.com/UncomplicatedFirewall"&gt;https://wiki.ubuntu.com/UncomplicatedFirewall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://launchpad.net/ufw"&gt;https://launchpad.net/ufw&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><summary>Configuring Uncomplicated Firewall (UFW) on Arch Linux.</summary></item></channel></rss>