Set a system's TCP/IP settings

Author: Alex Nikiforov FreeBSD

Reviewer: name contact BSD flavour

Reviewer: Yannick Cadin FreeBSD/OpenBSD

Reviewer: jdq OpenBSD


Be able to modify required TCP/IP settings both temporarily and permanently in order to remain after a reboot.


This chapter one of the most important because you as network administrator must know how to convert your hardware into real server. In this part you know how to set network settings in BSD box.


You can update IP on the fly manually and via DHCP server. You must be a root user for change IP and other network settings.

TODO: briefly mention DHCP and refer to section View and renew a DHCP lease. TODO: maybe move some of this to there?

""# dhclient fxp0 ""DHCPREQUEST on fxp0 to port 67 ""DHCPACK from ""bound to -- renewal in 302400 seconds.

Now we update our fxp0 interface IP via DHCP server. You may override default dhclient options in /etc/dhclient.conf. In environments where a static IP or DHCP is not available, you must manually configure a network interface:

""# ifconfig fxp0 netmask

And check the status of this interface:

""# ifconfig fxp0 ""fxp0: flags=8843 mtu 1500 "" options=8 "" inet netmask 0xffffff00 broadcast "" ether 00:09:6b:13:42:9f "" media: Ethernet autoselect (100baseTX ) "" status: active

The -a switch may be used to check the status of all interfaces.

You may save these settings on xBSD, yBSD and FreeBSD by adding an entry to /etc/rc.conf:

""ifconfig_rl1="inet netmask" ""ifconfig_rl0_alias1="inet netmask" ""ifconfig_rl0_alias0="inet netmask"

For OpenBSD, create an /etc/hostname.rl0 for the rl0 interface in OpenBSD:

"" netmask up"" ""inet alias"" ""inet alias""

To configure xBSD, yBSD, and FreeBSD to use dhcp on startup:


And in OpenBSD, simply use the following entry in /etc/hostname.if:


To bring up an interface according to the configuration files, use netstart:

""# sh /etc/netstart rl0

DHCP servers often provide a default route. If dhcp is not in use, or a default route is not provided by the DHCP server, you must configure one manually. In xBSD, yBSD and FreeBSD, add:


to rc.conf. Similarly, in OpenBSD, add an entry to /etc/mygate:

""echo > /etc/mygate

you may check the routing table by using

""# route -n show

The -n option discarding name resolution preventing long delays. You may add a default entry by keying in:

""# route add default

For update DNS servers list you must update your resolv.conf file. This is typical file

""# cat /etc/resolv.conf ""nameserver ""nameserver

TODO: don't cover DNS too much here.

For more information about DNS, see section Change the order of name resolution and ...TODO.

Firstly system try to resolve address with and then with (truly firstly with hosts file)

Practice Exercises

  1. Try to change your IP address
  2. Create alias for network interface
  3. Add DNS server.

More information

hostname (1), ifconfig(8), route(8), resolv.conf(5), rc.conf(5), hosts(5), hostname.if(5), myname(5), mygate(5), netstart(8)