FreeBSD, for better or worse, initializes through a series of scripts in the /etc/rc.d folder. The various flags and settings are set with a single file: /etc/rc.conf. However, there is another option!

You can also create a folder called /etc/rc.conf.d/ (third paragraph) and put discrete files named after their respective /etc/rc.d scripts. For example, to enable sshd, create /etc/rc.conf.d/sshd which contains:

sshd_enable=“YES”

The name of the file matches the startup script, /etc/rc.d/sshd, so it’s nice and obvious.

When I learned about this option, I began using that folder for all of my startup configuration files. I was left with a small /etc/rc.conf file that contained the hostname of the machine, default router, IP address allocation and (if necessary) the flag to enable routing between network interfaces. I knew that these variables could also be placed into discrete files, but it was not readily apparent to me what those files should be named. This setup makes automating system configurations with a system like Puppet or Chef much easier.

After some trial and error this afternoon, I’ve finally figured out the correct files for those last settings, which eliminates the need for the original rc.conf file.

## /etc/rc.conf.d/hostname

hostname=“YOUR HOSTNAME”

## /etc/rc.conf.d/network

ifconfig_<interface>_aliases=“inet 0.0.0.0/24”

## /etc/rc.conf.d/routing

gateway_enable=“YES”

defaultrouter=“IP of default gateway/router”

It took awhile to find these. Google and grepping through the startup scripts only helped to narrow things down a little, so I’ve put this up to help anyone else that might be searching for these answers.