Add Loopback Network Interface with Alias on FreeBSD


Note that this page will be part of a documentation about setting up a server using FreeBSD with similar features to the existing server documentation. Also note that this page is still work in progress

To use EzJail on a FreeBSD host, e. g. to sandbox different services, you need to add a loopback network interface and add some aliases to it. Jails networking seems to require a dedicated network and loopback aliases can not run on the external interface. Follow the next paragraphs to add one loopback interface including three aliases.
First, create the loopback interface in rc.conf:


Then, add some aliases to the loopback interface in rc.conf:

ifconfig_lo1_alias0="inet netmask"
ifconfig_lo1_alias1="inet netmask"
ifconfig_lo1_alias1="inet netmask"

If you happen to add an alias to an already running server, you might want to avoid rebooting and therefore also invoke the following command to add the alias while keeping the system running:

ifconfig lo1 alias netmask 

That’s it.