Set hostname & Static IP address on FreeBSD 12/13

Posted on 3 views

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

# ifconfig
em0: flags=8843 metric 0 mtu 1500
	ether 08:00:27:12:6b:98
	inet netmask 0xffffff00 broadcast 
	media: Ethernet autoselect (1000baseT )
	status: active
	nd6 options=29
lo0: flags=8049 metric 0 mtu 16384
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
	inet netmask 0xff000000 
	groups: lo 
	nd6 options=21

To have a persistent IP address on your FreeBSD 12/13 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 –
  • Set interface IP Address –
  • Set gateway for interface to

Set Hostname on FreeBSD 12 / FreeBSD 13

Set a hostname on FreeBSD 12/13 using the commands below:

$ sudo hostname
$ sudo vim /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 / FreeBSD 13

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

sudo vim /etc/rc.conf


ifconfig_em0="inet netmask"

Restart FreeBSD network service and routing table:

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

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


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.