(Last Updated On: December 15, 2018)

So you’re trying to learn how to set a hostname & static IP address on FreeBSD 12?. In this guide I’ll show you how easy it is to a hostname and a Static IP address on FreeBSD 12.  Please note that the FreeBSD network interface identifier uses the driver name followed by a number.

# ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 08:00:27:12:6b:98
	inet netmask 0xffffff00 broadcast 
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
	inet netmask 0xff000000 
	groups: lo 

To have a persistent IP address on your FreeBSD 12 server, the IP address must be assigned to an interface and the IP configuration included in /etc/rc.conf. Let’s consider an example below:

  • Set Server static hostname – freebsd.example.com
  • Set interface IP Address –
  • Set gateway for interface to

Set Hostname on FreeBSD 12

Set a hostname on FreeBSD 12 using the commands below:

$ su -
# hostname freebsd.example.com
# echo "\"hostname=freebsd.example.com\"" >>  /etc/rc.conf

If the dhclient is used to set the hostname via DHCP, the hostname variable should be set to an empty string

Set Static IP Address on FreeBSD 12

Now that you have the hostname set, proceed to configure a Static IP address on FreeBSD 12.

# vi /etc/rc.conf


ifconfig_em0="inet netmask"

Restart FreeBSD network service and routing table:

# /etc/rc.d/netif restart && /etc/rc.d/routing restart

To configure an interface for DHCP, reset the settings to: