<?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>Felipe Alfaro Solana &#187; FreeBSD</title>
	<atom:link href="http://www.felipe-alfaro.org/blog/category/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.felipe-alfaro.org/blog</link>
	<description>A little bit of technology, security and networking with Linux, FreeBSD and Mac OS X, plus some personal opinions.</description>
	<lastBuildDate>Sun, 23 Oct 2011 16:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Configuring WPA2 Enterprise with EAP-TLS in Mac OS X and Linux</title>
		<link>http://www.felipe-alfaro.org/blog/2006/01/29/wpa2-eap-tls/</link>
		<comments>http://www.felipe-alfaro.org/blog/2006/01/29/wpa2-eap-tls/#comments</comments>
		<pubDate>Sun, 29 Jan 2006 17:52:19 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2006/01/29/wpa2-enterprise/</guid>
		<description><![CDATA[Setting up the CA Follow the steps on setting up a Certificate Authority (CA) using OpenSSL. Issuing the client certificate and private key Once the CA has been configured, we will generate a private key and an unsigned public key digital certificate. # openssl req -new -days 365 -newkey rsa:1024 \ -keyout sslkey.pem -out unsigned.pem [...]]]></description>
			<content:encoded><![CDATA[<h3>Setting up the CA</h3>
<p>Follow the steps on <a href="/blog/2005/11/18/setting-up-certificate-authority-ca-using-openssl/" title="Setting up a Certificate Authority (CA) using OpenSSL">setting up a Certificate Authority (CA) using OpenSSL</a>.</p>
<h3>Issuing the client certificate and private key</h3>
<p>Once the CA has been configured, we will generate a private key and an unsigned public key digital certificate.</p>
<p><code># openssl req -new -days 365 -newkey rsa:1024 \<br />
-keyout sslkey.pem -out unsigned.pem</code></p>
<p>The unsigned public key digital certificate, stored in a PEM-encoded file named <code>unsigned.pem</code> will be sent to the CA for signing:</p>
<p><code># openssl ca -in unsigned.pem -out cert.pem</code></p>
<h3>Installing the client certificate and private key</h3>
<p>The next step consists in installing the private key, public key digital certificate and CA public key certificate.</p>
<h4>Linux</h4>
<p>The private key, public key digital certificate and CA certificate files should get installed into a location where only root and wpa_supplicant can access them, for example, <b>/etc/wpa</b>:</p>
<p><code># mkdir /etc/wpa</code><br />
<code># chown root.root /etc/wpa</code><br />
<code># chmod 700 /etc/wpa</code></p>
<h4>Mac OS X</h4>
<p>Mac OS X can only import private keys in PKCS#12 so we need to export all the previous items to a suitable format:</p>
<p><code># openssl pkcs12 -export -in cert.pem -inkey key.pem \<br />
-out client.p12 -name "host.domain"</code></p>
<p>Where <code>"host.domain"</code> denotes the FQDN of the host which this digital certificate and private key are intended for.</p>
<p>The output file <b>client.p12</b> contains the private key and public key digital certificate. This bundle should get moved to the host using a secure distribution channel, like an SSH/SCP/SFTP session or a USB key. Also, the CA digital certificate, usually named <b>cacert.pem</b>, should also get copied to the host.</p>
<p>On Mac OS X, using the GUI, double click the <b>cacert.pem</b> file, and install the CA certificate into the <b>X509Anchors</b> keychain. This a system-wide keychain intended to store X.509 CA root digital certificates.</p>
<p><img src="/blog/wp-content/WPA2/cacert.png"/></p>
<p>Next, using the GUI, double click on <b>client.p12</b> file, supply the password that protects the private key stored in this file, and choose to install both the private key and public key into the <b>login</b> keychain. Next, make sure the private key has been installed:</p>
<p><img src="/blog/wp-content/WPA2/keychain.png" width="100%"/></p>
<h3>Configuring the AirPort Express Wireless Access Point</h3>
<p>Launch <b>AirPort Admin Utility</b>, select the desired base station and click the <b>Configure</b> icon from the toolbar:</p>
<p><img src="/blog/wp-content/WPA2/ap.png" width="100%"/></p>
<p>Click the <b>Change Wireless Security&#8230;</b> button:</p>
<p><img src="/blog/wp-content/WPA2/ap_wpa2.png" width="100%"/></p>
<p>In this new window, fill in the information about the RADIUS server, like its IP address, shared secret and so on.</p>
<h3>Configuring the Supplicant for WPA2 Enterprise</h3>
<h4>Linux</h4>
<p>Create <b>/etc/wpa_supplicant.conf</b> using the following data:</p>
<div>
<pre>ctrl_interface=/var/run/wpa_supplicant
ap_scan=2
network={
  scan_ssid=1
  ssid="iTunes"
  proto=WPA2
  key_mgmt=WPA-EAP
  pairwise=CCMP
  group=CCMP
  ca_cert="/etc/wpa/cacert.pem"
  client_cert="/etc/wpa/cert.pem"
  private_key="/etc/wpa/key.pem"
  eap=TLS
  identity="anonymous"
}</pre>
</div>
<p>The <b>identity</b> directive is required, or else the EAP-TLS negotiation will fail.</p>
<p><b>ap_scan=2</b> and <b>scan_ssid=1</b> are needed when the Wireless Acccess Point is configured to not broadcast the ESSID.</p>
<h4>Mac OS X</h4>
<p>Launch <b>Internet Connect</b> from the Wireless menu:</p>
<p><img src="/blog/wp-content/WPA2/ic.png" width="100%"/></p>
<p>If no 802.1X icon appears on the toolbar, choose <b>File -> New 802.1X Conection&#8230;</b>. Click the 802.1X icon. The window will look like this:</p>
<p><img src="/blog/wp-content/WPA2/8021X.png" width="100%"/></p>
<p>From the <b>Configuration</b> drop-down, select <b>Edit Configurations&#8230;</b>:</p>
<p><img src="/blog/wp-content/WPA2/8021X_new.png" width="100%"/></p>
<p>A window like this will open:</p>
<p><img src="/blog/wp-content/WPA2/8021X_data.png" width="100%"/></p>
<p>Fill in both the <em>&#8220;Description&#8221;</em> and <em>&#8220;Wireless Network&#8221;</em> fields with the ESSID of the Wireless network. Leave <em>&#8220;User Name&#8221;</em> and <em>&#8220;Password&#8221;</em> blanked, since we are not using password-based authentication.</p>
<p>From the <em>&#8220;Authentication&#8221;</em> listbox, clear the checkbox for all the protocols except for <b>TLS</b>. Select the TLS protocol and click the Configure button. A new window will open for you to select the private key that will be used for the EAP-TLS authentication mechanism:</p>
<p><img src="/blog/wp-content/WPA2/8021X_key.png" width="100%"/></p>
<p>From the drop-down listbox, select the name of the private key that matches the name of the private key installed in the previous section.</p>
<p>Click the <b>Connect</b> button. The Supplicant will authenticate against the Wireless Access Point. At this point, it is possible that Mac OS X asks confirmation for accessing the private key stored in your keychain. It is recommended to &#8220;Always Allow&#8221; the Supplicant access to the private key.</p>
<p><img src="/blog/wp-content/WPA2/8021X_connected.png" width="100%"/></p>
<p>Launch <b>System Preferences -> Network</b> and <b>Configure&#8230;</b> the AirPort interface:</p>
<p><img src="/blog/wp-content/WPA2/network.png" width="100%"/></p>
<p>Click the <b>&#8220;+&#8221;</b> button to add a Preferred network:</p>
<p><img src="/blog/wp-content/WPA2/preferred.png" width="100%"/></p>
<p>Just enter the ESSID of the Wireless network and choose <b>WPA2 Enterprise</b> from the <b>Wireless Security</b> drop-down listbox. Also, make sure the <b>Configuration</b> field shows the name of the 802.1X configuration we created previously using Internet Connect.</p>
<p>Leave the rest of the fields blank, since we are not using password-based authentication.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2006/01/29/wpa2-eap-tls/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>FreeBSD firewall using PF</title>
		<link>http://www.felipe-alfaro.org/blog/2005/11/12/freebsd-firewall-using-pf/</link>
		<comments>http://www.felipe-alfaro.org/blog/2005/11/12/freebsd-firewall-using-pf/#comments</comments>
		<pubDate>Sat, 12 Nov 2005 16:11:22 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Firewall]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/?p=67</guid>
		<description><![CDATA[FreeBSD supports OpenBSD&#8217;s powerful firewall PF since version 5.3. The scenario I was pursuing was firewalling one of my FreeBSD machines: Incoming firewalling Only incoming SSH connections from known SSH clients should be accepted. Only incoming Syslog traffic from known Syslog clients should be accepted. Only incoming ICMP Echo-Reply, ICMP Echo-Request and ICMP Destination-Unreachable datagrams [...]]]></description>
			<content:encoded><![CDATA[<p>FreeBSD supports OpenBSD&#8217;s powerful firewall PF since version 5.3. The scenario I was pursuing was firewalling one of my FreeBSD machines:</p>
<h4>Incoming firewalling</h4>
<ul>
<li>Only incoming SSH connections from known SSH clients should be accepted.</li>
<li>Only incoming Syslog traffic from known Syslog clients should be accepted.</li>
<li>Only incoming ICMP Echo-Reply, ICMP Echo-Request and ICMP Destination-Unreachable datagrams should be accepted. Any other ICMP datagram is potentially dangerous.</li>
<li>No other incoming traffic should be allowed, but should get logged.</li>
</ul>
<h4>Outgoing firewalling</h4>
<ul>
<li>Only outgoing DNS queries to known DNS servers should be accepted.</li>
<li>Only outgoing NTP traffic to know NTP servers should be accepted.</li>
<li>Only outgoing ICMP Echo-Reply, ICMP Echo-Request and ICMP Destination-Unreachable datagrams should be accepted. Any other ICMP datagram is potentially dangerous.</li>
<li>No other outgoing traffic should be allowed, but should get logged.</li>
</ul>
<p>The contents of <code>/etc/pf.conf</code> should look lite this:</p>
<pre>
<div>scrub in all
pass quick on lo0 all

icmp_types = "{ echorep, unreach, echoreq }"
syslog_sources = "{ 192.168.0.124, 192.168.0.125, 192.168.0.126 }"
ssh_sources = "{ 192.168.0.90, 192.168.0.91 }"
ntp_servers = "{ 192.168.0.125 }"
dns_servers = "{ 192.168.0.124 }"

block in log all
pass in on rl0 inet proto icmp icmp-type $icmp_types keep state
pass in on rl0 proto tcp from $ssh_sources to self \
  port { 22 } flags S/SA keep state
pass in on rl0 proto udp from $syslog_sources to self \
  port { 514 }

block out log all
pass out on rl0 inet proto icmp icmp-type $icmp_types keep state
pass out on rl0 proto udp from self to $dns_servers \
  port { 53 } keep state
pass out on rl0 proto udp from self to $ntp_servers \
  port { 123 } keep state</div>
</pre>
<p>To enable PF and PF logging support to start automatically during boot, the following lines should be added to <code>/etc/rc.conf</code>:</p>
<p><code>pf_enable="YES"<br />
pf_rules="/etc/pf.conf"<br />
pf_program="/sbin/pfctl"<br />
pflog_enable="YES"<br />
pflog_logfile="/var/log/pflog"<br />
pflog_program="/sbin/pflogd"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2005/11/12/freebsd-firewall-using-pf/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>syslog-ng replacement for FreeBSD</title>
		<link>http://www.felipe-alfaro.org/blog/2005/10/31/syslog-ng-replacement-for-freebsd/</link>
		<comments>http://www.felipe-alfaro.org/blog/2005/10/31/syslog-ng-replacement-for-freebsd/#comments</comments>
		<pubDate>Sun, 30 Oct 2005 23:57:50 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Syslog]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/?p=62</guid>
		<description><![CDATA[FreeBSD uses syslog by default. However, syslog is very old and inflexible, so I decided to replace it with syslog-ng. syslog-ng syntax is far more easier to read and understand than syslog&#8217;s one. syslog-ng uses the following elements to determine what to log and where to log it: Source: Defines where log entries do come [...]]]></description>
			<content:encoded><![CDATA[<p>FreeBSD uses syslog by default. However, syslog is very old and inflexible, so I decided to replace it with <em>syslog-ng</em>. <em>syslog-ng</em> syntax is far more easier to read and understand than syslog&#8217;s one.</p>
<p><em>syslog-ng</em> uses the following elements to determine what to log and where to log it:</p>
<ul>
<li><b>Source:</b> Defines where log entries do come from. For example, <em>syslog-ng</em> can read log entries from the <em>/var/run/log</em> local socket, from the network via UDP port 514, via TCP, and so on.
<p>I just decided to split the sources in two:</p>
<ol>
<li>A local source, called <em>src</em></li>
<li>A network source, called <em>net</em></li>
</ol>
<p>This allows easily to distinguish between locally generated log entries and log entries generated elsewhere by a network device or host machine.</li>
<li><b>Destination:</b> Defines where do log entries will get logged into. For example, log entries can be written to a file, can be sent to another syslog-compatible server, sent to a socket, and so on.
<p>I have kept the default destinations, and added a new one called <em>airport</em>, pointing to file <em>/var/log/airport.log</em>. All log events generated by my AirPort Express Wireless Access Point will get logged into this destination.</li>
<li><b>Filter:</b> Defines a matching criteria for log entries. Allows to distinguish log entries by some common attributes, like the source host, facility, logging level, a regular expression matching the entry description, and so on.
<p>I have kept the default filters, but added a new one called <em>f_airport</em>, which matches all log entries whose source is my Wireless Access Point.</li>
</ul>
<p>Finally, <b>log</b> entries combine sources, filters and destinations. When a log entry is received, it is matched against every <b>log</b> rules until a source and a filter matches. Then, the log entry is sent to the destination or destinations for that matching rule.</p>
<p>Since I wanted to centralize some logs into my FreeBSD server across the network, concretely my AirPort Express logs, this is the <em>/usr/local/etc/syslog-ng/syslog-ng.conf</em> file I used to achieve it:</p>
<pre>
#
# options
#
options { long_hostnames(off); sync(0); };

#
# sources
#
source src { unix-dgram("/var/run/log");
             unix-dgram("/var/run/logpriv" perm(0600));
             internal(); file("/dev/klog"); };

source net { udp(); };

#
# destinations
#
destination messages { file("/var/log/messages"); };
destination security { file("/var/log/security"); };
destination authlog { file("/var/log/auth.log"); };
destination maillog { file("/var/log/maillog"); };
destination lpd-errs { file("/var/log/lpd-errs"); };
destination xferlog { file("/var/log/xferlog"); };
destination cron { file("/var/log/cron"); };
destination debuglog { file("/var/log/debug.log"); };
destination consolelog { file("/var/log/console.log"); };
destination all { file("/var/log/all.log"); };
destination newscrit { file("/var/log/news/news.crit"); };
destination newserr { file("/var/log/news/news.err"); };
destination newsnotice { file("/var/log/news/news.notice"); };
destination console { file("/dev/console"); };
destination allusers { usertty("*"); };
#destination loghost { udp("loghost" port(514)); };
destination airport { file("/var/log/airport.log"); };
destination linksys { file("/var/log/linksys.log"); };

#
# log facility filters
#
filter f_auth { facility(auth); };
filter f_authpriv { facility(authpriv); };
filter f_not_authpriv { not facility(authpriv); };
filter f_console { facility(console); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_ftp { facility(ftp); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_news { facility(news); };
filter f_security { facility(security); };
filter f_user { facility(user); };
filter f_uucp { facility(uucp); };
filter f_local0 { facility(local0); };
filter f_local1 { facility(local1); };
filter f_local2 { facility(local2); };
filter f_local3 { facility(local3); };
filter f_local4 { facility(local4); };
filter f_local5 { facility(local5); };
filter f_local6 { facility(local6); };
filter f_local7 { facility(local7); };

#
# log level filters
#
filter f_emerg { level(emerg); };
filter f_alert { level(alert..emerg); };
filter f_crit { level(crit..emerg); };
filter f_err { level(err..emerg); };
filter f_warning { level(warning..emerg); };
filter f_notice { level(notice..emerg); };
filter f_info { level(info..emerg); };
filter f_debug { level(debug..emerg); };
filter f_is_debug { level(debug); };

#
# airport filter
#
filter f_airport { host("airport"); };

#
# linksys filter
#
filter f_linksys { host("linksys"); };

#
# *.err;kern.warning;auth.notice;mail.crit              /dev/console
#
log { source(src); filter(f_err); destination(console); };
log { source(src); filter(f_kern); filter(f_warning); destination(console); };
log { source(src); filter(f_auth); filter(f_notice); destination(console); };
log { source(src); filter(f_mail); filter(f_crit); destination(console); };

#
# *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
#
log { source(src); filter(f_notice); filter(f_not_authpriv); destination(messages); };
log { source(src); filter(f_kern); filter(f_debug); destination(messages); };
log { source(src); filter(f_lpr); filter(f_info); destination(messages); };
log { source(src); filter(f_mail); filter(f_crit); destination(messages); };
log { source(src); filter(f_news); filter(f_err); destination(messages); };

#
# security.*                                            /var/log/security
#
log { source(src); filter(f_security); destination(security); };

#
# auth.info;authpriv.info                               /var/log/auth.log
log { source(src); filter(f_auth); filter(f_info); destination(authlog); };
log { source(src); filter(f_authpriv); filter(f_info); destination(authlog); };

#
# mail.info                                             /var/log/maillog
#
log { source(src); filter(f_mail); filter(f_info); destination(maillog); };

#
# lpr.info                                              /var/log/lpd-errs
#
log { source(src); filter(f_lpr); filter(f_info); destination(lpd-errs); };

#
# ftp.info                                              /var/log/xferlog
#
log { source(src); filter(f_ftp); filter(f_info); destination(xferlog); };

#
# cron.*                                                /var/log/cron
#
log { source(src); filter(f_cron); destination(cron); };

#
# *.=debug                                              /var/log/debug.log
#
log { source(src); filter(f_is_debug); destination(debuglog); };

#
# *.emerg                                               *
#
log { source(src); filter(f_emerg); destination(allusers); };

#
# airport logging
#
log { source(net); filter(f_airport); destination(airport); };

#
# linksys logging
#
log { source(net); filter(f_linksys); destination(linksys); };
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2005/10/31/syslog-ng-replacement-for-freebsd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

