Configuring Network on FreeBSD

Home / Configuring Network on FreeBSD

Configuring Network on FreeBSD

December 5, 2015 | Uncategorized | No Comments

Network is an important matter for system, especially for FreeBSD.

In this article we will discuss about how to configuring network on FreeBSD and learn some important notes of it.

For this I use FreeBSD 8.3 for amd64, although you can also use another version or architecture.

There are two method for configuring network, by using sysinstall and editing rc.conf.

Sysinstall Method

The easiest method for configuring network is using sysinstall, by invoking


A Graphical User Interface (text based though) will prompt you. You can do network configuration by choosing Configure menu for doing Post Installation.

Accessing rc.conf

Another method will be accessing rc.conf directly. This method require you to edit rc.conf manually. Later on this article, we will mostly cover things for rc.conf.

Setting IP

IP or Internet Protocol address is an address which tell where are us in the world of internet. There are two type of IP address we can assigned to our network card: static address or dynamic address.

If you want to set IP address statically, edit rc.conf and add this line:

ifconfig_em0="inet netmask"

In that example, we set our network card, which is recognized as em0, to have IP address with netmask / subnet The ethernet card recognized by your machine might be different, so you should find out what is the name of your ethernet card. A simple command to do so:

systat -ifstat

The default router, like the name, is used to tell our machine where is the router we must communicate.

If you want to set IP address dynamically using DHCP, edit rc.conf and add this line:


Setting Nameserver (DNS)

To set default DNS server used by our machine, edit /etc/resolv.conf and write this:


Our machine then use the provided to doing some query for name. In other word, using nameserver as stated above as default nameserver. Change to your need. A common DNS server used is Google DNS which located on

Setting Hostname

Hostname is the identifier for machine in the network. Normally it is formed by machine name and domain name. This example add line to rc.conf and set hostname to


IP Address Aliasing

IP Address Aliasing means a single network card can have more than 1 IP address. For example this will gives your ethernet card 3 IP address:

ifconfig_em0="inet netmask"
ifconfig_em0_alias0="inet netmask"
ifconfig_em0_alias1="inet netmask"

Multiple Network Cards in One Machine

Having multiple network cards in one machine is not a problem. Just configuring them both in rc.conf as you would normally, but with only one default router line. The hostname line for each needs to follow directly after the card is declared. For example:

ifconfig_em0="inet netmask"
ifconfig_em1="inet netmask"

Multiple netword cards on different networks

Having multiple cards in one machine on the same network is a simple matter, but setting the cards to seperate networks is another matter. They are both setup normally as above with the IPs declared statically, and the defaultrouter set to the network you want the machine to use for everything that isn’t specifically set to go out on the other card.

To see what router is set to default use the command

netstat -r

The first router on the list is the default router. Since FreeBSD sometimes changes the route if there is a problem it works best to create a start up script to set the route you want traffic to default to

route change default >> /dev/null
echo "DefRouteChange"

Getting this all to work can be tricky, and sometimes depends on the order the network cards are listed rc.conf, but it can be done.

Sending the hostname to the DHCP server

On many DSL modems and routers the hostname will not show up for FreeBSD machines when they are set to DHCP. To fix this you can add the following lines to /etc/dhclient.conf and replace the network card and hostname with your own

interface "em0" {
   send host-name "freebsd"

About Author

about author


A man who is obsessed to low level technology.

Leave a Reply

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

Social Share Buttons and Icons powered by Ultimatelysocial