Configure the network

From PacBSD Wiki
Jump to: navigation, search

Related articles

The page explains how to configure a network connection, using both the freebsd-init and OpenRC init systems.

File:Tango-document-new.png This article is a stub.
Notes: This is the the start of this document, please feel free to help expand on it. (Discuss)

Check the connection

The basic installation procedure typically has a function network configuration. Use ping to check the connection:

$ ping
PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=50 time=17.0 ms

If the ping is successful (you see 64 bytes messages as above), then the network is configured. Press Control-C to stop the ping.

If the ping failed with an Unknown hosts error, it means that your machine was unable to resolve this domain name. It may be related to your service provider or your router/gateway. Try pinging a static IP address to prove that your machine has access to the Internet:

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=53 time=52.9 ms

If you are able to ping but not, check your DNS configuration. See resolv.conf for details. The hosts line in /etc/nsswitch.conf is another place you can check.

If not, check for cable issues before diagnosing further.

  • If you receive an error like ping: icmp open socket: Operation not permitted when executing ping, try to re-install the iputils package.
  • The -c num option can be used to make exactly num pings, otherwise it pings infinitely and has to be terminated manually. See man ping for more information.
  • is a static address that is easy to remember. It is the address of Google's primary DNS server, therefore it can be considered reliable, and is generally not blocked by content filtering systems and proxies.

Set the hostname

A hostname is a unique name created to identify a machine on a network.

Set hostname with freebsd-init

To set the system's hostname while using freebsd-init run

sysrc hostname="hostname"

Set hostname with OpenRC

To set the systems's hostname while using OpenRC run

echo 'HOSTNAME="hostname"' > /etc/conf.d/hostname

Configure the Network Interface

Check the status

First, determine the model of the NIC and the chip it uses. PacBSD supports the same NICs that FreeBSD does, check FreeBSD's Hardware Compatibility list to see if the NIC is supported.

An easy way to see the model of the NIC is by running lspci:

# lspci -v 
03:0e.0 Ethernet controller: Intel Corporation 82545GM Gigabit Ethernet Controller (rev 04)
	Subsystem: Dell Device 0173
	Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 48
	Memory at dfee0000 (64-bit, non-prefetchable)
	I/O ports at dcc0
	Capabilities: [dc] Power Management version 2
	Capabilities: [e4] PCI-X non-bridge device
	Capabilities: [f0] MSI: Enable- Count=1/1 Maskable- 64bit+

If the NIC is supported, determine the name of the driver for the NIC. The drivers for common NICs are already present in the GENERIC kernel, meaning the NIC should be probed during boot. The system's boot messages can be viewed with less /var/log/dmesg and using the spacebar to scroll through the text. An easy way to see which driver is loaded, copy the memory address from the lspci and use a tool like grep to search the file.

$ grep dfee0000 /var/log/dmesg
em0: <Intel(R) PRO/1000 Legacy Network Connection 1.1.0> port 0xdcc0-0xdcff mem 0xdfee0000-0xdfefffff irq 48 at device 14.0 on pci3

In this example we can see that the em(4) driver is loaded for this NIC.

Another way to work out the driver for the NIC is with ifconfig:

$ ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 00:11:43:15:b1:a1
	inet6 fe80::211:43ff:fe15:b1a1%em0 prefixlen 64 scopeid 0x1 
	inet netmask 0xffffff00 broadcast 
	nd6 options=1<PERFORMNUD>
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
	inet netmask 0xff000000 
	groups: lo

Note: As you may be able to tell NICs are identified by the loaded driver. If a system has two NICs supported by the same driver those NICs will appear as em0 and em1

If for some reason the NIC in question is supported, but the driver isn't automatically loaded, this can be done with kldload(8). This can be done as a one time thing, running in a terminal as root, or added to /boot/loader.conf so it will be loaded at boot automatically:

kldload em


Note: This section of the guide assumes the network interface being configured is em0, be sure to change this to the correct name of your NIC.



To have the system configure the interface with DHCP on boot, add the following line to /etc/rc.conf:


This will run the DHCP client in the background allowing the rest of the boot process to continue while waiting for a response from the DHCP server. Because this runs asynchronously (not blocking) this could cause other services that require network, such as mounting a network share, to fail. If this happens the DHCP client can be set to run synchronously (blocking), this way the boot process will pause while waiting for a response from the DHCP server. To set this add the following line to /etc/rc.conf

Warning: Only set one of the above options, in most cases users will want to go the asynchronous route and only go the synchronous route if they have issues with other services

By default OpenRC is configured to use DHCP by default, to get it to work an init script for the network interface needs to be created due to the way PacBSD names its interfaces. The easiest way to do this is by copying, or symlinking, /etc/init.d/net.lo0 to /etc/init.d/net.<interface>.

# ln -s /etc/init.d/net.lo0 /etc/init.d/net.em0

Then tell OpenRC to start this at boot, and start it immediately with:

# rc-update add net.em0 default
# rc-service net.em0 start



File:Tango-document-new.png This article is a stub.
Notes: This section needs filled out by someone with more experience with wireless under PacBSD. (Discuss)

See Also