Kiriakos Naiskes software developer

Setting Up Static IP Address on FreeBSD

Tagged

Switching from dynamic DHCP to a static IP ensures your machine remains reachable at the exact same address after every reboot. A predictable IP simplifies SSH access, service hosting, and system management, which is why it is one of the first things I configure on my FreeBSD (and Linux) instances. In this guide, I will show you how to set it up.

Prerequisites

  • Root access.
  • Target IPv4 address, subnet mask, and default gateway details.

Identify the Active Network Interface

Look for the interface marked with status: active and an assigned IP address (e.g., em0, vtnet0, igb0, or re0):

ifconfig

Configure /etc/rc.conf

Edit /etc/rc.conf using a text editor. Replace ifconfig_em0"DHCP"= (or add the parameters if no entry exists) with your explicit network configurations so that it looks similar to the following:

hostname="typhon"
ifconfig_em0="inet 192.168.2.107 netmask 255.255.255.0"
ifconfig_em0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
moused_nondefault_enable="NO"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
defaultrouter="192.168.2.1"

Configure DNS Resolution

Add valid nameservers in /etc/resolv.conf, as DHCP will no longer auto-populate these entries.

For example:

nameserver 1.1.1.1
nameserver 8.8.8.8

Apply the Changes

You can apply your changes by rebooting your machine or, better yet, without restarting by running:

service netif restart && service routing restart

Date: 2026-08-17 Mon 23:10