How to set hostname and static IP address on FreeBSD 12

So you are trying to learn how to set a host name and a static IP address on FreeBSD 12? In this guide, I will show you how easy hostnames and static IP addresses are on FreeBSD 12. Please note that FreeBSD network interface identifier uses driver name With one 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 permanent IP address on your FreeBSD 12 server, you must assign that IP address to an interface, and the IP configuration is included in it. /etc/rc.conf. Let us consider the following example:

  • Set server static hostname –
  • Set Interface IP Address –
  • Set the interface to

Setting the hostname on FreeBSD 12

Set the hostname on FreeBSD 12 using the following command:

$ su -
# hostname
# echo """" >>  /etc/rc.conf

in case dhclient Used to set the host name via DHCP, the host name variable should be set to an empty string

Setting a static IP address on FreeBSD 12

Now that the hostname is set, continue to configure a static IP address on FreeBSD 12.

# vi /etc/rc.conf


ifconfig_em0="inet netmask"

Restart FreeBSD network services and routing tables:

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

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