<?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>ServerAdmins.NET &#187; freebsd</title>
	<atom:link href="http://serveradmins.net/tag/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://serveradmins.net</link>
	<description>Stuff for Server Admins...</description>
	<lastBuildDate>Wed, 22 Feb 2012 02:04:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>SSH timeouts suck.</title>
		<link>http://serveradmins.net/ssh-timeouts-suck/</link>
		<comments>http://serveradmins.net/ssh-timeouts-suck/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 02:03:39 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[keepalive]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh timeout]]></category>
		<category><![CDATA[ssh_config]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=101</guid>
		<description><![CDATA[SSH Keepalive timeouts are fixed in this post.]]></description>
			<content:encoded><![CDATA[<p>So if you&#8217;re ever connected to a remote machine (or several), and you frequently see this message after you walk away from your term for a bit&#8230;</p>
<p><code><br />
Write failed: Broken pipe<br />
</code></p>
<p>Do this from the machine you&#8217;re connecting from.  SSHD for Macs/Linux boxes should all have this file.  Windows, I&#8217;m not so much sure on.</p>
<p>(if not root already)<br />
<code><br />
sudo echo "ServerAliveInterval 5" >> /etc/ssh_config<br />
</code></p>
<p>Or just open it up in your favorite text editor, save and call it good.</p>
<p>What&#8217;s happening here is that somewhere between you and your destination, there&#8217;s a long enough of a timeout happening that you hit SSHs internal timeout.   This line just forces your SSH client to send a keepalive pulse fairly regularly to the endpoint.</p>
<p>Anyway, dumb quick fix to what ails so many of is.  </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/ssh-timeouts-suck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Basic IPFW firewall HowTo for FreeBSD&#8230;</title>
		<link>http://serveradmins.net/a-basic-ipfw-firewall-howto-for-freebsd/</link>
		<comments>http://serveradmins.net/a-basic-ipfw-firewall-howto-for-freebsd/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 01:42:27 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[allow]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[ipfw]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=65</guid>
		<description><![CDATA[How to setup and configure a basic firewall for FreeBSD using ipfw.]]></description>
			<content:encoded><![CDATA[<p>Of all the different OS&#8217;s and the multitude of firewall implementations for each, my favorite has to be FreeBSD&#8217;s IPFW ruleset.  It&#8217;s powerful, super efficient, and most of all, *EASY* to read! </p>
<p>So I&#8217;m just going to paste a sample firewall below, notate it heavily for you, and show you how to get it enabled.   </p>
<p>For newer FreeBSD builds, it&#8217;s enough to add <code>firewall_enable="YES"</code> to your /etc/rc.conf file and reboot.  This will load all the necessary kernel modules, and get you in shape.   You should know that by default FreeBSD defaults to a &#8216;default deny&#8217; policy.  This is *VERY* important to know.   What it means is that by default, your server isn&#8217;t going to open up any ports. You *WILL* be locked out if you do not have a firewall in place.  Don&#8217;t say I didn&#8217;t warn you!</p>
<p>So, with that being said, let&#8217;s get our firewall in built and in place, and then we&#8217;ll go about adding in the necessary options to ensure it comes up properly on boot.  It should noted here that you can build in a &#8220;Default to accept&#8221; option into the kernel or &#8220;firewall_type=&#8221;open&#8221; to the /etc/rc.conf to start up wide open.  This is the suggested practice as the chances are, you&#8217;re not close enough to your server to console it. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let&#8217;s get our basic firewall going.   We&#8217;re going to open up 22 for SSH, 80 for web traffic, 25 for SMTP and 110/143 for POP3/IMAP mail.   The syntax is simple enough you should be able to customize it for your own needs, but always make sure your SSH port is accessible.  Also if you run SSH on an alternative port, you should modify that here.  You don&#8217;t want to lock yourself out now, do you?</p>
<p>So go ahead, login as root to your server, open up your text editor of choice.  For the purpose of this post, I&#8217;m going to assume you&#8217;re creating the file /etc/firewall.sh.  If not, modify where appropriate. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   You should also make sure this file is executable by root, otherwise it won&#8217;t fire off properly on reboot.</p>
<p><code><br />
#!/bin/sh</p>
<p>set -e</p>
<p>#First, let's clear out any chance of conflicting with other FreeBSD firewall configurations<br />
# and make sure we're starting from a fresh slate.</p>
<p>/sbin/sysctl net.inet.ip.forwarding=0 >/dev/null<br />
/sbin/ipfw -q list >/dev/null 2>&#038;1 || /sbin/kldload ipfw<br />
(/sbin/ipf -D) >/dev/null 2>&#038;1 || true<br />
(/sbin/kldunload ipl) >/dev/null 2>&#038;1 || true<br />
(/sbin/pfctl -d) >/dev/null 2>&#038;1 || true<br />
(/sbin/kldunload pf) >/dev/null 2>&#038;1 || true<br />
/sbin/ipfw -q /dev/stdin < < EOF<br />
flush<br />
delete set 31</p>
<p>#Open up our Loopback device.  There's almost never any reason to filter this.<br />
add allow ip from any to any via lo0</p>
<p>#Allow checking/maintenance of stateful rulesets<br />
add check-state</p>
<p>#Kill off any active/open sessions, pre-fw init.  We do this<br />
#to ensure that any connection to unauthorized ports is dealt with<br />
#and that all connections adhere to the policy...</p>
<p>add reset tcp from any to any established</p>
<p>    ##########################<br />
## Add Inbound Service Allowances ##<br />
    ##########################<br />
#Port 80: www<br />
add allow tcp from any to me 80 setup in<br />
#Port 22: SSH - Stateful connection (it's going to maintain a connection, not come and go)<br />
add allow tcp from any to me 22 setup in keep-state</p>
<p>#Port 21, and 30000-50000, FTP and Passive port rolloff.<br />
add allow tcp from any to me 21 setup in<br />
add allow tcp from any to me 30000-50000 setup in keep-state</p>
<p>#Port 53: DNS<br />
add allow udp from any to me 53 in </p>
<p>#Port 25, 110, 143.  SMTP, POP3 and IMAP<br />
add allow tcp from any to me 25 in<br />
add allow tcp from any to me 110 in<br />
add allow tcp from any to me 143 in</p>
<p>#ICMP/ping requests should be allowed through, fun stuff happens<br />
#if you don't allow this.  (see ptmu)<br />
add icmp from any to me icmptypes 8 in</p>
<p> #################################<br />
## Lets Deny some Packets. WOOOT ##<br />
 #################################</p>
<p>#These rules denies everything else, not explicitly listed above<br />
add deny tcp from any to me setup in<br />
add deny ip from any to me in</p>
<p> ##################<br />
## Outbound Ahoy! ##<br />
 ##################</p>
<p>#Wide open outbound filtering.  You could modify this section to default to deny<br />
#And then allow specific ports out.  I'm not going to do that here, but you should<br />
#be able to figure it out. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>add allow tcp from me to any setup out keep-state<br />
add allow ip from me to any out keep-state</p>
<p> ###########################<br />
## Last chain to make sure ##<br />
 ###########################</p>
<p>#One more time, just to be positive...<br />
add deny tcp from any to any setup<br />
add deny ip from any to any<br />
enable firewall<br />
EOF</p>
<p>#I set this because the default FreeBSD behavior is to keep a table open<br />
#for a session for 1 hour.  That's a LONG time on a production server.  We<br />
#Go for 10 mins here, but could be lowered drastically.</p>
<p>#Set TTL on Dynamic Rules to 10 Mins.  Formerly 1 hour.<br />
/sbin/sysctl net.inet.ip.fw.dyn_ack_lifetime=600 >/dev/null</p>
<p></code></p>
<p>Done!</p>
<p>Save your /etc/firewall.sh file, then make sure permissions are right on it&#8230;</p>
<p><code><br />
chmod 755 /etc/firewall.sh &#038;&#038; chown root:wheel /etc/firewall.sh<br />
</code></p>
<p>Open up your handy text editor again, and add the following lines to /etc/rc.conf at the bottom.</p>
<p><code><br />
firewall_enable="YES"<br />
firewall_script="/etc/firewall.sh"<br />
</code></p>
<p>Done!   </p>
<p>Please keep in mind that if you set &#8220;firewall_type=open&#8221; above, it may overrule this firewall_script variable, so it should be removed.</p>
<p>Congrats, reboot and enjoy your new firewall. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If this is something you&#8217;re interested in, leave a comment and let me know how and I can write a few more articles on more complex configurations quite easily. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/a-basic-ipfw-firewall-howto-for-freebsd/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Updating the FreeBSD Ports tree, easily&#8230;</title>
		<link>http://serveradmins.net/updating-the-freebsd-ports-tree-easily/</link>
		<comments>http://serveradmins.net/updating-the-freebsd-ports-tree-easily/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 01:18:00 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Utility]]></category>
		<category><![CDATA[fastest_cvsup]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[how]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[portsnap]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[tree]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=52</guid>
		<description><![CDATA[How to get your FreeBDS ports tree updated and current, one way or another... =)

]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m feeling a bit lazy tonight, and wanted to get an update here, so for a bit I&#8217;ll show you a handy little tool to update your ports tree on FreeBSD.  After that, I&#8217;ll show you the ugly, old method.</p>
<p>Quick and easy&#8230;</p>
<p>Newer versions of FreeBSD come equipped with the &#8216;portsnap&#8217; utility.  This, makes it *VERY* simple to update your ports tree.  </p>
<p>For your first run, do this&#8230;<br />
<code><br />
portsnap fetch &#038;&#038; portsnap extract<br />
</code></p>
<p>This is going to grab a snapshot of the current ports tree, and simply extract it over your new tree, replacing *everything* as it goes.  You should only run the &#8216;extract&#8217; command the first time you run portsnap.</p>
<p>After that, you&#8217;ll want to run the following for any further updates&#8230;</p>
<p><code><br />
portsnap fetch &#038;&#038; portsnap update<br />
</code></p>
<p>Not only is this much quicker, it doesn&#8217;t overwrite everything. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you want to use this in a cron&#8217;d task, you should use the &#8216;portsnap cron 1&#8242; command.   It should be noted the number appended to the end of this is the number in seconds that portsnap will randomize the start of the app from.  For example, if you say &#8216;cron 2000&#8242;, portsnap will kick off *sometime* in the next 2000 seconds.  The reasoning for this is for larger serverfarms.  If you&#8217;re running that in cron on all of them and give portsnap a large window, it will keep them all from starting at the same time, loading the BSD servers and abusing your bandwidth.   I used 1 in the command above as I wasn&#8217;t really looking to use that. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Keep in mind this will only fetch the updates, you still need to update the tree afterwords&#8230;</p>
<p>A cron entry for this would look something like the following&#8230;</p>
<p><code><br />
0 3 * * * root /usr/sbin/portsnap cron &#038;&#038; /usr/sbin/portsnap update<br />
</code></p>
<p>So for normal, day to day operation once you&#8217;ve initialized your ports tree the following is what you&#8217;ll want to use and update.</p>
<p><code><br />
/usr/sbin/portsnap fetch &#038;&#038; /usr/sbin/portsnap update<br />
</code></p>
<p>Now, if you don&#8217;t have portsnap, you should use the following method to update your ports tree.  We&#8217;re going to go oldschool with cvsup here.</p>
<p>Edit:  From reader Bazzoola points out that this is outdated and antiquated and well, he&#8217;s 100% right.   Any current installations of FreeBSD should have the portsnap utility installed so this shouldn&#8217;t be necessary.  Consider it here for the sake of memories. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First of all, let&#8217;s find our fastest cvsup mirror&#8230;</p>
<p><code><br />
[root@R34 ~]# cd /usr/ports/sysutils/fastest_cvsup/<br />
[root@R34 /usr/ports/sysutils/fastest_cvsup]# make &#038;&#038; make install<br />
</code></p>
<p>This is going to install the &#8216;fastest_cvsup&#8217; port&#8230;  Afterwords, for the US locale, you can run the following to find your fastest cvsup mirror&#8230;</p>
<p><code><br />
[root@R34 /usr/ports/sysutils/fastest_cvsup]# fastest_cvsup  -c us<br />
>>  Querying servers in countries: us<br />
--> Connecting to cvsup.us.freebsd.org [72.233.193.64]...<br />
    - server replied: ! Access limit exceeded; try again later<br />
    - time taken: 69.51 ms<br />
--> Connecting to cvsup2.us.freebsd.org [130.94.149.166]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 27.19 ms<br />
--> Connecting to cvsup3.us.freebsd.org [128.31.0.28]...<br />
    - server replied: ! Access denied<br />
    - time taken: 31.65 ms<br />
--> Connecting to cvsup4.us.freebsd.org [149.20.64.73]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 55.77 ms<br />
--> Connecting to cvsup5.us.freebsd.org [208.83.20.166]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 36.99 ms<br />
--> Connecting to cvsup6.us.freebsd.org [64.202.113.190]...<br />
    * error: connect: Invalid argument<br />
--> Connecting to cvsup7.us.freebsd.org [64.215.216.140]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.64 ms<br />
--> Connecting to cvsup8.us.freebsd.org [216.165.129.134]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 6.23 ms<br />
--> Connecting to cvsup9.us.freebsd.org [128.205.32.21]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.28 ms<br />
--> Connecting to cvsup10.us.freebsd.org [69.147.83.48]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 54.01 ms<br />
--> Connecting to cvsup11.us.freebsd.org [63.87.62.77]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 35.11 ms<br />
--> Connecting to cvsup12.us.freebsd.org [128.205.32.24]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.86 ms<br />
--> Connecting to cvsup13.us.freebsd.org [128.205.32.24]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.54 ms<br />
--> Connecting to cvsup14.us.freebsd.org [216.87.78.137]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 34.63 ms<br />
--> Connecting to cvsup15.us.freebsd.org [35.9.37.225]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 23.49 ms<br />
--> Connecting to cvsup16.us.freebsd.org [128.143.108.35]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 23.47 ms<br />
--> Connecting to cvsup17.us.freebsd.org [65.212.71.21]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 35.93 ms<br />
--> Connecting to cvsup18.us.freebsd.org [128.205.32.84]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 3026.06 ms</p>
<p>>>  Speed Daemons:<br />
    - 1st: cvsup8.us.freebsd.org    6.23 ms<br />
    - 2st: cvsup16.us.freebsd.org   23.47 ms<br />
    - 3st: cvsup15.us.freebsd.org   23.49 ms<br />
[root@R34 /usr/ports/sysutils/fastest_cvsup]#<br />
</code></p>
<p>Cvsup8 it is!</p>
<p>So now, let&#8217;s get our ports-supfile in place&#8230;</p>
<p><code><br />
cp /usr/share/examples/cvsup/ports-supfile /root/<br />
</code></p>
<p>Now edit /root/ports-supfile and look for the following line&#8230;</p>
<p><code>*default host=CHANGE_THIS.FreeBSD.org</code></p>
<p>And modify it to read&#8230;<br />
<code>*default host=csup8.freebsd.org</code></p>
<p>Now, run the following to get *everything* up to date&#8230;</p>
<p><code><br />
cvsup -g -L 2 /root/ports-supfile<br />
</code></p>
<p>Voila, you have an updated ports tree. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/updating-the-freebsd-ports-tree-easily/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
