<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abraxas &#187; ufw</title>
	<atom:link href="http://www.effinger.org/blog/tag/ufw/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.effinger.org/blog</link>
	<description>a personal knowledge base</description>
	<lastBuildDate>Sun, 06 Jun 2010 17:41:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ufw &#8211; Firewall in Ubuntu</title>
		<link>http://www.effinger.org/blog/2009/01/26/ufw-firewall-in-ubuntu/</link>
		<comments>http://www.effinger.org/blog/2009/01/26/ufw-firewall-in-ubuntu/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 20:29:14 +0000</pubDate>
		<dc:creator>Markus Effinger</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[Fritzbox]]></category>
		<category><![CDATA[ufw]]></category>

		<guid isPermaLink="false">http://www.effinger.org/blog/?p=308</guid>
		<description><![CDATA[<p>ufw (uncomplicated firewall) ist zwar die Standard-Firewall von Ubuntu, aber im Auslieferungszustand bei der Desktop-Version nicht aktiviert. Nach einem</p>

sudo ufw enable
sudo ufw default deny

<p>ist sie aktiv und befolgt folgende Regeln (siehe Ubuntu-Wiki) in Intrepid Ibex:</p>

Alle loopback-Verbindungen akzeptieren, d.h. vom lokalen Rechner aus kann man auf jeden beliebigen Port zugreifen.
Alle ausgehenden Verbindungen zulassen.
Alle eingehenden Verbindungen ablehnen.
Alle [...]]]></description>
			<content:encoded><![CDATA[<p>ufw (uncomplicated firewall) ist zwar die Standard-Firewall von Ubuntu, aber im Auslieferungszustand bei der Desktop-Version nicht aktiviert. Nach einem</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw <span style="color: #7a0874; font-weight: bold;">enable</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw default deny</pre></div></div>

<p>ist sie aktiv und befolgt folgende Regeln (<a href="https://wiki.ubuntu.com/UbuntuFirewall">siehe Ubuntu-Wiki</a>) in Intrepid Ibex:</p>
<ol>
<li>Alle loopback-Verbindungen akzeptieren, d.h. vom lokalen Rechner aus kann man auf jeden beliebigen Port zugreifen.</li>
<li>Alle ausgehenden Verbindungen zulassen.</li>
<li>Alle eingehenden Verbindungen ablehnen.</li>
<li>Alle abgelehnten Pakete in die Syslog schreiben (&#8211;limit 3/min), also maximal drei Einträge pro Minute.</li>
</ol>
<p>Ich habe gleich mal den SSH-Zugang freigeschaltet durch ein</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow OpenSSH</pre></div></div>

<p>Um einzelne Anwendungen/Ports frei zu schalten, habe ich mir noch ein paar zusätzliche Profile im Verzeichnis /etc/ufw/applications.d/ erstellt:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">$ cat deluge
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Deluge<span style="">&#93;</span></span>
<span style="color: #000099;">title</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Deluge Bittorrent Client</span>
<span style="color: #000099;">description</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Deluge is an open source bittorrent client.</span>
<span style="color: #000099;">ports</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"><span style="">5050</span>,<span style="">5051</span>/tcp</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">$ cat vino-server
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>vino-server<span style="">&#93;</span></span>
<span style="color: #000099;">title</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Vino VNC Server</span>
<span style="color: #000099;">description</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Vino is an open source VNC server</span>
<span style="color: #000099;">ports</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"><span style="">5900</span>/tcp</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">$ cat exim
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Exim SMTP<span style="">&#93;</span></span>
<span style="color: #000099;">title</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Exim Message Transfer Agent</span>
<span style="color: #000099;">description</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Exim is an open source mail transfer agent <span style="">&#40;</span>MTA<span style="">&#41;</span> providing services such as SMTP to send e-mails.</span>
<span style="color: #000099;">ports</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"><span style="">25</span>/tcp</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">$ cat openldap
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>OpenLDAP<span style="">&#93;</span></span>
<span style="color: #000099;">title</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Server for the Lightweight Directory Access Protocol <span style="">&#40;</span>LDAP<span style="">&#41;</span></span>
<span style="color: #000099;">description</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">OpenLDAP is an open source implementation of a Lightweight Directory Access Protocol Server</span>
<span style="color: #000099;">ports</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"><span style="">389</span>/tcp</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>OpenLDAP Secure<span style="">&#93;</span></span>
<span style="color: #000099;">title</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Secure Server for the Lightweight Directory Access Protocol <span style="">&#40;</span>LDAPS<span style="">&#41;</span></span>
<span style="color: #000099;">description</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">OpenLDAP is an open source implementation of a Lightweight Directory Access Protocol Server</span>
<span style="color: #000099;">ports</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"><span style="">636</span>/tcp</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">$ cat dovecot-managesieve
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Dovecot Managesieve<span style="">&#93;</span></span>
<span style="color: #000099;">title</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Dovecot Managesieve Protocol</span>
<span style="color: #000099;">description</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Dovecot Managesieve allows to remotely administer sieve filters</span>
<span style="color: #000099;">ports</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"><span style="">2000</span>/tcp</span></pre></div></div>

<p>Danach habe ich VNC, deluge, exim, dovecot imap und imaps, CUPS, Samba, LDAP (wegen Adressbuch) für das lokale Netz freigeschalten mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app CUPS
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app Samba
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;Dovecot IMAP&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow <span style="color: #ff0000;">&quot;Dovecot Secure IMAP&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;Dovecot Managesieve&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app vino-server
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow Deluge
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;OpenLDAP&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;OpenLDAP Secure&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;Exim SMTP&quot;</span></pre></div></div>

<p>bzw. falls man nicht Exim sondern  Postfix einsetzt, welches standardmäßig installiert ist, die letzte Zeile ersetzen mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;Postfix&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw allow from 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> to any app <span style="color: #ff0000;">&quot;Postfix Submission&quot;</span></pre></div></div>

<p>Die Regeln werden übrigens in /var/lib/ufw/user.rules gespeichert. Eine <a href="https://help.ubuntu.com/community/Uncomplicated_Firewall_ufw?action=show">Anleitung zur Erstelltung eigener ufw-Regeln</a>, findet sich in der Hilfe der Ubuntu Server Edition. Im Ubuntu-Forum sind außerdem einige <a href="http://ubuntuforums.org/showthread.php?t=823741">Beispiele zu ufw</a>.</p>
<p>Wenn man wie ich <a href="http://www.effinger.org/blog/2008/11/21/virtualbox-und-intrepid-das-perfekte-setup-netzwerk/">VirtualBox über Proxy ARP</a> auf das Netzwerk zugreifen lässt, sollte man in der Datei /etc/default/ufw in folgender Zeile das DROP auf ACCEPT ändern, da ansonsten die virtuellen Maschinen nur noch Verbindungen zum Host aufbauen können.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># set the default forward policy to ACCEPT or DROP.  Please note that if you</span>
<span style="color: #666666; font-style: italic;"># change this you will most likely want to adjust your rules</span>
<span style="color: #666666; font-style: italic;"># Default was DROP</span>
<span style="color: #007800;">DEFAULT_FORWARD_POLICY</span>=<span style="color: #ff0000;">&quot;ACCEPT&quot;</span></pre></div></div>

<p>Normalerweise sollte nach einem</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> ufw <span style="color: #7a0874; font-weight: bold;">enable</span></pre></div></div>

<p>die Firewall bei jedem Neustart auch aktiviert werden. Falls dies nicht der Fall ist, muss man ggfs. in der Datei /etc/ufw/ufw.conf ENABLED auf yes setzen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/ufw/ufw.conf</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># set to yes to start on boot</span>
<span style="color: #007800;">ENABLED</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>Das Einzige, was mir an ufw noch fehlt, ist, dass keine Regeln für Interfaces unterstützt werden (siehe <a href="https://bugs.launchpad.net/ufw/+bug/247450">Feature Request</a>), aber vielleicht kommt das ja noch..</p>
<p>Nach der Aktivierung hatte ich außerdem einige unschöne Einträge in meiner Logdatei, die einen Zugriff von meinem Router auf den Port registrierten:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Jan <span style="color: #000000;">19</span> 05:<span style="color: #000000;">36</span>:<span style="color: #000000;">14</span> abraxas kernel: <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">51524.306320</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>UFW BLOCK INPUT<span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #007800;">IN</span>=eth1 <span style="color: #007800;">OUT</span>= <span style="color: #007800;">MAC</span>=00:<span style="color: #000000;">11</span>:d8:<span style="color: #000000;">59</span>:8a:<span style="color: #000000;">18</span>:00:<span style="color: #000000;">15</span>:0c:d5:1f:02:08:00 <span style="color: #007800;">SRC</span>=192.168.178.1 <span style="color: #007800;">DST</span>=192.168.178.200 <span style="color: #007800;">LEN</span>=<span style="color: #000000;">60</span> <span style="color: #007800;">TOS</span>=0x00 <span style="color: #007800;">PREC</span>=0x00 <span style="color: #007800;">TTL</span>=<span style="color: #000000;">64</span> <span style="color: #007800;">ID</span>=<span style="color: #000000;">29386</span> DF <span style="color: #007800;">PROTO</span>=TCP <span style="color: #007800;">SPT</span>=<span style="color: #000000;">4981</span> <span style="color: #007800;">DPT</span>=<span style="color: #000000;">14013</span> <span style="color: #007800;">WINDOW</span>=<span style="color: #000000;">5840</span> <span style="color: #007800;">RES</span>=0x00 SYN <span style="color: #007800;">URGP</span>=<span style="color: #000000;">0</span></pre></div></div>

<p>Nachforschungen im Internet ergaben, dass es sich um die <a href="http://www.ip-phone-forum.de/showthread.php?t=138295">Kindersicherung der Fritz-Box</a> handelt. Diese lässt sich über das Webinterface deaktivieren, allerdings hören die Portzugriffe erst nach einem Neustart auf.</p>
<p>Das Fazit zu ufw: Wirklich <a href="http://beginlinux.wordpress.com/2008/04/23/my-mom-learns-the-uncomplicated-firewall-on-ubuntu-804/">unkompliziert (&#8220;uncomplicated&#8221;) ist ufw nicht</a> &#8211; man muss schon wissen, was man macht. Im Vergleich zu iptables ist es aber doch deutlich einfacher zu bedienen und kommt der Regelerstellung auf gängigen Heimnetzerwerkroutern (abgesehen vom command-line syntax) relativ nahe.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.effinger.org/blog/2009/01/26/ufw-firewall-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
