<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7980922255211744664</id><updated>2012-01-09T12:55:13.260-08:00</updated><category term='pf'/><category term='freebsd'/><category term='postgresql'/><category term='firewall'/><category term='jails'/><title type='text'>Things I Do</title><subtitle type='html'>notes from random projects</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7980922255211744664.post-2734492130806807553</id><published>2012-01-09T12:52:00.000-08:00</published><updated>2012-01-09T12:55:13.270-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='postgresql'/><title type='text'>New PostgreSQL Databases And The Users That Own Them</title><content type='html'>A quick post on how to create new databases with owners other than 'postgres'.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ psql postgres&lt;br /&gt;postgres=# CREATE USER someuser WITH PASSWORD 'password goes here';&lt;br /&gt;CREATE USER&lt;br /&gt;postgres=# CREATE DATABASE newDatabase WITH OWNER = someuser;&lt;br /&gt;CREATE DATABASE&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;A quick, random password can be created using &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;/dev/random&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ head -c 10 /dev/random | uuencode -m -&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7980922255211744664-2734492130806807553?l=thecolinblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/2734492130806807553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thecolinblog.blogspot.com/2012/01/postgresql-users.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/2734492130806807553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/2734492130806807553'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/2012/01/postgresql-users.html' title='New PostgreSQL Databases And The Users That Own Them'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7980922255211744664.post-125392861220219965</id><published>2011-11-27T21:01:00.001-08:00</published><updated>2011-11-27T21:10:07.794-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pf'/><category scheme='http://www.blogger.com/atom/ns#' term='firewall'/><title type='text'>pf Tables</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pf&lt;/span&gt; has &lt;a href="http://www.openbsd.org/faq/pf/tables.html" target="_blank"&gt;tables&lt;/a&gt;, which are extremely useful when creating and destroying jails. The given link has all the information needed, but below are some quick commands to get started.&lt;br /&gt;&lt;br /&gt;A series of jails will be created, with IP addresses 10.10.10.100-105. A small&amp;nbsp;excerpt&amp;nbsp;from &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pf.conf&lt;/span&gt; follows, in which a table is created, IPs given, and a rule to use it.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;table &amp;lt;jails&amp;gt; persist { \&lt;br /&gt;        10.10.10.100, \&lt;br /&gt;        10.10.10.101, \&lt;br /&gt;        10.10.10.102, \&lt;br /&gt;        10.10.10.103, \&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;pass in on $ext_if proto tcp from any to &amp;lt;jails&amp;gt; port 22&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This should permit SSH to the jails table. A new jail has just been created, add it to the table and then display the table contents.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo pfctl -t jails -T add 10.10.10.104&lt;br /&gt;$ sudo pfctl -t jails -T show&lt;br /&gt;10.10.10.100&lt;br /&gt;10.10.10.101&lt;br /&gt;10.10.10.102&lt;br /&gt;10.10.10.103&lt;br /&gt;10.10.10.104&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pf.conf&lt;/span&gt; file must still be modified to include this new IP address if it is to persist across reboots.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7980922255211744664-125392861220219965?l=thecolinblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/125392861220219965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/pf-tables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/125392861220219965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/125392861220219965'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/pf-tables.html' title='pf Tables'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7980922255211744664.post-8832937578409489003</id><published>2011-11-16T20:46:00.001-08:00</published><updated>2011-11-16T21:03:24.391-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pf'/><category scheme='http://www.blogger.com/atom/ns#' term='freebsd'/><title type='text'>Packet Filter (pf)</title><content type='html'>There are several firewall options for FreeBSD - this is about &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pf&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Kernel Options&lt;/span&gt;&lt;br /&gt;While &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pf&lt;/span&gt; can be loaded as a kernel module, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ALTQ&lt;/span&gt; cannot. If the kernel is to be recompiled, may as well add both. Below are all the pieces available, but not all are required depending on usage. If there is no intended use of &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ALTQ&lt;/span&gt;, then kernel modules may be used instead.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# pf - manually added&lt;br /&gt;device          pf              # OpenBSD Packet Filter firewall&lt;br /&gt;device          pflog           # pseudo network device for logging&lt;br /&gt;device          pfsync          # state change log interface (HA)&lt;br /&gt;# ALTQ - queues&lt;br /&gt;options         ALTQ            # ALTQ framework&lt;br /&gt;options         ALTQ_CBQ        # Class Based Queueing&lt;br /&gt;options         ALTQ_RED        # Random Early Detection&lt;br /&gt;options         ALTQ_RIO        # Random Early Detection In and Out&lt;br /&gt;options         ALTQ_HFSC       # Hierarchical Fair Service Curve Sched.&lt;br /&gt;options         ALTQ_PRIQ       # Priority Queueing. high traffic first&lt;br /&gt;options         ALTQ_NOPCC      # SMP support. Required on SMP systems&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There are some pieces for &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;rc.conf&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# pf&lt;br /&gt;pf_enable="YES"                 # enable pf&lt;br /&gt;pf_rules="/etc/pf.conf"         # rules definition file for pf&lt;br /&gt;pf_flags=""                     # additional flags for pfctl&lt;br /&gt;pflog_enable="YES"              # start pflogd(8)&lt;br /&gt;pflog_logfile="/var/log/pflog"  # where pflogd stores logfile&lt;br /&gt;pflog_flags=""                  # additional flags for pflogd&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Example configurations for &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pf&lt;/span&gt; can be found in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/share/examples/pf&lt;/span&gt; on FreeBSD. Or, read through the &lt;a href="http://www.openbsd.org/faq/pf/index.html" target="_blank"&gt;documentation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Recompile the kernel and restart. Or, if using modules: &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;kldload pf&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7980922255211744664-8832937578409489003?l=thecolinblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/8832937578409489003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/packet-filter-pf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/8832937578409489003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/8832937578409489003'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/packet-filter-pf.html' title='Packet Filter (pf)'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7980922255211744664.post-4026275786448752518</id><published>2011-11-16T20:12:00.001-08:00</published><updated>2011-11-17T14:23:24.997-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jails'/><category scheme='http://www.blogger.com/atom/ns#' term='freebsd'/><title type='text'>ezjail Flavour</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: large;"&gt;About Flavours&lt;/span&gt;&lt;br /&gt;ezjail provides a template system called "flavours." A flavour can be specified when creating an ezjail jail (-f flag), making it extremely easy to create similar jails over and over.&lt;br /&gt;&lt;br /&gt;Flavours live in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;BASE_EZJAIL_DIR/flavours&lt;/span&gt; - the rest of this post will assume &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;BASE_EZJAIL_DIR&lt;/span&gt; is &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/jails&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ezjail-admin&lt;/span&gt; version is 3.0.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Create A Flavour&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ cd /usr/jails/flavours&lt;br /&gt;$ sudo cp -r example theusual&lt;br /&gt;$ cd theusual/etc&lt;br /&gt;$ sudo vi resolv.conf&lt;br /&gt;$ cd ..&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above block copied the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;example&lt;/span&gt; directory to &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;theusual&lt;/span&gt; and then created &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;resolv.conf&lt;/span&gt; so the new jail knows the local nameserver.&lt;br /&gt;&lt;br /&gt;Now to use it.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo ezjail-admin create -f theusual jail1 10.10.10.101&lt;br /&gt;$ sudo ezjail-admin start jail1&lt;br /&gt;$ sudo ezjail-admin console jail1&lt;br /&gt;# telnet www.google.com 80&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above assumes network settings are correct and a firewall does not block out going port 80 traffic.&lt;br /&gt;&lt;br /&gt;On the first start-up, the new jail will run &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ezjail.flavour&lt;/span&gt;, which is a shell script. This can be modified to add users, packages, start services, and so on. With a working network, hopefully setup with the above resolv.conf, packages can even be installed remotely.&lt;br /&gt;&lt;br /&gt;The example &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ezjail.flavour&lt;/span&gt;, which was copied, looks for a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pkg&lt;/span&gt; directory and tries to load packages from there.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ cd /usr/jails/flavours/theusual&lt;br /&gt;$ sudo mkdir pkg&lt;br /&gt;$ sudo cp /some/dir/with/some_package.tbz pkg/&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Upon initial start-up, the next jail created with this flavour will install the local package &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;some_package&lt;/span&gt;. The example script also has examples for adding users, groups, and starting services.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;A Full Example&lt;/span&gt;&lt;br /&gt;The example flavour, provided by ezjail, has a few lines for adding groups, users, and packages. Below is a full example, with the few modifications clearly labeled. This is used to create an environment for Hadoop by installing java (in pkg directory), creating a hadoop user, and setting up and starting sshd.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:shell"&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# Groups&lt;br /&gt;#########&lt;br /&gt;#&lt;br /&gt;# You will probably start with some groups your users should be in&lt;br /&gt;&lt;br /&gt;pw groupadd -q -n hadoop # -g 1004&lt;br /&gt;&lt;br /&gt;# Users&lt;br /&gt;########&lt;br /&gt;#&lt;br /&gt;# You might want to add some users. The password is to be provided in the&lt;br /&gt;# encrypted form as found in /etc/master.passwd.&lt;br /&gt;# The example password here is "admin"&lt;br /&gt;# Refer to crypt(3) and pw(8) for more information&lt;br /&gt;&lt;br /&gt;# add our hadoop user here&lt;br /&gt;# user: hadoop, group: hadoop, uid: 110&lt;br /&gt;pw useradd -n hadoop -u 110 -g hadoop -s /bin/sh -m -d /home/hadoop -c 'hadoop account'&lt;br /&gt;mkdir -p /home/hadoop/.ssh&lt;br /&gt;chmod 700 /home/hadoop/.ssh&lt;br /&gt;&lt;br /&gt;echo -n 'NOTE: THIS WOULD BE SSH KEY' &amp;gt;&amp;gt; /home/hadoop/.ssh/authorized_keys2&lt;br /&gt;chown -R hadoop:hadoop /home/hadoop&lt;br /&gt;&lt;br /&gt;# Files&lt;br /&gt;########&lt;br /&gt;#&lt;br /&gt;# You can now give files to users just created&lt;br /&gt;&lt;br /&gt;# /usr/hadoop is where hadoop will live&lt;br /&gt;tar -zxf /usr/hadoop/hadoop*tar.gz -C /usr/hadoop/&lt;br /&gt;rm /usr/hadoop/hadoop-*.tar.gz&lt;br /&gt;chown -R hadoop:hadoop /usr/hadoop&lt;br /&gt;&lt;br /&gt;# Packages&lt;br /&gt;###########&lt;br /&gt;#&lt;br /&gt;# Install all packages previously put to /pkg&lt;br /&gt;# Remove package files afterwards&lt;br /&gt;&lt;br /&gt;# load the staged packages&lt;br /&gt;[ -d /pkg ] &amp;amp;&amp;amp; PACKAGESITE=file:// pkg_add -r /pkg/*&lt;br /&gt;rm -rf /pkg&lt;br /&gt;&lt;br /&gt;# Postinstall&lt;br /&gt;##############&lt;br /&gt;#&lt;br /&gt;# Your own stuff here, for example set login shells that were only&lt;br /&gt;# installed just before.&lt;br /&gt;hname=`uname -n`&lt;br /&gt;# sshd&lt;br /&gt;echo "ListenAddress $hname" &amp;gt;&amp;gt; /etc/ssh/sshd_config&lt;br /&gt;echo 'sshd_enable="YES"' &amp;gt;&amp;gt; /etc/rc.conf&lt;br /&gt;/etc/rc.d/sshd start&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7980922255211744664-4026275786448752518?l=thecolinblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/4026275786448752518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/ezjail-flavour.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/4026275786448752518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/4026275786448752518'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/ezjail-flavour.html' title='ezjail Flavour'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7980922255211744664.post-8332562707837187027</id><published>2011-11-15T20:55:00.001-08:00</published><updated>2011-11-15T20:59:38.902-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jails'/><category scheme='http://www.blogger.com/atom/ns#' term='freebsd'/><title type='text'>First FreeBSD Jail</title><content type='html'>I want a jail to build packages while leaving other jails clean. This should result in only one jail getting cluttered with various source files and what-not. The steps below assume ezjail has never been initialized.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Initialize ezjail&lt;/span&gt;&lt;br /&gt;In a &lt;a href="http://thecolinblog.blogspot.com/2011/11/jail-host-set-up.html"&gt;previous post&lt;/a&gt;, I provided a few quick steps to getting a system ready for jails. The next step is to run &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ezjail-admin&lt;/span&gt; for the first time.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo ezjail-admin install -p&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This will have initialized the jail system for the first time and created a copy of the ports tree. The default directory for the install is &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/jails&lt;/span&gt; and will be created if not already present. Easy.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Create First Jail&lt;/span&gt;&lt;br /&gt;A jail needs an IP address. If aliases were setup in rc.conf (and rebooted), then things should be good. If not, here is the syntax:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo ifconfig em0 inet 10.10.10.110 netmask 255.255.255.255 alias&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Create and start the first jail.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo ezjail-admin create builder 10.10.10.110&lt;br /&gt;$ sudo ezjail-admin start builder&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Jail Configuration&lt;/span&gt;&lt;br /&gt;There is a good chance the jail is somewhat useless at this point, as network settings and other pieces are missing. Time to use the console.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo ezjail-admin console builder&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above command results in a root account on the named jail. Fix the network, add a user, and install a few packages. The values below should be changed to match your environment.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# echo "nameserver 10.10.10.1" &amp;gt;&amp;gt; /etc/resolv.conf&lt;br /&gt;# pw useradd -n builder -g builder -s /bin/sh -m -d /home/builder -c 'builder account'&lt;br /&gt;# passwd builder&lt;br /&gt;# pkg_add -r sudo&lt;br /&gt;# sudoedit /usr/local/etc/sudoers&lt;br /&gt;# vi /etc/ssh/sshd_config&lt;br /&gt;# echo 'sshd_enable="YES"' &amp;gt;&amp;gt; /etc/rc.conf&lt;br /&gt;# exit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Quick explanation:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create resolv.conf and add our nameserver/router&lt;/li&gt;&lt;li&gt;Add user "builder" (-n builder)&lt;/li&gt;&lt;li&gt;Set builder's password&lt;/li&gt;&lt;li&gt;Install and then configur sudo&lt;/li&gt;&lt;li&gt;Edit &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sshd_config&lt;/span&gt; so "builder" can log in. Be sure to change ListenAddress (10.10.10.110 for this example)&lt;/li&gt;&lt;li&gt;Enable &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sshd&lt;/span&gt; in rc.conf&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Restart the jail and log in.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo ezjail-admin stop builder&lt;br /&gt;$ sudo ezjail-admin start builder&lt;br /&gt;$ ssh 10.10.10.110&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Create Packages&lt;/span&gt;&lt;br /&gt;The original goal for this jail was to be able to build packages for other jails. Here is a quick run-down of how.&lt;br /&gt;&lt;br /&gt;Logged in as "builder" to 10.10.10.110 jail:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ cd /usr/ports/benchmarks/bonnie&lt;br /&gt;$ sudo make install&lt;br /&gt;$ cd ~&lt;br /&gt;$ mkdir bonnie&lt;br /&gt;$ cd bonnie&lt;br /&gt;$ pkg_info | grep bonnie&lt;br /&gt;$ pkg_create -b bonnie-2.0.6_1&lt;br /&gt;$ ls&lt;br /&gt;bonnie-2.0.6_1.tbz&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now to copy this out of the jail and into another. This can either be done by file transfer between jails (scp, ftp, etc) or from the host as shown below.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo cp /usr/jails/builder/home/builder/bonnie/bonnie-2.0.6_1.tbz /usr/jails/jail2/tmp/&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And now load it in the other jail.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ sudo pkg_add /tmp/bonnie-2.0.6_1.tbz&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7980922255211744664-8332562707837187027?l=thecolinblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/8332562707837187027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/first-freebsd-jail.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/8332562707837187027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/8332562707837187027'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/first-freebsd-jail.html' title='First FreeBSD Jail'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7980922255211744664.post-7182365564198923165</id><published>2011-11-15T18:33:00.000-08:00</published><updated>2011-11-15T21:10:55.340-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jails'/><category scheme='http://www.blogger.com/atom/ns#' term='freebsd'/><title type='text'>FreeBSD Jail Host Set-up</title><content type='html'>This post summarizes what steps were taken to configure and prepare a host system for &lt;a href="http://www.freebsd.org/doc/handbook/jails.html" target="_blank"&gt;FreeBSD jails&lt;/a&gt;. This is not perfect, I am not a FreeBSD professional, so please be careful if you choose to follow any of these steps.&lt;br /&gt;&lt;br /&gt;This is for FreeBSD 8.2-STABLE and assumes a system already installed and running.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Install Sources&lt;/span&gt;&lt;br /&gt;Using the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sysinstall&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt;tool, install all sources: &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Configure &amp;gt; Distributions &amp;gt; Src &amp;gt; All&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;This will place the sources needed to compile a custom kernel into the &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/src/&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; directory.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Custom Kernel&lt;/span&gt;&lt;br /&gt;Now to customize, build, and install a new kernel. For the purposes below, the hostname "COEUS" will be used - replace this with whatever hostname is correct for your machine.&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;The FreeBSD Handbook provides a great page on&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.freebsd.org/doc/handbook/kernelconfig-building.html" style="font-family: inherit;" target="_blank"&gt;how to compile a custom kernel&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# cd /usr/src/sys/`uname -p`/conf&lt;br /&gt;# cp GENERIC COEUS&lt;br /&gt;# vi COEUS&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The &lt;a href="http://www.freebsd.org/doc/handbook/kernelconfig-config.html" target="_blank"&gt;Configuration File&lt;/a&gt; is explained in detail in the FreeBSD Handbook. The &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;ident GENERIC&lt;/span&gt; line should be changed to &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;ident COEUS&lt;/span&gt; and superfluous devices should be commented out. It is also advisable to remove all &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;options NFS*&lt;/span&gt; unless required.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Build And Install The Kernel&lt;/span&gt;&lt;br /&gt;Building the kernel is pretty straight forward. Remember the name of your file (COEUS in this example).&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# cd /usr/src&lt;br /&gt;# make -j`sysctl -n hw.ncpu` buildkernel KERNCONF=COEUS&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If no errors were displayed, then it should be safe to install the kernel and then reboot:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# make installkernel KERNCONF=COEUS&lt;br /&gt;# shutdown -r now&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Upon reboot, check whether things were successful.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;$ uname -a&lt;br /&gt;FreeBSD coeus.local 8.2-RELEASE FreeBSD 8.2-RELEASE #4: Tue Nov 15 00:11:11 PST 2011     root@coeus.local:/usr/obj/usr/src/sys/COEUS  amd64&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Install Packages&lt;/span&gt;&lt;br /&gt;The next step is to install some packages. This portion assumes you have a working connection.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:text"&gt;# pkg_add -r sudo&lt;br /&gt;# pkg_add -r ezjail&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It is recommended to configure and use &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;a href="http://www.sudo.ws/sudo/sudo.man.html" target="_blank"&gt;sudo&lt;/a&gt;&lt;/span&gt; over always-on root. The remaining steps assume this has been setup correctly and a normal user has been logged in.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Jail Considerations&lt;/span&gt;&lt;br /&gt;There is some prepwork to be done in order to get jails setup correctly. First, each jail will need an IP address. Will they be in order? Is a block of address already set aside? How are jails expected to be named? A general strategy now will help out later.&lt;br /&gt;&lt;br /&gt;Once the answer to jail names, IP address, and how many have been answered, continue on.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Configuring /etc/rc.conf&lt;/span&gt;&lt;br /&gt;Below is a working /etc/rc.conf and some comments. Your file may include a lot more than the example below. Use your best judgement.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:bash"&gt;# Enable network daemons for user convenience.&lt;br /&gt;# Please make all changes to this file, not to /etc/defaults/rc.conf.&lt;br /&gt;# This file now contains just the overrides from /etc/defaults/rc.conf.&lt;br /&gt;#&lt;br /&gt;hostname="coeus.local"          # set hostname&lt;br /&gt;#&lt;br /&gt;# syslogd should not list on any IP address&lt;br /&gt;# this allows syslogd in jails&lt;br /&gt;syslogd_flags="-ss"             # additional flags for syslogd&lt;br /&gt;#&lt;br /&gt;# some services:&lt;br /&gt;sshd_enable="YES"               # enable sshd&lt;br /&gt;sendmail_enable="NO"            # disable sendmail&lt;br /&gt;#&lt;br /&gt;# ifconfig&lt;br /&gt;ifconfig_em0="inet 192.168.1.180 netmask 255.255.255.0"&lt;br /&gt;defaultrouter="192.168.1.1"&lt;br /&gt;#&lt;br /&gt;# jail aliases&lt;br /&gt;ifconfig_em0_alias0="192.168.1.181 netmask 255.255.255.255"&lt;br /&gt;ifconfig_em0_alias1="192.168.1.190 netmask 255.255.255.255"&lt;br /&gt;ifconfig_em0_alias2="192.168.1.191 netmask 255.255.255.255"&lt;br /&gt;ifconfig_em0_alias3="192.168.1.192 netmask 255.255.255.255"&lt;br /&gt;ifconfig_em0_alias4="192.168.1.193 netmask 255.255.255.255"&lt;br /&gt;ifconfig_em0_alias5="192.168.1.194 netmask 255.255.255.255"&lt;br /&gt;#&lt;br /&gt;# jails&lt;br /&gt;jail_enable="YES"               # enable jails&lt;br /&gt;jail_set_hostname_allow="NO"    # disable hostname changes in jails&lt;br /&gt;jail_sysvipc_allow="YES"        # needed for postgresql&lt;br /&gt;#&lt;br /&gt;# ezjail GO!&lt;br /&gt;ezjail_enable="YES"             # enable ezjails&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Quick breakdown:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;syslogd_flags&lt;/span&gt; will stop syslogd from listening on all IPs.&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sshd_enable&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sendmail_enable&lt;/span&gt; control those services and how I want them on startup.&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ifconfig_em0&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;defaultrouter&lt;/span&gt; set network settings for the host&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ifconfig_em0_alias1&lt;/span&gt; .. &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;5&lt;/span&gt; are the IP address for the jails. Note the netmask of all 255's.&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;jail_enable&lt;/span&gt; enables jails&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ezjail_enable&lt;/span&gt; allows ezjail to be used&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Reboot.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7980922255211744664-7182365564198923165?l=thecolinblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thecolinblog.blogspot.com/feeds/7182365564198923165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/jail-host-set-up.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/7182365564198923165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7980922255211744664/posts/default/7182365564198923165'/><link rel='alternate' type='text/html' href='http://thecolinblog.blogspot.com/2011/11/jail-host-set-up.html' title='FreeBSD Jail Host Set-up'/><author><name>Colin</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
