FreeBSD

Installation

The FreeBSD image can be downloaded directly from their website at freebsd.org. A description for each image type is listed on the page.

Verify Your Download

Once downloaded, we need to verify that it’s not corrupted and that it actually came from the FreeBSD developers. These can both be found through in a signed checksums file that’s referenced in the download page.

Below is the checksum file for the FreeBSD 15.1 release. The first half contains the SHA256 sums for each image file. While the second half is the signed cryptographic signature of the file that we need to verify the origin.

By confirming the checksums came from the developers, we can use them to deduce if the image file also did.

CHECKSUM.SHA256-FreeBSD-15.1-RELEASE-amd64.asc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

SHA256 (FreeBSD-15.1-RELEASE-amd64-bootonly.iso) = 3e74120a59512cefc35840443bdd05087c8a010a27cf8a6fbb4f7450824f092e
SHA256 (FreeBSD-15.1-RELEASE-amd64-bootonly.iso.xz) = 807b31dc257f8c1b3979cb48f875bc9e198f615ea1dbf5a5ab3a0fefc2115d5f
SHA256 (FreeBSD-15.1-RELEASE-amd64-disc1.iso) = fa27646f05a1440fd26ffbb85e06a50bc86e128242a4e9cb7bb3ea76e1aa5fd9
SHA256 (FreeBSD-15.1-RELEASE-amd64-disc1.iso.xz) = 7983bc92cf0e2098df8769c36ae471b235552ebe99733e0673fe7ad85c2e9950
SHA256 (FreeBSD-15.1-RELEASE-amd64-dvd1.iso) = 027504262c65e096d78bd345d74905a8a7216bbb3c6155d55634ae8328f76c5d
SHA256 (FreeBSD-15.1-RELEASE-amd64-dvd1.iso.xz) = 1aa52e114672753acd6734b588b586350c384fd720355bba679dafa5ce0c19f0
SHA256 (FreeBSD-15.1-RELEASE-amd64-memstick.img) = 26c6d5de1156e7a99df920d047578b504c4899865d91b1156b1de1a0c5239eae
SHA256 (FreeBSD-15.1-RELEASE-amd64-memstick.img.xz) = ab63c91cd501cedfa7a28020464f2991123ea599c061ca9080c4e453cb0a8e76
SHA256 (FreeBSD-15.1-RELEASE-amd64-mini-memstick.img) = 61c4a454eb799bc92fcef375d434c0d48721951c598e4cb91b5aa8faa30d7a40
SHA256 (FreeBSD-15.1-RELEASE-amd64-mini-memstick.img.xz) = 25602a32253ed7cbbb50007d43c48e2f4342b92985465a79d8808a2156179b3f
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEglY7hNBiDtwN+4ZBOJfy4i5lrT8FAmotfnUACgkQOJfy4i5l
rT+nzhAAl7ADU3kRw7r2UgjXzkcEdlRAr7hkYttzal8fLwzlxJZ9lLY94w8ZllGO
0/u/iuAS14SNtq+T9GO2Mo+pfVAhUCZnW4/6ql82K8fWlMjMUSeqUNBvX9bjtsXR
4iTuimEaWXMz/aFDkc6VP+OAYwLvqVMPRr3xrYHu5QWt225EvdeueidGiEYtlZvl
xYSejg9Ug5b3MODEteoj5qAlhj61aDIdZqrc9SNaLnmtcc0tA1pQ1FQmIkZI3Gbh
JMi+riMIgR7Rp7FVqnq4e0RucbCTw2NwXG5kem+nAbsUdumz8IuR7yp1Mpp4DaDE
YRncMQKEQarGExZFePMmchVfBVsLSSp4Y3H7Px5DpY9yf2x3o3pbENF2EWqgVSqH
Li6hZDj7fsdUMi54F+FaQVrV4E9SfAvl2LHsKoANTTRE62ZzhnsA+undREmdTT8t
K4hneKOCnjLugpqama1UweiGTYZs7nkVA7zjRqhFztHaWtJ4BehlmzzmW3aIiBMI
bHiqlZm40D81dcm9ZOX7T7T0JmKdMhB7YWqHJd0Sl3A2zrCgMlwQcNzrRTkSi9Dv
EyEv5IOH8HEzK2dHqtXuTxcSUBI8DC4Y2I8JBvTRg7NxwcndOL45zvEaDF9qDuqz
upkJacb704adRqiglSCqfsrZWWwLeNwMRAzV+c/isKHFOzh6Ts0=
=tcc7
-----END PGP SIGNATURE-----

