Need help?

Our experts have had an average response time of 12.49 minutes in November 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to set Static IP and Hostname in FreeBSD 12

by | Nov 20, 2020

Don’t know how to set a Static IP address and hostname in FreeBSD 12? We can help you.

Today, we are going to see how our Support Engineers set hostname and static IP address on FreeBSD 12.


Set Static IP and Hostname in FreeBSD 12

Static IP and Hostname

Initially, we need to make sure that the IP address assigns to an interface and the IP configuration includes in /etc/rc.conf, to have a persistent IP address.

Please keep in mind that a FreeBSD network interface identifier uses the drive name followed by a number as shown below:

# ifconfig em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=81009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER> ether 08:00:27:12:6b:98 inet netmask 0xffffff00 broadcast media: Ethernet autoselect (1000baseT ) status: active nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 inet netmask 0xff000000 groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

For example:

  • Set Server static hostname –
  • Set interface IP Address –
  • Change gateway of interface to

Given below are the steps to follow:

  1. Configure network settings in FreeBSD
  2. Set hostname in FreeBSD 12
  3. Set Static IP address in FreeBSD 12
  4. Establish a DHCP Address

Let us now look into it in detail.

Configure network settings in FreeBSD

Network configurations for FreeBSD are stored in the system configuration file.

The path to this file is /etc/rc.conf, this is where the server’s host name as well as network interface configurations are set.

Given below is an example for the rc.conf file used by FreeBSD:

ifconfig_em0_ipv6=”inet6 accept_rtadv”
# Set dumpdev to “AUTO” to enable crash dumps, “NO” to disable
  • The hostname value sets the host name of the FreeBSD server
  • ifconfig_em0 value sets the network configurations for the em0 network interface
  • ifconfig_em0_ipv6 value is the IPv6 equvelant of the ifconfig_em0 value
  • sshd_enable sees whether the SSH daemon is enabled or not.


Set Hostname on FreeBSD 12

$ su –
# hostname
# echo “\”\”” >> /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

Once we set the hostname, proceed to configure a Static IP address on FreeBSD 12:

# vi /etc/rc.conf


ifconfig_em0=”inet netmask″

Later, restart FreeBSD network service and routing table:

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

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



Setting a DHCP Address

DHCP address for a network interface on a FreeBSD host is set by editing the system configuration file /etc/rc.conf.

For instance, to set the network interface em0 to DHCP:

  • Open the system configuration file into a text editor
vi /etc/rc.conf
  • Update the network interface to use DHCP. In our example, the interface will be em0
  • Save the changes and exit the text editor.

Meanwhile, apply new network configurations:


Similarly, the system configuration file must resemble with the ifconfig_ interface where we have updated the “DHCP” value.

For instance:

ifconfig_em0_ipv6=”inet6 accept_rtadv”
# Set dumpdev to “AUTO” to enable crash dumps, “NO” to disable

Furthermore, to verify if the changes are done successfully use the command:

ifconfig em0

[Need further assistance? We are here for you!]



To conclude, today, we saw how our Support Engineers configure network settings in FreeBSD by setting static IP addresses and DHCP addresses.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *