Set Static IP Address in FreeBSD

Before you begin, find out what is the interface name using the ifconfig command.

$ ifconfig -a
em0: flags=8843 metric 0 mtu 1500 options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
ether 7a:98:a6:53:cd:7a
hwaddr 7a:98:a6:53:cd:7a
inet netmask 0xffffff00 broadcast
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
lo0: flags=8049 metric 0 mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
inet netmask 0xff000000
groups: lo

In this case the interface name is em0.

a. set temporary static IP (until next reboot)

# set temporary IP address to
$ ipconfig em0 inet

b. set permanent static IP address (persistent across reboots)

Static IP configuration must be included in /etc/rc.conf. Edit rc.conf using your favorite editor.

Delete or comment out the following line


Add the following lines after hostname directive:

ifconfig_em0="inet netmask"

Restart network interface service

$ sudo service netif restart 


Be aware that this method of setting a static IP address in rc.conf will disable the DHCP server. If you have custom DNS servers defined in /etc/dhclient.conf, they will not work. In this case, the custom DNS servers must be added in the /etc/resolv.conf file.

Leave a Reply