With the image and checksum files downloaded, all we’re missing are the actual developer signatures to compare against. A text file with all the signatures can be found at docs.freebsd.org/en/articles/pgpkeys.

Now we can verify!

sh

# Import trusted signatures from FreeBSD
gpg --import ./pgpkeys.txt

# Verify the checksums are official
# Remember to ensure the key fingerprint is listed on the pgpkeys page!
gpg --verify CHECKSUM.SHA256-FreeBSD-15.1-RELEASE-amd64.asc

# See if one of the verified checksums match the image file.
sha256sum FreeBSD-15.1-RELEASE-amd64-disc1.iso | grep -f ./CHECKSUM.SHA256-FreeBSD-15.1-RELEASE-amd64.asc

Install On A Computer

From here it’s better to follow the official documentation

Post-Install Configuration

Firewall

sh

# Enable both service on boot
sysrc pf_enable=yes # appends pf_enable="yes" to /etc/rc.conf
sysrc pflog_enable=yes # a pf logging service

# Start both services
service pf onestart
service pflog onestart

# Add firewall rules
cat > /etc/pf.conf << 'EOF'
#~~~~~~~~~~~~~~ Macros
ext_if="igc0"
vpn_if="tailscale0"
set skip on {tailscale0, lo0} # Ignore filtering on these devices (lo0 is localhost)

# Remove any TCP/IP packets too small to be valid. (prevents some connectivity problems)
scrub in

block in # block all incoming traffic
pass out # all traffic is allowed to go out

# Allowed incoming TCP ports
pass in on $ext_if proto tcp from any to ($ext_if) port {22, 53, 80, 443}
# Allowed incoming UDP ports
pass in on $ext_if proto udp to ($ext_if) port 53

pass in on $ext_if inet proto icmp to ($ext_if) icmp-type { unreach, redir, timex, echoreq }
EOF

# Test firewall rules
pfctl -nf /etc/pf.conf  

# Apply firewall rules
pfctl -f /etc/pf.conf  

Jails

sh

# Start jails on boot
sysrc jail_enable=YES

# Jails start from everything listed in /etc/jails.conf
# but you can override that behavior 
sysrc jail_list="mariadb httpd"

# Jails are stopped in the order they're started
# but you have the option to reverse it
sycsrc jail_reverse_stop=YES

# If startup order isn't important
sysrc jail_parallel_start="YES"


# Create a Jail directory tree
zfs create -o mountpoint=/jail zroot/jail
zfs create zroot/jail/media # contains the compressed files of the downloaded userlands.
zfs create zroot/jail/templates # contains the templates when using Thin Jails.
zfs create zroot/jail/containers # contains the jails.

## Creating a jail called "classic" ##
mkdir /jail/containers/classic
# chflags -R 0 ./classic && rm -r ./classic # if you ever need to delete this folder and a permission issue stops you.

# traditional option 1: Download userland the jail will use. Should never be above host version.
fetch https://download.freebsd.org/releases/amd64/amd64/15.1-RELEASE/base.txz -o /jail/media/15.1-RELEASE-base.txz
tar -xf ./15.1-RELEASE-base.txz -C /jail/containers/classic

# traditional option 2: you use bsdinstall.
bsdinstall jail /jail/containers/classic

# new option 3: you install userland from the pkg repository
# NOTE: This uses pkg instead of freebsd-update
pkg --rootdir /jail/containers/classic install -r FreeBSD-base FreeBSD-set-base-jail

# Copy over host timezone and dns files
cp /etc/resolv.conf /jail/containers/classic/etc/resolv.conf
cp /etc/localtime /jail/containers/classic/etc/localtime

# Update jail to latest patch
# - traditional
freebsd-update --currently-running 15.1 -b /jail/containers/classic/ fetch install
# - new
pkg -r /jail/containers/pkgjail update
pkg -r /jail/containers/pkgjail upgrade


# Create the jail configuration:
cat > /etc/jail.conf.d/classic.conf << 'EOF'
classic {
  # STARTUP/LOGGING
  exec.start = "/bin/sh /etc/rc";
  exec.stop = "/bin/sh /etc/rc.shutdown";
  exec.consolelog = "/var/log/jail_console_${name}.log";

  # PERMISSIONS
  allow.raw_sockets;
  exec.clean;
  mount.devfs;

  # HOSTNAME/PATH
  host.hostname = "${name}";
  path = "/jail/containers/${name}";

  # NETWORK
  # ip4.addr = 192.168.1.151;
  interface = igc0;
}
EOF