Index: head/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.xml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.xml (revision 46060)
+++ head/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.xml (revision 46061)
@@ -1,5217 +1,5217 @@
Advanced NetworkingSynopsisThis chapter covers a number of advanced networking
topics.After reading this chapter, you will know:The basics of gateways and routes.How to set up USB tethering.How to set up &ieee; 802.11 and &bluetooth;
devices.How to make &os; act as a bridge.How to set up network PXE
booting.How to set up IPv6 on a &os;
machine.How to enable and utilize the features of the Common
Address Redundancy Protocol (CARP) in
&os;.Before reading this chapter, you should:Understand the basics of the
/etc/rc scripts.Be familiar with basic network terminology.Know how to configure and install a new &os; kernel
().Know how to install additional third-party software
().Gateways and RoutesCoranthGryphonContributed by routinggatewaysubnetRouting is the mechanism that allows
a system to find the network path to another system. A
route is a defined pair of addresses
which represent the destination and a
gateway. The route indicates that when trying
to get to the specified destination, send the packets through
the specified gateway. There are three types of destinations:
individual hosts, subnets, and default. The
default route is used if no other routes apply.
There are also three types of gateways: individual hosts,
interfaces, also called links, and Ethernet hardware
(MAC) addresses. Known routes are stored in
a routing table.This section provides an overview of routing basics. It
then demonstrates how to configure a &os; system as a router and
offers some troubleshooting tips.Routing BasicsTo view the routing table of a &os; system, use
&man.netstat.1;:&prompt.user; netstat -r
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default outside-gw UGS 37 418 em0
localhost localhost UH 0 181 lo0
test0 0:e0:b5:36:cf:4f UHLW 5 63288 re0 77
10.20.30.255 link#1 UHLW 1 2421
example.com link#1 UC 0 0
host1 0:e0:a8:37:8:1e UHLW 3 4601 lo0
host2 0:e0:a8:37:8:1e UHLW 0 5 lo0 =>
host2.example.com link#1 UC 0 0
224 link#1 UC 0 0The entries in this example are as follows:defaultThe first route in this table specifies the
default route. When the local system
needs to make a connection to a remote host, it checks
the routing table to determine if a known path exists.
If the remote host matches an entry in the table, the
system checks to see if it can connect using the
interface specified in that entry.If the destination does not match an entry, or if
all known paths fail, the system uses the entry for the
default route. For hosts on a local area network, the
Gateway field in the default route is
set to the system which has a direct connection to the
Internet. When reading this entry, verify that the
Flags column indicates that the
gateway is usable (UG).The default route for a machine which itself is
functioning as the gateway to the outside world will be
the gateway machine at the Internet Service Provider
(ISP).localhostThe second route is the localhost
route. The interface specified in the
Netif column for
localhost is
lo0, also known as the loopback
device. This indicates that all traffic for this
destination should be internal, rather than sending it
out over the network.MAC addressThe addresses beginning with 0:e0: are
MAC addresses. &os; will
automatically identify any hosts,
test0 in the example, on the
local Ethernet and add a route for that host over the
Ethernet interface, re0. This type
of route has a timeout, seen in the
Expire column, which is used if the
host does not respond in a specific amount of time.
When this happens, the route to this host will be
automatically deleted. These hosts are identified using
the Routing Information Protocol
(RIP), which calculates routes to
local hosts based upon a shortest path
determination.subnet&os; will automatically add subnet routes for the
local subnet. In this example, 10.20.30.255 is the
broadcast address for the subnet 10.20.30 and
example.com is the
domain name associated with that subnet. The
designation link#1 refers to the
first Ethernet card in the machine.Local network hosts and local subnets have their
routes automatically configured by a daemon called
&man.routed.8;. If it is not running, only routes which
are statically defined by the administrator will
exist.hostThe host1 line refers to the host
by its Ethernet address. Since it is the sending host,
&os; knows to use the loopback interface
(lo0) rather than the Ethernet
interface.The two host2 lines represent
aliases which were created using &man.ifconfig.8;. The
=> symbol after the
lo0 interface says that an alias
has been set in addition to the loopback address. Such
routes only show up on the host that supports the alias
and all other hosts on the local network will have a
link#1 line for such routes.224The final line (destination subnet 224) deals with
multicasting.Various attributes of each route can be seen in the
Flags column.
summarizes some of these flags and their meanings:
Commonly Seen Routing Table FlagsCommandPurposeUThe route is active (up).HThe route destination is a single host.GSend anything for this destination on to this
gateway, which will figure out from there where to
send it.SThis route was statically configured.CClones a new route based upon this route for
machines to connect to. This type of route is
normally used for local networks.WThe route was auto-configured based upon a local
area network (clone) route.LRoute involves references to Ethernet (link)
hardware.
On a &os; system, the default route can defined in
/etc/rc.conf by specifying the
IP address of the default gateway:defaultrouter="10.20.30.1"It is also possible to manually add the route using
route:&prompt.root; route add default 10.20.30.1Note that manually added routes will not survive a reboot.
For more information on manual manipulation of network
routing tables, refer to &man.route.8;.Configuring a Router with Static RoutesAlHoangContributed by dual homed hostsA &os; system can be configured as the default gateway, or
router, for a network if it is a dual-homed system. A
dual-homed system is a host which resides on at least two
different networks. Typically, each network is connected to a
separate network interface, though IP
aliasing can be used to bind multiple addresses, each on a
different subnet, to one physical interface.routerIn order for the system to forward packets between
interfaces, &os; must be configured as a router. Internet
standards and good engineering practice prevent the &os;
Project from enabling this feature by default, but it can be
configured to start at boot by adding this line to
/etc/rc.conf:gateway_enable="YES" # Set to YES if this host will be a gatewayTo enable routing now, set the &man.sysctl.8; variable
net.inet.ip.forwarding to
1. To stop routing, reset this variable to
0.BGPRIPOSPFThe routing table of a router needs additional routes so
it knows how to reach other networks. Routes can be either
added manually using static routes or routes can be
automatically learned using a routing protocol. Static routes
are appropriate for small networks and this section describes
how to add a static routing entry for a small network.For large networks, static routes quickly become
unscalable. &os; comes with the standard
BSD routing daemon &man.routed.8;, which
provides the routing protocols RIP,
versions 1 and 2, and IRDP. Support for
the BGP and OSPF
routing protocols can be installed using the
net/zebra package or port.Consider the following network:
INTERNET
| (10.0.0.1/24) Default Router to Internet
|
|Interface xl0
|10.0.0.10/24
+------+
| | RouterA
| | (FreeBSD gateway)
+------+
| Interface xl1
| 192.168.1.1/24
|
+--------------------------------+
Internal Net 1 | 192.168.1.2/24
|
+------+
| | RouterB
| |
+------+
| 192.168.2.1/24
|
Internal Net 2In this scenario, RouterA is a
&os; machine that is acting as a router to the rest of the
Internet. It has a default route set to 10.0.0.1 which allows it to
connect with the outside world.
RouterB is already configured to use
192.168.1.1 as its
default gateway.Before adding any static routes, the routing table on
RouterA looks like this:&prompt.user; netstat -nr
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 10.0.0.1 UGS 0 49378 xl0
127.0.0.1 127.0.0.1 UH 0 6 lo0
10.0.0.0/24 link#1 UC 0 0 xl0
192.168.1.0/24 link#2 UC 0 0 xl1With the current routing table,
RouterA does not have a route to the
192.168.2.0/24
network. The following command adds the Internal Net
2 network to RouterA's
routing table using 192.168.1.2 as the next
hop:&prompt.root; route add -net 192.168.2.0/24 192.168.1.2Now, RouterA can reach any host
on the 192.168.2.0/24 network.
However, the routing information will not persist if the &os;
system reboots. If a static route needs to be persistent, add
it to /etc/rc.conf:# Add Internal Net 2 as a persistent static route
static_routes="internalnet2"
route_internalnet2="-net 192.168.2.0/24 192.168.1.2"The static_routes configuration
variable is a list of strings separated by a space, where each
string references a route name. The variable
route_internalnet2
contains the static route for that route name.Using more than one string in
static_routes creates multiple static
routes. The following shows an example of adding static
routes for the 192.168.0.0/24 and
192.168.1.0/24
networks:static_routes="net1 net2"
route_net1="-net 192.168.0.0/24 192.168.0.1"
route_net2="-net 192.168.1.0/24 192.168.1.1"TroubleshootingWhen an address space is assigned to a network, the
service provider configures their routing tables so that all
traffic for the network will be sent to the link for the site.
But how do external sites know to send their packets to the
network's ISP?There is a system that keeps track of all assigned
address spaces and defines their point of connection to the
Internet backbone, or the main trunk lines that carry Internet
traffic across the country and around the world. Each
backbone machine has a copy of a master set of tables, which
direct traffic for a particular network to a specific
backbone carrier, and from there down the chain of service
providers until it reaches a particular network.It is the task of the service provider to advertise to
the backbone sites that they are the point of connection, and
thus the path inward, for a site. This is known as route
propagation.&man.traceroute.8;Sometimes, there is a problem with route propagation and
some sites are unable to connect. Perhaps the most useful
command for trying to figure out where routing is breaking
down is traceroute. It is useful when
ping fails.When using traceroute, include the
address of the remote host to connect to. The output will
show the gateway hosts along the path of the attempt,
eventually either reaching the target host, or terminating
because of a lack of connection. For more information, refer
to &man.traceroute.8;.Multicast Considerationsmulticast routingkernel optionsMROUTING&os; natively supports both multicast applications and
multicast routing. Multicast applications do not require any
special configuration in order to run on &os;. Support for
multicast routing requires that the following option be
compiled into a custom kernel:options MROUTINGThe multicast routing daemon,
mrouted can be installed using the
net/mrouted package or port. This daemon
implements the DVMRP multicast routing
protocol and is configured by editing
/usr/local/etc/mrouted.conf in order to
set up the tunnels and DVMRP. The
installation of mrouted also
installs map-mbone and
mrinfo, as well as their associated
man pages. Refer to these for configuration examples.DVMRP has largely been replaced by
the PIM protocol in many multicast
installations. Refer to &man.pim.4; for more
information.Wireless NetworkingLoaderMarcFonvieilleMurrayStokelywireless networking802.11wireless networkingWireless Networking BasicsMost wireless networks are based on the &ieee; 802.11
standards. A basic wireless network consists of multiple
stations communicating with radios that broadcast in either
the 2.4GHz or 5GHz band, though this varies according to the
locale and is also changing to enable communication in the
2.3GHz and 4.9GHz ranges.802.11 networks are organized in two ways. In
infrastructure mode, one station acts as
a
master with all the other stations associating to it, the
network is known as a BSS, and the master
station is termed an access point (AP).
In a BSS, all communication passes through
the AP; even when one station wants to
communicate with another wireless station, messages must go
through the AP. In the second form of
network, there is no master and stations communicate directly.
This form of network is termed an IBSS
and is commonly known as an ad-hoc
network.802.11 networks were first deployed in the 2.4GHz band
using protocols defined by the &ieee; 802.11 and 802.11b
standard. These specifications include the operating
frequencies and the MAC layer
characteristics, including framing and transmission rates,
as communication can occur at various rates. Later, the
802.11a standard defined operation in the 5GHz band, including
different signaling mechanisms and higher transmission rates.
Still later, the 802.11g standard defined the use of 802.11a
signaling and transmission mechanisms in the 2.4GHz band in
such a way as to be backwards compatible with 802.11b
networks.Separate from the underlying transmission techniques,
802.11 networks have a variety of security mechanisms. The
original 802.11 specifications defined a simple security
protocol called WEP. This protocol uses a
fixed pre-shared key and the RC4 cryptographic cipher to
encode data transmitted on a network. Stations must all
agree on the fixed key in order to communicate. This scheme
was shown to be easily broken and is now rarely used except
to discourage transient users from joining networks. Current
security practice is given by the &ieee; 802.11i specification
that defines new cryptographic ciphers and an additional
protocol to authenticate stations to an access point and
exchange keys for data communication. Cryptographic keys
are periodically refreshed and there are mechanisms for
detecting and countering intrusion attempts. Another
security protocol specification commonly used in wireless
networks is termed WPA, which was a
precursor to 802.11i. WPA specifies a
subset of the requirements found in 802.11i and is designed
for implementation on legacy hardware. Specifically,
WPA requires only the
TKIP cipher that is derived from the
original WEP cipher. 802.11i permits use
of TKIP but also requires support for a
stronger cipher, AES-CCM, for encrypting data. The
AES cipher was not required in
WPA because it was deemed too
computationally costly to be implemented on legacy
hardware.The other standard to be aware of is 802.11e. It defines
protocols for deploying multimedia applications, such as
streaming video and voice over IP (VoIP),
in an 802.11 network. Like 802.11i, 802.11e also has a
precursor specification termed WME (later
renamed WMM) that has been defined by an
industry group as a subset of 802.11e that can be deployed now
to enable multimedia applications while waiting for the final
ratification of 802.11e. The most important thing to know
about 802.11e and
WME/WMM is that it
enables prioritized traffic over a wireless network through
Quality of Service (QoS) protocols and
enhanced media access protocols. Proper implementation of
these protocols enables high speed bursting of data and
prioritized traffic flow.&os; supports networks that operate using 802.11a,
802.11b, and 802.11g. The WPA and 802.11i
security protocols are likewise supported (in conjunction with
any of 11a, 11b, and 11g) and QoS and
traffic prioritization required by the
WME/WMM protocols are
supported for a limited set of wireless devices.Quick StartConnecting a computer to an existing wireless network is
a very common situation. This procedure shows the steps
required.Obtain the SSID (Service Set
Identifier) and PSK (Pre-Shared Key)
for the wireless network from the network
administrator.Identify the wireless adapter. The &os;
GENERIC kernel includes drivers for
many common wireless adapters. If the wireless adapter is
one of those models, it will be shown in the output from
&man.ifconfig.8;:&prompt.user; ifconfig | grep -B3 -i wirelessIf a wireless adapter is not listed, an additional
kernel module might be required, or it might be a model
not supported by &os;.This example shows the Atheros ath0
wireless adapter.Add an entry for this network to
/etc/wpa_supplicant.conf. If the
file does not exist, create it. Replace
myssid and
mypsk with the
SSID and PSK
provided by the network administrator.network={
ssid="myssid"
psk="mypsk"
}Add entries to /etc/rc.conf to
configure the network on startup:wlans_ath0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"Restart the computer, or restart the network service
to connect to the network:&prompt.root; service netif restartBasic SetupKernel ConfigurationTo use wireless networking, a wireless networking card
is needed and the kernel needs to be configured with the
appropriate wireless networking support. The kernel is
separated into multiple modules so that only the required
support needs to be configured.The most
commonly used wireless devices are those that use parts made
by Atheros. These devices are supported by &man.ath.4;
and require the following line to be added to
/boot/loader.conf:if_ath_load="YES"The Atheros driver is split up into three separate
pieces: the driver (&man.ath.4;), the hardware support
layer that handles chip-specific functions
(&man.ath.hal.4;), and an algorithm for selecting the
rate for transmitting frames. When this support is loaded
as kernel modules, any dependencies are automatically
handled. To load support for a different type of wireless
device, specify the module for that device. This example
is for devices based on the Intersil Prism parts
(&man.wi.4;) driver:if_wi_load="YES"The examples in this section use an &man.ath.4;
device and the device name in the examples must be
changed according to the configuration. A list of
available wireless drivers and supported adapters can be
found in the &os; Hardware Notes, available on
the Release
Information page of the &os; website. If a
native &os; driver for the wireless device does not
exist, it may be possible to use the &windows; driver
with the help of the NDIS driver
wrapper.In addition, the modules that implement cryptographic
support for the security protocols to use must be loaded.
These are intended to be dynamically loaded on demand by
the &man.wlan.4; module, but for now they must be manually
configured. The following modules are available:
&man.wlan.wep.4;, &man.wlan.ccmp.4;, and &man.wlan.tkip.4;.
The &man.wlan.ccmp.4; and &man.wlan.tkip.4; drivers are
only needed when using the WPA or
802.11i security protocols. If the network does not use
encryption, &man.wlan.wep.4; support is not needed. To
load these modules at boot time, add the following lines to
/boot/loader.conf:wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"Once this information has been added to
/boot/loader.conf, reboot the &os;
box. Alternately, load the modules by hand using
&man.kldload.8;.For users who do not want to use modules, it is
possible to compile these drivers into the kernel by
adding the following lines to a custom kernel
configuration file:device wlan # 802.11 support
device wlan_wep # 802.11 WEP support
device wlan_ccmp # 802.11 CCMP support
device wlan_tkip # 802.11 TKIP support
device wlan_amrr # AMRR transmit rate control algorithm
device ath # Atheros pci/cardbus NIC's
device ath_hal # pci/cardbus chip support
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
device ath_rate_sample # SampleRate tx rate control for athWith this information in the kernel configuration
file, recompile the kernel and reboot the &os;
machine.Information about the wireless device should appear
in the boot messages, like this:ath0: <Atheros 5212> mem 0x88000000-0x8800ffff irq 11 at device 0.0 on cardbus1
ath0: [ITHREAD]
ath0: AR2413 mac 7.9 RF2413 phy 4.5Infrastructure ModeInfrastructure (BSS) mode is the
mode that is typically used. In this mode, a number of
wireless access points are connected to a wired network.
Each wireless network has its own name, called the
SSID. Wireless clients connect to the
wireless access points.&os; ClientsHow to Find Access PointsTo scan for available networks, use &man.ifconfig.8;.
This request may take a few moments to complete as it
requires the system to switch to each available wireless
frequency and probe for available access points. Only
the superuser can initiate a scan:&prompt.root; ifconfig wlan0 create wlandev ath0
&prompt.root; ifconfig wlan0 up scan
SSID/MESH ID BSSID CHAN RATE S:N INT CAPS
dlinkap 00:13:46:49:41:76 11 54M -90:96 100 EPS WPA WME
freebsdap 00:11:95:c3:0d:ac 1 54M -83:96 100 EPS WPAThe interface must be before
it can scan. Subsequent scan requests do not require
the interface to be marked as up again.The output of a scan request lists each
BSS/IBSS network
found. Besides listing the name of the network, the
SSID, the output also shows the
BSSID, which is the
MAC address of the access point. The
CAPS field identifies the type of
each network and the capabilities of the stations
operating there:
Station Capability CodesCapability CodeMeaningEExtended Service Set
(ESS). Indicates that
the station is part of an infrastructure network
rather than an IBSS/ad-hoc
network.IIBSS/ad-hoc network.
Indicates that the station is part of an ad-hoc
network rather than an ESS
network.PPrivacy. Encryption is required for all
data frames exchanged within the
BSS using cryptographic means
such as WEP,
TKIP or
AES-CCMP.SShort Preamble. Indicates that the network
is using short preambles, defined in 802.11b High
Rate/DSSS PHY, and utilizes a 56 bit sync field
rather than the 128 bit field used in long
preamble mode.sShort slot time. Indicates that the 802.11g
network is using a short slot time because there
are no legacy (802.11b) stations present.
One can also display the current list of known
networks with:&prompt.root; ifconfig wlan0 list scanThis information may be updated automatically by the
adapter or manually with a request.
Old data is automatically removed from the cache, so over
time this list may shrink unless more scans are
done.Basic SettingsThis section provides a simple example of how to make
the wireless network adapter work in &os; without
encryption. Once familiar with these concepts, it is
strongly recommend to use WPA to set up
the wireless network.There are three basic steps to configure a wireless
network: select an access point, authenticate the
station, and configure an IP address.
The following sections discuss each step.Selecting an Access PointMost of the time, it is sufficient to let the system
choose an access point using the builtin heuristics.
This is the default behaviour when an interface is
marked as up or it is listed in
/etc/rc.conf:wlans_ath0="wlan0"
ifconfig_wlan0="DHCP"If there are multiple access points, a specific
one can be selected by its
SSID:wlans_ath0="wlan0"
ifconfig_wlan0="ssid your_ssid_here DHCP"In an environment where there are multiple access
points with the same SSID, which
is often done to simplify roaming, it may be necessary
to associate to one specific device. In this case, the
BSSID of the access point can be
specified, with or without the
SSID:wlans_ath0="wlan0"
ifconfig_wlan0="ssid your_ssid_here bssid xx:xx:xx:xx:xx:xx DHCP"There are other ways to constrain the choice of an
access point, such as limiting the set of frequencies
the system will scan on. This may be useful for a
multi-band wireless card as scanning all the possible
channels can be time-consuming. To limit operation to a
specific band, use the
parameter:wlans_ath0="wlan0"
ifconfig_wlan0="mode 11g ssid your_ssid_here DHCP"This example will force the card to operate in
802.11g, which is defined only for 2.4GHz frequencies
so any 5GHz channels will not be considered. This can
also be achieved with the
parameter, which locks
operation to one specific frequency, and the
parameter, to specify a list
of channels for scanning. More information about these
parameters can be found in &man.ifconfig.8;.AuthenticationOnce an access point is selected, the station
needs to authenticate before it can pass data.
Authentication can happen in several ways. The most
common scheme, open authentication, allows any station
to join the network and communicate. This is the
authentication to use for test purposes the first time
a wireless network is setup. Other schemes require
cryptographic handshakes to be completed before data
traffic can flow, either using pre-shared keys or
secrets, or more complex schemes that involve backend
services such as RADIUS. Open
authentication is the default setting. The next most
common setup is WPA-PSK, also
known as WPA Personal, which is
described in .If using an &apple; &airport; Extreme base
station for an access point, shared-key authentication
together with a WEP key needs to
be configured. This can be configured in
/etc/rc.conf or by using
&man.wpa.supplicant.8;. For a single &airport; base
station, access can be configured with:wlans_ath0="wlan0"
ifconfig_wlan0="authmode shared wepmode on weptxkey 1 wepkey 01234567 DHCP"In general, shared key authentication should be
avoided because it uses the WEP key
material in a highly-constrained manner, making it
even easier to crack the key. If
WEP must be used for compatibility
with legacy devices, it is better to use
WEP with open
authentication. More information regarding
WEP can be found in .Getting an IP Address with
DHCPOnce an access point is selected and the
authentication parameters are set, an
IP address must be obtained in
order to communicate. Most of the time, the
IP address is obtained via
DHCP. To achieve that, edit
/etc/rc.conf and add
DHCP to the configuration for the
device:wlans_ath0="wlan0"
ifconfig_wlan0="DHCP"The
wireless interface is now ready to bring up:&prompt.root; service netif startOnce the interface is running, use &man.ifconfig.8;
to see the status of the interface
ath0:&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.1.100 netmask 0xffffff00 broadcast 192.168.1.255
media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
status: associated
ssid dlinkap channel 11 (2462 Mhz 11g) bssid 00:13:46:49:41:76
country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
roam:rate 5 protmode CTS wme burstThe status: associated line means
that it is connected to the wireless network. The
bssid 00:13:46:49:41:76 is the
MAC address of the access point and
authmode OPEN indicates that the
communication is not encrypted.Static IP AddressIn an IP address cannot be
obtained from a DHCP server, set a
fixed IP address. Replace the
DHCP keyword shown above with the
address information. Be sure to retain any other
parameters for selecting the access point:wlans_ath0="wlan0"
ifconfig_wlan0="inet 192.168.1.100 netmask 255.255.255.0 ssid your_ssid_here"WPAWi-Fi Protected Access (WPA) is a
security protocol used together with 802.11 networks to
address the lack of proper authentication and the weakness
of WEP. WPA leverages the 802.1X
authentication protocol and uses one of several ciphers
instead of WEP for data integrity.
The only cipher required by WPA is the
Temporary Key Integrity Protocol
(TKIP). TKIP is a
cipher that extends the basic RC4 cipher used by
WEP by adding integrity checking,
tamper detection, and measures for responding to detected
intrusions. TKIP is designed to work
on legacy hardware with only software modification. It
represents a compromise that improves security but is
still not entirely immune to attack.
WPA also specifies the
AES-CCMP cipher as an alternative to
TKIP, and that is preferred when
possible. For this specification, the term
WPA2 or RSN is
commonly used.WPA defines authentication and
encryption protocols. Authentication is most commonly
done using one of two techniques: by 802.1X and a backend
authentication service such as RADIUS,
or by a minimal handshake between the station and the
access point using a pre-shared secret. The former is
commonly termed WPA Enterprise and the
latter is known as WPA Personal. Since
most people will not set up a RADIUS
backend server for their wireless network,
WPA-PSK is by far the most commonly
encountered configuration for
WPA.The control of the wireless connection and the key
negotiation or authentication with a server is done using
&man.wpa.supplicant.8;. This program requires a
configuration file,
/etc/wpa_supplicant.conf, to run.
More information regarding this file can be found in
&man.wpa.supplicant.conf.5;.WPA-PSKWPA-PSK, also known as
WPA Personal, is based on a
pre-shared key (PSK) which is
generated from a given password and used as the master
key in the wireless network. This means every wireless
user will share the same key.
WPA-PSK is intended for small
networks where the use of an authentication server is
not possible or desired.Always use strong passwords that are sufficiently
long and made from a rich alphabet so that they will
not be easily guessed or attacked.The first step is the configuration of
/etc/wpa_supplicant.conf with
the SSID and the pre-shared key of
the network:network={
ssid="freebsdap"
psk="freebsdmall"
}Then, in /etc/rc.conf,
indicate that the wireless device configuration will be
done with WPA and the
IP address will be obtained with
DHCP:wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"Then, bring up the interface:&prompt.root; service netif start
Starting wpa_supplicant.
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
DHCPOFFER from 192.168.0.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.254 -- renewal in 300 seconds.
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUALOr, try to configure the interface manually using
the information in
/etc/wpa_supplicant.conf:&prompt.root; wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
Trying to associate with 00:11:95:c3:0d:ac (SSID='freebsdap' freq=2412 MHz)
Associated with 00:11:95:c3:0d:ac
WPA: Key negotiation completed with 00:11:95:c3:0d:ac [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED - Connection to 00:11:95:c3:0d:ac completed (auth) [id=0 id_str=]The next operation is to launch &man.dhclient.8;
to get the IP address from the
DHCP server:&prompt.root; dhclient wlan0
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.254 -- renewal in 300 seconds.
&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUALIf /etc/rc.conf has an
ifconfig_wlan0="DHCP" entry,
&man.dhclient.8; will be launched automatically after
&man.wpa.supplicant.8; associates with the access
point.If DHCP is not possible or
desired, set a static IP address
after &man.wpa.supplicant.8; has authenticated the
station:&prompt.root; ifconfig wlan0 inet 192.168.0.100 netmask 255.255.255.0
&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUALWhen DHCP is not used, the
default gateway and the nameserver also have to be
manually set:&prompt.root; route add default your_default_router
&prompt.root; echo "nameserver your_DNS_server" >> /etc/resolv.confWPA with
EAP-TLSThe second way to use WPA is with
an 802.1X backend authentication server. In this case,
WPA is called
WPA Enterprise to differentiate it
from the less secure WPA Personal.
Authentication in WPA Enterprise is
based on the Extensible Authentication Protocol
(EAP).EAP does not come with an
encryption method. Instead, EAP is
embedded inside an encrypted tunnel. There are many
EAP authentication methods, but
EAP-TLS, EAP-TTLS,
and EAP-PEAP are the most
common.EAP with Transport Layer Security
(EAP-TLS) is a well-supported
wireless authentication protocol since it was the
first EAP method to be certified
by the Wi-Fi
Alliance. EAP-TLS requires
three certificates to run: the certificate of the
Certificate Authority (CA) installed
on all machines, the server certificate for the
authentication server, and one client certificate for
each wireless client. In this EAP
method, both the authentication server and wireless
client authenticate each other by presenting their
respective certificates, and then verify that these
certificates were signed by the organization's
CA.As previously, the configuration is done via
/etc/wpa_supplicant.conf:network={
ssid="freebsdap"
proto=RSN
key_mgmt=WPA-EAP
eap=TLS
identity="loader"
ca_cert="/etc/certs/cacert.pem"
client_cert="/etc/certs/clientcert.pem"
private_key="/etc/certs/clientkey.pem"
private_key_passwd="freebsdmallclient"
}This field indicates the network name
(SSID).This example uses the RSN
&ieee; 802.11i protocol, also known as
WPA2.The key_mgmt line refers to
the key management protocol to use. In this
example, it is WPA using
EAP authentication.This field indicates the EAP
method for the connection.The identity field contains
the identity string for
EAP.The ca_cert field indicates
the pathname of the CA
certificate file. This file is needed to verify
the server certificate.The client_cert line gives
the pathname to the client certificate file. This
certificate is unique to each wireless client of the
network.The private_key field is the
pathname to the client certificate private key
file.The private_key_passwd field
contains the passphrase for the private key.Then, add the following lines to
/etc/rc.conf:wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"The next step is to bring up the interface:&prompt.root; service netif start
Starting wpa_supplicant.
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
DHCPACK from 192.168.0.20
bound to 192.168.0.254 -- renewal in 300 seconds.
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUALIt is also possible to bring up the interface
manually using &man.wpa.supplicant.8; and
&man.ifconfig.8;.WPA with
EAP-TTLSWith EAP-TTLS, both the
authentication server and the client need a certificate.
With EAP-TTLS, a client certificate
is optional. This method is similar to a web server
which creates a secure SSL tunnel
even if visitors do not have client-side certificates.
EAP-TTLS uses an encrypted
TLS tunnel for safe transport of
the authentication data.The required configuration can be added to
/etc/wpa_supplicant.conf:network={
ssid="freebsdap"
proto=RSN
key_mgmt=WPA-EAP
eap=TTLS
identity="test"
password="test"
ca_cert="/etc/certs/cacert.pem"
phase2="auth=MD5"
}This field specifies the EAP
method for the connection.The identity field contains
the identity string for EAP
authentication inside the encrypted
TLS tunnel.The password field contains
the passphrase for the EAP
authentication.The ca_cert field indicates
the pathname of the CA
certificate file. This file is needed to verify
the server certificate.This field specifies the authentication
method used in the encrypted TLS
tunnel. In this example,
EAP with MD5-Challenge is used.
The inner authentication phase is
often called phase2.Next, add the following lines to
/etc/rc.conf:wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"The next step is to bring up the interface:&prompt.root; service netif start
Starting wpa_supplicant.
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
DHCPACK from 192.168.0.20
bound to 192.168.0.254 -- renewal in 300 seconds.
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUALWPA with
EAP-PEAPPEAPv0/EAP-MSCHAPv2 is the most
common PEAP method. In this
chapter, the term PEAP is used to
refer to that method.Protected EAP (PEAP) is designed
as an alternative to EAP-TTLS and
is the most used EAP standard after
EAP-TLS. In a network with mixed
operating systems, PEAP should be
the most supported standard after
EAP-TLS.PEAP is similar to
EAP-TTLS as it uses a server-side
certificate to authenticate clients by creating an
encrypted TLS tunnel between the
client and the authentication server, which protects
the ensuing exchange of authentication information.
PEAP authentication differs from
EAP-TTLS as it broadcasts the
username in the clear and only the password is sent
in the encrypted TLS tunnel.
EAP-TTLS will use the
TLS tunnel for both the username
and password.Add the following lines to
/etc/wpa_supplicant.conf to
configure the EAP-PEAP related
settings:network={
ssid="freebsdap"
proto=RSN
key_mgmt=WPA-EAP
eap=PEAP
identity="test"
password="test"
ca_cert="/etc/certs/cacert.pem"
phase1="peaplabel=0"
phase2="auth=MSCHAPV2"
}This field specifies the EAP
method for the connection.The identity field contains
the identity string for EAP
authentication inside the encrypted
TLS tunnel.The password field contains
the passphrase for the EAP
authentication.The ca_cert field indicates
the pathname of the CA
certificate file. This file is needed to verify
the server certificate.This field contains the parameters for the
first phase of authentication, the
TLS tunnel. According to the
authentication server used, specify a specific
label for authentication. Most of the time, the
label will be client EAP
encryption which is set by using
peaplabel=0. More information
can be found in &man.wpa.supplicant.conf.5;.This field specifies the authentication
protocol used in the encrypted
TLS tunnel. In the
case of PEAP, it is
auth=MSCHAPV2.Add the following to
/etc/rc.conf:wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"Then, bring up the interface:&prompt.root; service netif start
Starting wpa_supplicant.
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
DHCPACK from 192.168.0.20
bound to 192.168.0.254 -- renewal in 300 seconds.
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUALWEPWired Equivalent Privacy (WEP) is
part of the original 802.11 standard. There is no
authentication mechanism, only a weak form of access
control which is easily cracked.WEP can be set up using
&man.ifconfig.8;:&prompt.root; ifconfig wlan0 create wlandev ath0
&prompt.root; ifconfig wlan0 inet 192.168.1.100 netmask 255.255.255.0 \
ssid my_net wepmode on weptxkey 3 wepkey 3:0x3456789012The weptxkey specifies which
WEP key will be used in the
transmission. This example uses the third key.
This must match the setting on the access point.
When unsure which key is used by the access point,
try 1 (the first key) for this
value.The wepkey selects one of the
WEP keys. It should be in the
format index:key. Key
1 is used by default; the index
only needs to be set when using a key other than the
first key.Replace the 0x3456789012
with the key configured for use on the access
point.Refer to &man.ifconfig.8; for further
information.The &man.wpa.supplicant.8; facility can be used to
configure a wireless interface with
WEP. The example above can be set up
by adding the following lines to
/etc/wpa_supplicant.conf:network={
ssid="my_net"
key_mgmt=NONE
wep_key3=3456789012
wep_tx_keyidx=3
}Then:&prompt.root; wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
Trying to associate with 00:13:46:49:41:76 (SSID='dlinkap' freq=2437 MHz)
Associated with 00:13:46:49:41:76Ad-hoc ModeIBSS mode, also called ad-hoc mode, is
designed for point to point connections. For example, to
establish an ad-hoc network between the machines
A and B,
choose two IP addresses and a
SSID.On A:&prompt.root; ifconfig wlan0 create wlandev ath0 wlanmode adhoc
&prompt.root; ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap
&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:11:95:c3:0d:ac
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <adhoc>
status: running
ssid freebsdap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
protmode CTS wme burstThe adhoc parameter indicates that the
interface is running in IBSS mode.B should now be able to detect
A:&prompt.root; ifconfig wlan0 create wlandev ath0 wlanmode adhoc
&prompt.root; ifconfig wlan0 up scan
SSID/MESH ID BSSID CHAN RATE S:N INT CAPS
freebsdap 02:11:95:c3:0d:ac 2 54M -64:-96 100 IS WMEThe I in the output confirms that
A is in ad-hoc mode. Now, configure
B with a different
IP address:&prompt.root; ifconfig wlan0 inet 192.168.0.2 netmask 255.255.255.0 ssid freebsdap
&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <adhoc>
status: running
ssid freebsdap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
protmode CTS wme burstBoth A and
B are now ready to exchange
information.&os; Host Access Points&os; can act as an Access Point (AP)
which eliminates the need to buy a hardware
AP or run an ad-hoc network. This can
be particularly useful when a &os; machine is acting as a
gateway to another network such as the Internet.Basic SettingsBefore configuring a &os; machine as an
AP, the kernel must be configured with
the appropriate networking support for the wireless card
as well as the security protocols being used. For more
details, see .The NDIS driver wrapper for
&windows; drivers does not currently support
AP operation. Only native &os;
wireless drivers support AP
mode.Once wireless networking support is loaded, check if
the wireless device supports the host-based access point
mode, also known as hostap mode:&prompt.root; ifconfig wlan0 create wlandev ath0
&prompt.root; ifconfig wlan0 list caps
drivercaps=6f85edc1<STA,FF,TURBOP,IBSS,HOSTAP,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,BURST,WME,WDS,BGSCAN,TXFRAG>
cryptocaps=1f<WEP,TKIP,AES,AES_CCM,TKIPMIC>This output displays the card's capabilities. The
HOSTAP word confirms that this wireless
card can act as an AP. Various supported
ciphers are also listed: WEP,
TKIP, and AES. This
information indicates which security protocols can be used
on the AP.The wireless device can only be put into hostap mode
during the creation of the network pseudo-device, so a
previously created device must be destroyed first:&prompt.root; ifconfig wlan0 destroythen regenerated with the correct option before setting
the other parameters:&prompt.root; ifconfig wlan0 create wlandev ath0 wlanmode hostap
&prompt.root; ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1Use &man.ifconfig.8; again to see the status of the
wlan0 interface:&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:11:95:c3:0d:ac
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
status: running
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
protmode CTS wme burst dtimperiod 1 -dfsThe hostap parameter indicates the
interface is running in the host-based access point
mode.The interface configuration can be done automatically at
boot time by adding the following lines to
/etc/rc.conf:wlans_ath0="wlan0"
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1"Host-based Access Point Without Authentication or
EncryptionAlthough it is not recommended to run an
AP without any authentication or
encryption, this is a simple way to check if the
AP is working. This configuration is
also important for debugging client issues.Once the AP is configured, initiate
a scan from another wireless machine to find the
AP:&prompt.root; ifconfig wlan0 create wlandev ath0
&prompt.root; ifconfig wlan0 up scan
SSID/MESH ID BSSID CHAN RATE S:N INT CAPS
freebsdap 00:11:95:c3:0d:ac 1 54M -66:-96 100 ES WMEThe client machine found the AP and
can be associated with it:&prompt.root; ifconfig wlan0 inet 192.168.0.2 netmask 255.255.255.0 ssid freebsdap
&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
roam:rate 5 protmode CTS wme burstWPA Host-based Access PointThis section focuses on setting up a &os;
AP using the WPA
security protocol. More details regarding
WPA and the configuration of
WPA-based wireless clients can be found
in .The &man.hostapd.8; daemon is used to deal with client
authentication and key management on the
WPA-enabled AP.The following configuration operations are performed
on the &os; machine acting as the AP.
Once the AP is correctly working,
&man.hostapd.8; should be automatically enabled at boot
with the following line in
/etc/rc.conf:hostapd_enable="YES"Before trying to configure &man.hostapd.8;, first
configure the basic settings introduced in .WPA-PSKWPA-PSK is intended for small
networks where the use of a backend authentication server
is not possible or desired.The configuration is done in
/etc/hostapd.conf:interface=wlan0
debug=1
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=freebsdap
wpa=1
wpa_passphrase=freebsdmall
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP This field indicates the wireless interface used
for the AP.This field sets the level of verbosity during the
execution of &man.hostapd.8;. A value of
1 represents the minimal
level.The ctrl_interface field gives
the pathname of the directory used by &man.hostapd.8;
to store its domain socket files for the communication
with external programs such as &man.hostapd.cli.8;.
The default value is used in this example.The ctrl_interface_group line
sets the group which is allowed to access the control
interface files.This field sets the network name.The wpa field enables
WPA and specifies which
WPA authentication protocol will
be required. A value of 1
configures the AP for
WPA-PSK.The wpa_passphrase field
contains the ASCII passphrase for
WPA authentication.Always use strong passwords that are
sufficiently long and made from a rich alphabet so
that they will not be easily guessed or
attacked.The wpa_key_mgmt line refers
to the key management protocol to use. This example
sets WPA-PSK.The wpa_pairwise field
indicates the set of accepted encryption algorithms by
the AP. In this example, both
TKIP (WPA) and
CCMP (WPA2)
ciphers are accepted. The CCMP
cipher is an alternative to TKIP
and is strongly preferred when possible.
TKIP should be used solely for
stations incapable of doing
CCMP.The next step is to start &man.hostapd.8;:&prompt.root; service hostapd forcestart&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2290
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
inet6 fe80::211:95ff:fec3:dac%ath0 prefixlen 64 scopeid 0x4
ether 00:11:95:c3:0d:ac
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
status: associated
ssid freebsdap channel 1 bssid 00:11:95:c3:0d:ac
authmode WPA2/802.11i privacy MIXED deftxkey 2 TKIP 2:128-bit txpowmax 36 protmode CTS dtimperiod 1 bintval 100Once the AP is running, the
clients can associate with it. See for more details. It
is possible to see the stations associated with the
AP using ifconfig
wlan0 list
sta.WEP Host-based Access PointIt is not recommended to use WEP for
setting up an AP since there is no
authentication mechanism and the encryption is easily
cracked. Some legacy wireless cards only support
WEP and these cards will only support
an AP without authentication or
encryption.The wireless device can now be put into hostap mode and
configured with the correct SSID and
IP address:&prompt.root; ifconfig wlan0 create wlandev ath0 wlanmode hostap
&prompt.root; ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 \
ssid freebsdap wepmode on weptxkey 3 wepkey 3:0x3456789012 mode 11gThe weptxkey indicates which
WEP key will be used in the
transmission. This example uses the third key as key
numbering starts with 1. This
parameter must be specified in order to encrypt the
data.The wepkey sets the selected
WEP key. It should be in the format
index:key. If the index is
not given, key 1 is set. The index
needs to be set when using keys other than the first
key.Use &man.ifconfig.8; to see the status of the
wlan0 interface:&prompt.root; ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:11:95:c3:0d:ac
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
status: running
ssid freebsdap channel 4 (2427 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode OPEN privacy ON deftxkey 3 wepkey 3:40-bit
txpower 21.5 scanvalid 60 protmode CTS wme burst dtimperiod 1 -dfsFrom another wireless machine, it is now possible to
initiate a scan to find the AP:&prompt.root; ifconfig wlan0 create wlandev ath0
&prompt.root; ifconfig wlan0 up scan
SSID BSSID CHAN RATE S:N INT CAPS
freebsdap 00:11:95:c3:0d:ac 1 54M 22:1 100 EPSIn this example, the client machine found the
AP and can associate with it using the
correct parameters. See for more details.Using Both Wired and Wireless ConnectionsA wired connection provides better performance and
reliability, while a wireless connection provides flexibility
and mobility. Laptop users typically want to roam seamlessly
between the two types of connections.On &os;, it is possible to combine two or even more
network interfaces together in a failover
fashion. This type of configuration uses the most preferred
and available connection from a group of network interfaces,
and the operating system switches automatically when the link
state changes.Link aggregation and failover is covered in and an example for using
both wired and wireless connections is provided at .TroubleshootingThis section describes
a number of steps to help troubleshoot common wireless
networking problems.If the access point is not listed when scanning,
check that the configuration has not limited the wireless
device to a limited set of channels.If the device cannot associate with an access point,
verify that the configuration matches the settings on the
access point. This includes the authentication scheme and
any security protocols. Simplify the configuration as
much as possible. If using a security protocol such as
WPA or WEP,
configure the access point for open authentication and
no security to see if traffic will pass.Debugging support is provided by
&man.wpa.supplicant.8;. Try running this utility manually
- with the option and look at the
+ with and look at the
system logs.Once the system can associate with the access point,
diagnose the network configuration using tools like
&man.ping.8;.There are many lower-level debugging tools.
Debugging messages can be enabled in the 802.11 protocol
support layer using &man.wlandebug.8;. On a &os; system
prior to &os; 9.1, this program can be found in
/usr/src/tools/tools/net80211.
For example, to enable console messages related to
scanning for access points and the 802.11 protocol
handshakes required to arrange communication:&prompt.root; wlandebug -i ath0 +scan+auth+debug+assoc
net.wlan.0.debug: 0 => 0xc80000<assoc,auth,scan>Many useful statistics are maintained by the 802.11
layer and wlanstats, found in /usr/src/tools/tools/net80211,
will dump this information. These statistics should
display all errors identified by the 802.11 layer.
However, some errors are identified in the device drivers
that lie below the 802.11 layer so they may not show up.
To diagnose device-specific problems, refer to the
drivers' documentation.If the above information does not help to clarify the
problem, submit a problem report and include output from the
above tools.USB TetheringtetherMany cellphones provide the option to share their data
connection over USB (often called "tethering"). This feature
uses either the RNDIS, CDC
or a custom &apple; &iphone;/&ipad;
protocol.&android; devices generally use the &man.urndis.4;
driver.&apple; devices use the &man.ipheth.4; driver.Older devices will often use the &man.cdce.4;
driver.Before attaching a device, load the appropriate driver
into the kernel:&prompt.root; kldload if_urndis
&prompt.root; kldload if_cdce
&prompt.root; kldload if_iphethOnce the device is attached
ue0 will be
available for use like a normal network device. Be sure that
the USB tethering option is enabled on the
device.BluetoothPavLucistnikWritten by pav@FreeBSD.orgBluetoothBluetooth is a wireless technology for creating personal
networks operating in the 2.4 GHz unlicensed band, with a
range of 10 meters. Networks are usually formed ad-hoc from
portable devices such as cellular phones, handhelds, and
laptops. Unlike Wi-Fi wireless technology, Bluetooth offers
higher level service profiles, such as
FTP-like file servers, file pushing, voice
transport, serial line emulation, and more.This section describes the use of a USB
Bluetooth dongle on a &os; system. It then describes the
various Bluetooth protocols and utilities.Loading Bluetooth SupportThe Bluetooth stack in &os; is implemented using the
&man.netgraph.4; framework. A broad variety of Bluetooth
USB dongles is supported by &man.ng.ubt.4;.
Broadcom BCM2033 based Bluetooth devices are supported by the
&man.ubtbcmfw.4; and &man.ng.ubt.4; drivers. The 3Com
Bluetooth PC Card 3CRWB60-A is supported by the
&man.ng.bt3c.4; driver. Serial and UART based Bluetooth
devices are supported by &man.sio.4;, &man.ng.h4.4;, and
&man.hcseriald.8;.Before attaching a device, determine which of the above
drivers it uses, then load the driver. For example, if the
device uses the &man.ng.ubt.4; driver:&prompt.root; kldload ng_ubtIf the Bluetooth device will be attached to the system
during system startup, the system can be configured to load
the module at boot time by adding the driver to
/boot/loader.conf:ng_ubt_load="YES"Once the driver is loaded, plug in the
USB dongle. If the driver load was
successful, output similar to the following should appear on
the console and in
/var/log/messages:ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
wMaxPacketSize=49, nframes=6, buffer size=294To start and stop the Bluetooth stack, use its startup
script. It is a good idea to stop the stack before unplugging
the device. When starting the stack, the output should be
similar to the following:&prompt.root; service bluetooth start ubt0
BD_ADDR: 00:02:72:00:d4:1a
Features: 0xff 0xff 0xf 00 00 00 00 00
<3-Slot> <5-Slot> <Encryption> <Slot offset>
<Timing accuracy> <Switch> <Hold mode> <Sniff mode>
<Park mode> <RSSI> <Channel quality> <SCO link>
<HV2 packets> <HV3 packets> <u-law log> <A-law log> <CVSD>
<Paging scheme> <Power control> <Transparent SCO data>
Max. ACL packet size: 192 bytes
Number of ACL packets: 8
Max. SCO packet size: 64 bytes
Number of SCO packets: 8Finding Other Bluetooth DevicesHCIThe Host Controller Interface (HCI)
provides a uniform method for accessing Bluetooth baseband
capabilities. In &os;, a netgraph HCI node
is created for each Bluetooth device. For more details, refer
to &man.ng.hci.4;.One of the most common tasks is discovery of Bluetooth
devices within RF proximity. This
operation is called inquiry. Inquiry and
other HCI related operations are done using
&man.hccontrol.8;. The example below shows how to find out
which Bluetooth devices are in range. The list of devices
should be displayed in a few seconds. Note that a remote
device will only answer the inquiry if it is set to
discoverable mode.&prompt.user; hccontrol -n ubt0hci inquiry
Inquiry result, num_responses=1
Inquiry result #0
BD_ADDR: 00:80:37:29:19:a4
Page Scan Rep. Mode: 0x1
Page Scan Period Mode: 00
Page Scan Mode: 00
Class: 52:02:04
Clock offset: 0x78ef
Inquiry complete. Status: No error [00]The BD_ADDR is the unique address of a
Bluetooth device, similar to the MAC
address of a network card. This address is needed for further
communication with a device and it is possible to assign a
human readable name to a BD_ADDR. Information regarding the
known Bluetooth hosts is contained in
/etc/bluetooth/hosts. The following
example shows how to obtain the human readable name that was
assigned to the remote device:&prompt.user; hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4
BD_ADDR: 00:80:37:29:19:a4
Name: Pav's T39If an inquiry is performed on a remote Bluetooth device,
it will find the computer as
your.host.name (ubt0). The name assigned to
the local device can be changed at any time.The Bluetooth system provides a point-to-point connection
between two Bluetooth units, or a point-to-multipoint
connection which is shared among several Bluetooth devices.
The following example shows how to obtain the list of active
baseband connections for the local device:&prompt.user; hccontrol -n ubt0hci read_connection_list
Remote BD_ADDR Handle Type Mode Role Encrypt Pending Queue State
00:80:37:29:19:a4 41 ACL 0 MAST NONE 0 0 OPENA connection handle is useful when
termination of the baseband connection is required, though
it is normally not required to do this by hand. The stack
will automatically terminate inactive baseband
connections.&prompt.root; hccontrol -n ubt0hci disconnect 41
Connection handle: 41
Reason: Connection terminated by local host [0x16]Type hccontrol help for a complete
listing of available HCI commands. Most
of the HCI commands do not require
superuser privileges.Device PairingBy default, Bluetooth communication is not authenticated,
and any device can talk to any other device. A Bluetooth
device, such as a cellular phone, may choose to require
authentication to provide a particular service. Bluetooth
authentication is normally done with a
PIN code, an ASCII
string up to 16 characters in length. The user is required
to enter the same PIN code on both devices.
Once the user has entered the PIN code,
both devices will generate a link key.
After that, the link key can be stored either in the devices
or in a persistent storage. Next time, both devices will
use the previously generated link key. This procedure is
called pairing. Note that if the link
key is lost by either device, the pairing must be
repeated.The &man.hcsecd.8; daemon is responsible for handling
Bluetooth authentication requests. The default configuration
file is /etc/bluetooth/hcsecd.conf. An
example section for a cellular phone with the
PIN code set to 1234 is
shown below:device {
bdaddr 00:80:37:29:19:a4;
name "Pav's T39";
key nokey;
pin "1234";
}The only limitation on PIN codes is
length. Some devices, such as Bluetooth headsets, may have
a fixed PIN code built in. The
switch forces &man.hcsecd.8; to stay in
the foreground, so it is easy to see what is happening. Set
the remote device to receive pairing and initiate the
Bluetooth connection to the remote device. The remote device
should indicate that pairing was accepted and request the
PIN code. Enter the same
PIN code listed in
hcsecd.conf. Now the computer and the
remote device are paired. Alternatively, pairing can be
initiated on the remote device.The following line can be added to
/etc/rc.conf to configure &man.hcsecd.8;
to start automatically on system start:hcsecd_enable="YES"The following is a sample of the &man.hcsecd.8; daemon
output:hcsecd[16484]: Got Link_Key_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4
hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', link key doesn't exist
hcsecd[16484]: Sending Link_Key_Negative_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4
hcsecd[16484]: Got PIN_Code_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4
hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', PIN code exists
hcsecd[16484]: Sending PIN_Code_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4Network Access with
PPP ProfilesA Dial-Up Networking (DUN) profile can
be used to configure a cellular phone as a wireless modem for
connecting to a dial-up Internet access server. It can also
be used to configure a computer to receive data calls from a
cellular phone.Network access with a PPP profile can
be used to provide LAN access for a single
Bluetooth device or multiple Bluetooth devices. It can also
provide PC to PC
connection using PPP networking over serial
cable emulation.In &os;, these profiles are implemented with &man.ppp.8;
and the &man.rfcomm.pppd.8; wrapper which converts a
Bluetooth connection into something
PPP can use. Before a profile can be used,
a new PPP label must be created in
/etc/ppp/ppp.conf. Consult
&man.rfcomm.pppd.8; for examples.In this example, &man.rfcomm.pppd.8; is used to open a
connection to a remote device with a
BD_ADDR of
00:80:37:29:19:a4 on a
DUN RFCOMM
channel:&prompt.root; rfcomm_pppd -a 00:80:37:29:19:a4 -c -C dun -l rfcomm-dialupThe actual channel number will be obtained from the remote
device using the SDP protocol. It is
possible to specify the RFCOMM channel by
hand, and in this case &man.rfcomm.pppd.8; will not perform
the SDP query. Use &man.sdpcontrol.8; to
find out the RFCOMM channel on the remote
device.In order to provide network access with the
PPP LAN service,
&man.sdpd.8; must be running and a new entry for
LAN clients must be created in
/etc/ppp/ppp.conf. Consult
&man.rfcomm.pppd.8; for examples. Finally, start the
RFCOMM PPP server on a
valid RFCOMM channel number. The
RFCOMM PPP server will
automatically register the Bluetooth LAN
service with the local SDP daemon. The
example below shows how to start the RFCOMM
PPP server.&prompt.root; rfcomm_pppd -s -C 7 -l rfcomm-serverBluetooth ProtocolsThis section provides an overview of the various Bluetooth
protocols, their function, and associated utilities.Logical Link Control and Adaptation Protocol
(L2CAP)L2CAPThe Logical Link Control and Adaptation Protocol
(L2CAP) provides connection-oriented and
connectionless data services to upper layer protocols.
L2CAP permits higher level protocols and
applications to transmit and receive
L2CAP data packets up to 64 kilobytes in
length.L2CAP is based around the concept of
channels. A channel is a logical
connection on top of a baseband connection, where each
channel is bound to a single protocol in a many-to-one
fashion. Multiple channels can be bound to the same
protocol, but a channel cannot be bound to multiple
protocols. Each L2CAP packet received on
a channel is directed to the appropriate higher level
protocol. Multiple channels can share the same baseband
connection.In &os;, a netgraph L2CAP node is
created for each Bluetooth device. This node is normally
connected to the downstream Bluetooth HCI
node and upstream Bluetooth socket nodes. The default name
for the L2CAP node is
devicel2cap. For more details refer to
&man.ng.l2cap.4;.A useful command is &man.l2ping.8;, which can be used to
ping other devices. Some Bluetooth implementations might
not return all of the data sent to them, so 0
bytes in the following example is normal.&prompt.root; l2ping -a 00:80:37:29:19:a4
0 bytes from 0:80:37:29:19:a4 seq_no=0 time=48.633 ms result=0
0 bytes from 0:80:37:29:19:a4 seq_no=1 time=37.551 ms result=0
0 bytes from 0:80:37:29:19:a4 seq_no=2 time=28.324 ms result=0
0 bytes from 0:80:37:29:19:a4 seq_no=3 time=46.150 ms result=0The &man.l2control.8; utility is used to perform various
operations on L2CAP nodes. This example
shows how to obtain the list of logical connections
(channels) and the list of baseband connections for the
local device:&prompt.user; l2control -a 00:02:72:00:d4:1a read_channel_list
L2CAP channels:
Remote BD_ADDR SCID/ DCID PSM IMTU/ OMTU State
00:07:e0:00:0b:ca 66/ 64 3 132/ 672 OPEN
&prompt.user; l2control -a 00:02:72:00:d4:1a read_connection_list
L2CAP connections:
Remote BD_ADDR Handle Flags Pending State
00:07:e0:00:0b:ca 41 O 0 OPENAnother diagnostic tool is &man.btsockstat.1;. It is
similar to &man.netstat.1;, but for Bluetooth
network-related data structures. The example below shows
the same logical connection as &man.l2control.8;
above.&prompt.user; btsockstat
Active L2CAP sockets
PCB Recv-Q Send-Q Local address/PSM Foreign address CID State
c2afe900 0 0 00:02:72:00:d4:1a/3 00:07:e0:00:0b:ca 66 OPEN
Active RFCOMM sessions
L2PCB PCB Flag MTU Out-Q DLCs State
c2afe900 c2b53380 1 127 0 Yes OPEN
Active RFCOMM sockets
PCB Recv-Q Send-Q Local address Foreign address Chan DLCI State
c2e8bc80 0 250 00:02:72:00:d4:1a 00:07:e0:00:0b:ca 3 6 OPENRadio Frequency Communication
(RFCOMM)The RFCOMM protocol provides
emulation of serial ports over the L2CAP
protocol. RFCOMM is a simple transport
protocol, with additional provisions for emulating the 9
circuits of RS-232 (EIATIA-232-E) serial ports. It
supports up to 60 simultaneous connections
(RFCOMM channels) between two Bluetooth
devices.For the purposes of RFCOMM, a
complete communication path involves two applications
running on the communication endpoints with a communication
segment between them. RFCOMM is intended
to cover applications that make use of the serial ports of
the devices in which they reside. The communication segment
is a direct connect Bluetooth link from one device to
another.RFCOMM is only concerned with the
connection between the devices in the direct connect case,
or between the device and a modem in the network case.
RFCOMM can support other configurations,
such as modules that communicate via Bluetooth wireless
technology on one side and provide a wired interface on the
other side.In &os;, RFCOMM is implemented at the
Bluetooth sockets layer.Service Discovery Protocol
(SDP)SDPThe Service Discovery Protocol (SDP)
provides the means for client applications to discover the
existence of services provided by server applications as
well as the attributes of those services. The attributes of
a service include the type or class of service offered and
the mechanism or protocol information needed to utilize the
service.SDP involves communication between a
SDP server and a SDP
client. The server maintains a list of service records that
describe the characteristics of services associated with the
server. Each service record contains information about a
single service. A client may retrieve information from a
service record maintained by the SDP
server by issuing a SDP request. If the
client, or an application associated with the client,
decides to use a service, it must open a separate connection
to the service provider in order to utilize the service.
SDP provides a mechanism for discovering
services and their attributes, but it does not provide a
mechanism for utilizing those services.Normally, a SDP client searches for
services based on some desired characteristics of the
services. However, there are times when it is desirable to
discover which types of services are described by an
SDP server's service records without any
prior information about the services. This process of
looking for any offered services is called
browsing.The Bluetooth SDP server,
&man.sdpd.8;, and command line client, &man.sdpcontrol.8;,
are included in the standard &os; installation. The
following example shows how to perform a
SDP browse query.&prompt.user; sdpcontrol -a 00:01:03:fc:6e:ec browse
Record Handle: 00000000
Service Class ID List:
Service Discovery Server (0x1000)
Protocol Descriptor List:
L2CAP (0x0100)
Protocol specific parameter #1: u/int/uuid16 1
Protocol specific parameter #2: u/int/uuid16 1
Record Handle: 0x00000001
Service Class ID List:
Browse Group Descriptor (0x1001)
Record Handle: 0x00000002
Service Class ID List:
LAN Access Using PPP (0x1102)
Protocol Descriptor List:
L2CAP (0x0100)
RFCOMM (0x0003)
Protocol specific parameter #1: u/int8/bool 1
Bluetooth Profile Descriptor List:
LAN Access Using PPP (0x1102) ver. 1.0Note that each service has a list of attributes, such
as the RFCOMM channel. Depending on the
service, the user might need to make note of some of the
attributes. Some Bluetooth implementations do not support
service browsing and may return an empty list. In this
case, it is possible to search for the specific service.
The example below shows how to search for the
OBEX Object Push
(OPUSH) service:&prompt.user; sdpcontrol -a 00:01:03:fc:6e:ec search OPUSHOffering services on &os; to Bluetooth clients is done
with the &man.sdpd.8; server. The following line can be
added to /etc/rc.conf:sdpd_enable="YES"Then the &man.sdpd.8; daemon can be started with:&prompt.root; service sdpd startThe local server application that wants to provide a
Bluetooth service to remote clients will register the
service with the local SDP daemon. An
example of such an application is &man.rfcomm.pppd.8;. Once
started, it will register the Bluetooth LAN service with the
local SDP daemon.The list of services registered with the local
SDP server can be obtained by issuing a
SDP browse query via the local control
channel:&prompt.root; sdpcontrol -l browseOBEX Object Push
(OPUSH)OBEXObject Exchange (OBEX) is a widely
used protocol for simple file transfers between mobile
devices. Its main use is in infrared communication, where
it is used for generic file transfers between notebooks or
PDAs, and for sending business cards or
calendar entries between cellular phones and other devices
with Personal Information Manager (PIM)
applications.The OBEX server and client are
implemented by obexapp, which can
be installed using the comms/obexapp
package or port.The OBEX client is used to push
and/or pull objects from the OBEX server.
An example object is a business card or an appointment.
The OBEX client can obtain the
RFCOMM channel number from the remote
device via SDP. This can be done by
specifying the service name instead of the
RFCOMM channel number. Supported service
names are: IrMC, FTRN,
and OPUSH. It is also possible to
specify the RFCOMM channel as a number.
Below is an example of an OBEX session
where the device information object is pulled from the
cellular phone, and a new object, the business card, is
pushed into the phone's directory.&prompt.user; obexapp -a 00:80:37:29:19:a4 -C IrMC
obex> get telecom/devinfo.txt devinfo-t39.txt
Success, response: OK, Success (0x20)
obex> put new.vcf
Success, response: OK, Success (0x20)
obex> di
Success, response: OK, Success (0x20)In order to provide the OPUSH
service, &man.sdpd.8; must be running and a root folder,
where all incoming objects will be stored, must be created.
The default path to the root folder is
/var/spool/obex. Finally, start the
OBEX server on a valid
RFCOMM channel number. The
OBEX server will automatically register
the OPUSH service with the local
SDP daemon. The example below shows how
to start the OBEX server.&prompt.root; obexapp -s -C 10Serial Port Profile (SPP)The Serial Port Profile (SPP) allows
Bluetooth devices to perform serial cable emulation. This
profile allows legacy applications to use Bluetooth as a
cable replacement, through a virtual serial port
abstraction.In &os;, &man.rfcomm.sppd.1; implements
SPP and a pseudo tty is used as a virtual
serial port abstraction. The example below shows how to
connect to a remote device's serial port service. A
RFCOMM channel does not have to be
specified as &man.rfcomm.sppd.1; can obtain it from the
remote device via SDP. To override this,
specify a RFCOMM channel on the command
line.&prompt.root; rfcomm_sppd -a 00:07:E0:00:0B:CA -t
rfcomm_sppd[94692]: Starting on /dev/pts/6...
/dev/pts/6Once connected, the pseudo tty can be used as serial
port:&prompt.root; cu -l /dev/pts/6The pseudo tty is printed on stdout and can be read by
wrapper scripts:PTS=`rfcomm_sppd -a 00:07:E0:00:0B:CA -t`
cu -l $PTSTroubleshootingBy default, when &os; is accepting a new connection, it
tries to perform a role switch and become master. Some older
Bluetooth devices which do not support role switching will not
be able to connect. Since role switching is performed when a
new connection is being established, it is not possible to ask
the remote device if it supports role switching. However,
there is a HCI option to disable role
switching on the local side:&prompt.root; hccontrol -n ubt0hci write_node_role_switch 0To display Bluetooth packets, use the third-party package
hcidump, which can be installed
using the comms/hcidump package or port.
This utility is similar to &man.tcpdump.1; and can be used to
display the contents of Bluetooth packets on the terminal and
to dump the Bluetooth packets to a file.BridgingAndrewThompsonWritten by IP subnetbridgeIt is sometimes useful to divide a network, such as an
Ethernet segment, into network segments without having to
create IP subnets and use a router to connect
the segments together. A device that connects two networks
together in this fashion is called a
bridge.A bridge works by learning the MAC
addresses of the devices on each of its network interfaces. It
forwards traffic between networks only when the source and
destination MAC addresses are on different
networks. In many respects, a bridge is like an Ethernet switch
with very few ports. A &os; system with multiple network
interfaces can be configured to act as a bridge.Bridging can be useful in the following situations:Connecting NetworksThe basic operation of a bridge is to join two or more
network segments. There are many reasons to use a
host-based bridge instead of networking equipment, such as
cabling constraints or firewalling. A bridge can also
connect a wireless interface running in hostap mode to a
wired network and act as an access point.Filtering/Traffic Shaping FirewallA bridge can be used when firewall functionality is
needed without routing or Network Address Translation
(NAT).An example is a small company that is connected via
DSL or ISDN to an
ISP. There are thirteen public
IP addresses from the
ISP and ten computers on the network.
In this situation, using a router-based firewall is
difficult because of subnetting issues. A bridge-based
firewall can be configured without any
IP addressing issues.Network TapA bridge can join two network segments in order to
inspect all Ethernet frames that pass between them using
&man.bpf.4; and &man.tcpdump.1; on the bridge interface or
by sending a copy of all frames out an additional
interface known as a span port.Layer 2 VPNTwo Ethernet networks can be joined across an
IP link by bridging the networks to an
EtherIP tunnel or a &man.tap.4; based solution such as
OpenVPN.Layer 2 RedundancyA network can be connected together with multiple
links and use the Spanning Tree Protocol
(STP) to block redundant paths.This section describes how to configure a &os; system as a
bridge using &man.if.bridge.4;. A netgraph bridging driver is
also available, and is described in &man.ng.bridge.4;.Packet filtering can be used with any firewall package
that hooks into the &man.pfil.9; framework. The bridge can be
used as a traffic shaper with &man.altq.4; or
&man.dummynet.4;.Enabling the BridgeIn &os;, &man.if.bridge.4; is a kernel module which is
automatically loaded by &man.ifconfig.8; when creating a
bridge interface. It is also possible to compile bridge
support into a custom kernel by adding
device if_bridge to the custom kernel
configuration file.The bridge is created using interface cloning. To create
the bridge interface:&prompt.root; ifconfig bridge create
bridge0
&prompt.root; ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 96:3d:4b:f1:79:7a
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0When a bridge interface is created, it is automatically
assigned a randomly generated Ethernet address. The
maxaddr and timeout
parameters control how many MAC addresses
the bridge will keep in its forwarding table and how many
seconds before each entry is removed after it is last seen.
The other parameters control how STP
operates.Next, specify which network interfaces to add as members
of the bridge. For the bridge to forward packets, all member
interfaces and the bridge need to be up:&prompt.root; ifconfig bridge0 addm fxp0 addm fxp1 up
&prompt.root; ifconfig fxp0 up
&prompt.root; ifconfig fxp1 upThe bridge can now forward Ethernet frames between
fxp0 and fxp1. Add
the following lines to /etc/rc.conf so
the bridge is created at startup:cloned_interfaces="bridge0"
ifconfig_bridge0="addm fxp0 addm fxp1 up"
ifconfig_fxp0="up"
ifconfig_fxp1="up"If the bridge host needs an IP
address, set it on the bridge interface, not on the member
interfaces. The address can be set statically or via
DHCP. This example sets a static
IP address:&prompt.root; ifconfig bridge0 inet 192.168.0.1/24It is also possible to assign an IPv6
address to a bridge interface. To make the changes permanent,
add the addressing information to
/etc/rc.conf.When packet filtering is enabled, bridged packets will
pass through the filter inbound on the originating interface
on the bridge interface, and outbound on the appropriate
interfaces. Either stage can be disabled. When direction
of the packet flow is important, it is best to firewall on
the member interfaces rather than the bridge itself.The bridge has several configurable settings for passing
non-IP and IP packets,
and layer2 firewalling with &man.ipfw.8;. See
&man.if.bridge.4; for more information.Enabling Spanning TreeFor an Ethernet network to function properly, only one
active path can exist between two devices. The
STP protocol detects loops and puts
redundant links into a blocked state. Should one of the
active links fail, STP calculates a
different tree and enables one of the blocked paths to restore
connectivity to all points in the network.The Rapid Spanning Tree Protocol (RSTP
or 802.1w) provides backwards compatibility with legacy
STP. RSTP provides
faster convergence and exchanges information with neighboring
switches to quickly transition to forwarding mode without
creating loops. &os; supports RSTP and
STP as operating modes, with
RSTP being the default mode.STP can be enabled on member interfaces
using &man.ifconfig.8;. For a bridge with
fxp0 and fxp1 as the
current interfaces, enable STP with:&prompt.root; ifconfig bridge0 stp fxp0 stp fxp1
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether d6:cf:d5:a0:94:6d
id 00:01:02:4b:d4:50 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
root id 00:01:02:4b:d4:50 priority 32768 ifcost 0 port 0
member: fxp0 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
port 3 priority 128 path cost 200000 proto rstp
role designated state forwarding
member: fxp1 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
port 4 priority 128 path cost 200000 proto rstp
role designated state forwardingThis bridge has a spanning tree ID of
00:01:02:4b:d4:50 and a priority of
32768. As the root id
is the same, it indicates that this is the root bridge for the
tree.Another bridge on the network also has
STP enabled:bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 96:3d:4b:f1:79:7a
id 00:13:d4:9a:06:7a priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
root id 00:01:02:4b:d4:50 priority 32768 ifcost 400000 port 4
member: fxp0 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
port 4 priority 128 path cost 200000 proto rstp
role root state forwarding
member: fxp1 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
port 5 priority 128 path cost 200000 proto rstp
role designated state forwardingThe line root id 00:01:02:4b:d4:50 priority 32768
ifcost 400000 port 4 shows that the root bridge is
00:01:02:4b:d4:50 and has a path cost of
400000 from this bridge. The path to the
root bridge is via port 4 which is
fxp0.Bridge Interface ParametersSeveral ifconfig parameters are unique
to bridge interfaces. This section summarizes some common
uses for these parameters. The complete list of available
parameters is described in &man.ifconfig.8;.privateA private interface does not forward any traffic to
any other port that is also designated as a private
interface. The traffic is blocked unconditionally so no
Ethernet frames will be forwarded, including
ARP packets. If traffic needs to be
selectively blocked, a firewall should be used
instead.spanA span port transmits a copy of every Ethernet frame
received by the bridge. The number of span ports
configured on a bridge is unlimited, but if an
interface is designated as a span port, it cannot also
be used as a regular bridge port. This is most useful
for snooping a bridged network passively on another host
connected to one of the span ports of the bridge. For
example, to send a copy of all frames out the interface
named fxp4:&prompt.root; ifconfig bridge0 span fxp4stickyIf a bridge member interface is marked as sticky,
dynamically learned address entries are treated at
static entries in the forwarding cache. Sticky entries
are never aged out of the cache or replaced, even if the
address is seen on a different interface. This gives
the benefit of static address entries without the need
to pre-populate the forwarding table. Clients learned
on a particular segment of the bridge can not roam to
another segment.An example of using sticky addresses is to combine
the bridge with VLANs in order to
isolate customer networks without wasting
IP address space. Consider that
CustomerA
is on vlan100, CustomerB is on
vlan101, and the bridge has the
address 192.168.0.1:&prompt.root; ifconfig bridge0 addm vlan100 sticky vlan100 addm vlan101 sticky vlan101
&prompt.root; ifconfig bridge0 inet 192.168.0.1/24In this example, both clients see 192.168.0.1 as their
default gateway. Since the bridge cache is sticky, one
host can not spoof the MAC address of
the other customer in order to intercept their
traffic.Any communication between the
VLANs can be blocked using a firewall
or, as seen in this example, private interfaces:&prompt.root; ifconfig bridge0 private vlan100 private vlan101The customers are completely isolated from each
other and the full /24 address range can be
allocated without subnetting.The number of unique source MAC
addresses behind an interface can be limited. Once the
limit is reached, packets with unknown source addresses
are dropped until an existing host cache entry expires
or is removed.The following example sets the maximum number of
Ethernet devices for CustomerA on
vlan100 to 10:&prompt.root; ifconfig bridge0 ifmaxaddr vlan100 10Bridge interfaces also support monitor mode, where the
packets are discarded after &man.bpf.4; processing and are not
processed or forwarded further. This can be used to
multiplex the input of two or more interfaces into a single
&man.bpf.4; stream. This is useful for reconstructing the
traffic for network taps that transmit the RX/TX signals out
through two separate interfaces. For example, to read the
input from four network interfaces as one stream:&prompt.root; ifconfig bridge0 addm fxp0 addm fxp1 addm fxp2 addm fxp3 monitor up
&prompt.root; tcpdump -i bridge0SNMP MonitoringThe bridge interface and STP
parameters can be monitored via &man.bsnmpd.1; which is
included in the &os; base system. The exported bridge
MIBs conform to IETF
standards so any SNMP client or monitoring
package can be used to retrieve the data.To enable monitoring on the bridge, uncomment this line in
/etc/snmp.config by removing the
beginning # symbol:begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so"Other configuration settings, such as community names and
access lists, may need to be modified in this file. See
&man.bsnmpd.1; and &man.snmp.bridge.3; for more information.
Once these edits are saved, add this line to
/etc/rc.conf:bsnmpd_enable="YES"Then, start &man.bsnmpd.1;:&prompt.root; service bsnmpd startThe following examples use the
Net-SNMP software
(net-mgmt/net-snmp) to query a bridge
from a client system. The
net-mgmt/bsnmptools port can also be used.
From the SNMP client which is running
Net-SNMP, add the following lines
to $HOME/.snmp/snmp.conf in order to
import the bridge MIB definitions:mibdirs +/usr/share/snmp/mibs
mibs +BRIDGE-MIB:RSTP-MIB:BEGEMOT-MIB:BEGEMOT-BRIDGE-MIBTo monitor a single bridge using the IETF BRIDGE-MIB
(RFC4188):&prompt.user; snmpwalk -v 2c -c public bridge1.example.com mib-2.dot1dBridge
BRIDGE-MIB::dot1dBaseBridgeAddress.0 = STRING: 66:fb:9b:6e:5c:44
BRIDGE-MIB::dot1dBaseNumPorts.0 = INTEGER: 1 ports
BRIDGE-MIB::dot1dStpTimeSinceTopologyChange.0 = Timeticks: (189959) 0:31:39.59 centi-seconds
BRIDGE-MIB::dot1dStpTopChanges.0 = Counter32: 2
BRIDGE-MIB::dot1dStpDesignatedRoot.0 = Hex-STRING: 80 00 00 01 02 4B D4 50
...
BRIDGE-MIB::dot1dStpPortState.3 = INTEGER: forwarding(5)
BRIDGE-MIB::dot1dStpPortEnable.3 = INTEGER: enabled(1)
BRIDGE-MIB::dot1dStpPortPathCost.3 = INTEGER: 200000
BRIDGE-MIB::dot1dStpPortDesignatedRoot.3 = Hex-STRING: 80 00 00 01 02 4B D4 50
BRIDGE-MIB::dot1dStpPortDesignatedCost.3 = INTEGER: 0
BRIDGE-MIB::dot1dStpPortDesignatedBridge.3 = Hex-STRING: 80 00 00 01 02 4B D4 50
BRIDGE-MIB::dot1dStpPortDesignatedPort.3 = Hex-STRING: 03 80
BRIDGE-MIB::dot1dStpPortForwardTransitions.3 = Counter32: 1
RSTP-MIB::dot1dStpVersion.0 = INTEGER: rstp(2)The dot1dStpTopChanges.0 value is two,
indicating that the STP bridge topology has
changed twice. A topology change means that one or more links
in the network have changed or failed and a new tree has been
calculated. The
dot1dStpTimeSinceTopologyChange.0 value
will show when this happened.To monitor multiple bridge interfaces, the private
BEGEMOT-BRIDGE-MIB can be used:&prompt.user; snmpwalk -v 2c -c public bridge1.example.com
enterprises.fokus.begemot.begemotBridge
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseName."bridge0" = STRING: bridge0
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseName."bridge2" = STRING: bridge2
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseAddress."bridge0" = STRING: e:ce:3b:5a:9e:13
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseAddress."bridge2" = STRING: 12:5e:4d:74:d:fc
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseNumPorts."bridge0" = INTEGER: 1
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseNumPorts."bridge2" = INTEGER: 1
...
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTimeSinceTopologyChange."bridge0" = Timeticks: (116927) 0:19:29.27 centi-seconds
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTimeSinceTopologyChange."bridge2" = Timeticks: (82773) 0:13:47.73 centi-seconds
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTopChanges."bridge0" = Counter32: 1
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTopChanges."bridge2" = Counter32: 1
BEGEMOT-BRIDGE-MIB::begemotBridgeStpDesignatedRoot."bridge0" = Hex-STRING: 80 00 00 40 95 30 5E 31
BEGEMOT-BRIDGE-MIB::begemotBridgeStpDesignatedRoot."bridge2" = Hex-STRING: 80 00 00 50 8B B8 C6 A9To change the bridge interface being monitored via the
mib-2.dot1dBridge subtree:&prompt.user; snmpset -v 2c -c private bridge1.example.com
BEGEMOT-BRIDGE-MIB::begemotBridgeDefaultBridgeIf.0 s bridge2Link Aggregation and FailoverAndrewThompsonWritten by laggfailoverFECLACPloadbalanceroundrobin&os; provides the &man.lagg.4; interface which can be used
to aggregate multiple network interfaces into one virtual
interface in order to provide failover and link aggregation.
Failover allows traffic to continue to flow as long as at least
one aggregated network interface has an established link. Link
aggregation works best on switches which support
LACP, as this protocol distributes traffic
bi-directionally while responding to the failure of individual
links.The aggregation protocols supported by the lagg interface
determine which ports are used for outgoing traffic and whether
or not a specific port accepts incoming traffic. The following
protocols are supported by &man.lagg.4;:failoverThis mode sends and receives traffic only through
the master port. If the master port becomes
unavailable, the next active port is used. The first
interface added to the virtual interface is the master
port and all subsequently added interfaces are used as
failover devices. If failover to a non-master port
occurs, the original port becomes master once it
becomes available again.fec / loadbalance&cisco; Fast ðerchannel; (FEC)
is found on older &cisco; switches. It provides a
static setup and does not negotiate aggregation with the
peer or exchange frames to monitor the link. If the
switch supports LACP, that should be
used instead.lacpThe &ieee; 802.3ad Link Aggregation Control Protocol
(LACP) negotiates a set of
aggregable links with the peer into one or more Link
Aggregated Groups (LAGs). Each
LAG is composed of ports of the same
speed, set to full-duplex operation, and traffic is
balanced across the ports in the
LAG with the greatest total speed.
Typically, there is only one LAG
which contains all the ports. In the event of changes
in physical connectivity,
LACP will quickly converge to a new
configuration.LACP balances outgoing traffic
across the active ports based on hashed protocol header
information and accepts incoming traffic from any active
port. The hash includes the Ethernet source and
destination address and, if available, the
VLAN tag, and the
IPv4 or IPv6
source and destination address.roundrobinThis mode distributes outgoing traffic using a
round-robin scheduler through all active ports and
accepts incoming traffic from any active port. Since
this mode violates Ethernet frame ordering, it should be
used with caution.Configuration ExamplesThis section demonstrates how to configure a &cisco;
switch and a &os; system for LACP load
balancing. It then shows how to configure two Ethernet
interfaces in failover mode as well as how to configure
failover mode between an Ethernet and a wireless
interface.LACP Aggregation with a &cisco;
SwitchThis example connects two &man.fxp.4; Ethernet
interfaces on a &os; machine to the first two Ethernet ports
on a &cisco; switch as a single load balanced and fault
tolerant link. More interfaces can be added to increase
throughput and fault tolerance. Replace the names of the
&cisco; ports, Ethernet devices, channel group number, and
IP address shown in the example to match
the local configuration.Frame ordering is mandatory on Ethernet links and any
traffic between two stations always flows over the same
physical link, limiting the maximum speed to that of one
interface. The transmit algorithm attempts to use as much
information as it can to distinguish different traffic flows
and balance the flows across the available
interfaces.On the &cisco; switch, add the
FastEthernet0/1 and
FastEthernet0/2 interfaces to
channel group 1:interface FastEthernet0/1
channel-group 1 mode active
channel-protocol lacp
!
interface FastEthernet0/2
channel-group 1 mode active
channel-protocol lacpOn the &os; system, create the &man.lagg.4; interface
using the physical interfaces
fxp0 and
fxp1 and bring the interfaces up
with an IP address of
10.0.0.3/24:&prompt.root; ifconfig fxp0 up
&prompt.root; ifconfig fxp1 up
&prompt.root; ifconfig lagg0 create
&prompt.root; ifconfig lagg0 up laggproto lacp laggport fxp0 laggport fxp110.0.0.3/24Next, verify the status of the virtual interface:&prompt.root; ifconfig lagg0
lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8<VLAN_MTU>
ether 00:05:5d:71:8d:b8
media: Ethernet autoselect
status: active
laggproto lacp
laggport: fxp1 flags=1c<ACTIVE,COLLECTING,DISTRIBUTING>
laggport: fxp0 flags=1c<ACTIVE,COLLECTING,DISTRIBUTING>Ports
marked as ACTIVE are part of the
LAG that has been negotiated with the
remote switch. Traffic will be transmitted and received
through these active ports. Add to the
above command to view the LAG
identifiers.To see the port status on the &cisco; switch:switch# show lacp neighbor
Flags: S - Device is requesting Slow LACPDUs
F - Device is requesting Fast LACPDUs
A - Device is in Active mode P - Device is in Passive mode
Channel group 1 neighbors
Partner's information:
LACP port Oper Port Port
Port Flags Priority Dev ID Age Key Number State
Fa0/1 SA 32768 0005.5d71.8db8 29s 0x146 0x3 0x3D
Fa0/2 SA 32768 0005.5d71.8db8 29s 0x146 0x4 0x3DFor more detail, type show lacp neighbor
detail.To retain this configuration across reboots, add the
following entries to
/etc/rc.conf on the &os; system:ifconfig_fxp0="up"
ifconfig_fxp1="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport fxp0 laggport fxp110.0.0.3/24"Failover ModeFailover mode can be used to switch over to a secondary
interface if the link is lost on the master interface. To
configure failover, make sure that the underlying physical
interfaces are up, then create the &man.lagg.4; interface.
In this example, fxp0 is the
master interface, fxp1 is the
secondary interface, and the virtual interface is assigned
an IP address of
10.0.0.15/24:&prompt.root; ifconfig fxp0 up
&prompt.root; ifconfig fxp1 up
&prompt.root; ifconfig lagg0 create
&prompt.root; ifconfig lagg0 up laggproto failover laggport fxp0 laggport fxp110.0.0.15/24The virtual interface should look something like
this:&prompt.root; ifconfig lagg0
lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8<VLAN_MTU>
ether 00:05:5d:71:8d:b8
inet 10.0.0.15 netmask 0xffffff00 broadcast 10.0.0.255
media: Ethernet autoselect
status: active
laggproto failover
laggport: fxp1 flags=0<>
laggport: fxp0 flags=5<MASTER,ACTIVE>Traffic will be transmitted and received on
fxp0. If the link is lost on
fxp0,
fxp1 will become the active link.
If the link is restored on the master interface, it will
once again become the active link.To retain this configuration across reboots, add the
following entries to
/etc/rc.conf:ifconfig_fxp0="up"
ifconfig_fxp1="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport fxp0 laggport fxp110.0.0.15/24"Failover Mode Between Ethernet and Wireless
InterfacesFor laptop users, it is usually desirable to configure
the wireless device as a secondary which is only used when
the Ethernet connection is not available. With
&man.lagg.4;, it is possible to configure a failover which
prefers the Ethernet connection for both performance and
security reasons, while maintaining the ability to transfer
data over the wireless connection.This is achieved by overriding the physical wireless
interface's MAC address with that of the
Ethernet interface.In this example, the Ethernet interface,
bge0, is the master and the
wireless interface, wlan0, is
the failover. The wlan0 device
was created from iwn0 wireless
interface, which will be configured with the
MAC address of the Ethernet interface.
First, determine the MAC address of the
Ethernet interface:&prompt.root; ifconfig bge0
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=19b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4>
ether 00:21:70:da:ae:37
inet6 fe80::221:70ff:feda:ae37%bge0 prefixlen 64 scopeid 0x2
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (1000baseT <full-duplex>)
status: activeReplace bge0 to match the
system's Ethernet interface name. The
ether line will contain the
MAC address of the specified interface.
Now, change the MAC address of the
underlying wireless interface:&prompt.root; ifconfig iwn0 ether 00:21:70:da:ae:37Bring the wireless interface up, but do not set an
IP address:&prompt.root; ifconfig wlan0 create wlandev iwn0 ssid my_router upMake sure the bge0 interface
is up, then create the &man.lagg.4; interface with
bge0 as master with failover to
wlan0:&prompt.root; ifconfig bge0 up
&prompt.root; ifconfig lagg0 create
&prompt.root; ifconfig lagg0 up laggproto failover laggport bge0 laggport wlan0The virtual interface should look something like
this:&prompt.root; ifconfig lagg0
lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8<VLAN_MTU>
ether 00:21:70:da:ae:37
media: Ethernet autoselect
status: active
laggproto failover
laggport: wlan0 flags=0<>
laggport: bge0 flags=5<MASTER,ACTIVE>Then, start the DHCP client to
obtain an IP address:&prompt.root; dhclient lagg0To retain this configuration across reboots, add the
following entries to
/etc/rc.conf:ifconfig_bge0="up"
ifconfig_iwn0="ether 00:21:70:da:ae:37"
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport bge0 laggport wlan0 DHCP"Diskless Operation with PXEJean-FrançoisDockèsUpdated by AlexDupreReorganized and enhanced by diskless workstationdiskless operationThe &intel; Preboot eXecution Environment
(PXE) allows an operating system to boot over
the network. For example, a &os; system can boot over the
network and operate without a local disk, using file systems
mounted from an NFS server.
PXE support is usually available in the
BIOS. To use PXE when the
machine starts, select the Boot from network
option in the BIOS setup or type a function
key during system initialization.In order to provide the files needed for an operating system
to boot over the network, a PXE setup also
requires properly configured DHCP,
TFTP, and NFS servers,
where:Initial parameters, such as an IP
address, executable boot filename and location, server name,
and root path are obtained from the
DHCP server.The operating system loader file is booted using
TFTP.The file systems are loaded using
NFS.When a computer PXE boots, it receives
information over DHCP about where to obtain
the initial boot loader file. After the host computer receives
this information, it downloads the boot loader via
TFTP and then executes the boot loader. In
&os;, the boot loader file is
/boot/pxeboot. After
/boot/pxeboot executes, the &os; kernel is
loaded and the rest of the &os; bootup sequence proceeds, as
described in .This section describes how to configure these services on a
&os; system so that other systems can PXE
boot into &os;. Refer to &man.diskless.8; for more
information.As described, the system providing these services is
insecure. It should live in a protected area of a network and
be untrusted by other hosts.Setting Up the PXE
EnvironmentCraigRodrigues
rodrigc@FreeBSD.org
Written by The steps shown in this section configure the built-in
NFS and TFTP servers.
The next section demonstrates how to install and configure the
DHCP server. In this example, the
directory which will contain the files used by
PXE users is
/b/tftpboot/FreeBSD/install. It is
important that this directory exists and that the same
directory name is set in both
/etc/inetd.conf and
/usr/local/etc/dhcpd.conf.Create the root directory which will contain a &os;
installation to be NFS mounted:&prompt.root; export NFSROOTDIR=/b/tftpboot/FreeBSD/install
&prompt.root; mkdir -p ${NFSROOTDIR}Enable the NFS server by adding
this line to /etc/rc.conf:nfs_server_enable="YES"Export the diskless root directory via
NFS by adding the following to
/etc/exports:/b -ro -alldirsStart the NFS server:&prompt.root; service nfsd startEnable &man.inetd.8; by adding the following line to
/etc/rc.conf:inetd_enable="YES"Uncomment the following line in
/etc/inetd.conf by making sure it
does not start with a # symbol:tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /b/tftpbootSome PXE versions require the
TCP version of
TFTP. In this case, uncomment the
second tftp line which contains
stream tcp.Start &man.inetd.8;:&prompt.root; service inetd startRebuild the &os; kernel and userland (refer to for more detailed
instructions):&prompt.root; cd /usr/src
&prompt.root; make buildworld
&prompt.root; make buildkernelInstall &os; into the directory mounted over
NFS:&prompt.root; make installworld DESTDIR=${NFSROOTDIR}
&prompt.root; make installkernel DESTDIR=${NFSROOTDIR}
&prompt.root; make distribution DESTDIR=${NFSROOTDIR}Test that the TFTP server works and
can download the boot loader which will be obtained via
PXE:&prompt.root; tftp localhost
tftp> get FreeBSD/install/boot/pxeboot
Received 264951 bytes in 0.1 secondsEdit ${NFSROOTDIR}/etc/fstab and
create an entry to mount the root file system over
NFS:# Device Mountpoint FSType Options Dump Pass
myhost.example.com:/b/tftpboot/FreeBSD/install / nfs ro 0 0Replace myhost.example.com
with the hostname or IP address of the
NFS server. In this example, the root
file system is mounted read-only in order to prevent
NFS clients from potentially deleting
the contents of the root file system.Set the root password in the PXE
environment for client machines which are
PXE booting :&prompt.root; chroot ${NFSROOTDIR}
&prompt.root; passwdIf needed, enable &man.ssh.1; root logins for client
machines which are PXE booting by
editing
${NFSROOTDIR}/etc/ssh/sshd_config and
enabling PermitRootLogin. This option
is documented in &man.sshd.config.5;.Perform any other needed customizations of the
PXE environment in
${NFSROOTDIR}. These customizations
could include things like installing packages or editing
the password file with &man.vipw.8;.When booting from an NFS root volume,
/etc/rc detects the
NFS boot and runs
/etc/rc.initdiskless. In this case,
/etc and /var need
to be memory backed file systems so that these directories are
writable but the NFS root directory is
read-only:&prompt.root; chroot ${NFSROOTDIR}
&prompt.root; mkdir -p conf/base
&prompt.root; tar -c -v -f conf/base/etc.cpio.gz --format cpio --gzip etc
&prompt.root; tar -c -v -f conf/base/var.cpio.gz --format cpio --gzip varWhen the system boots, memory file systems for
/etc and /var will
be created and mounted and the contents of the
cpio.gz files will be copied into
them.Configuring the DHCP ServerDHCPdiskless operationThe DHCP server does not need to be the
same machine as the TFTP and
NFS server, but it needs to be accessible
in the network.DHCP is not part of the &os; base
system but can be installed using the
net/isc-dhcp42-server port or
package.Once installed, edit the configuration file,
/usr/local/etc/dhcpd.conf. Configure
the next-server,
filename, and
root-path settings as seen in this
example:subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.3 ;
option subnet-mask 255.255.255.0 ;
option routers 192.168.0.1 ;
option broadcast-address 192.168.0.255 ;
option domain-name-servers 192.168.35.35, 192.168.35.36 ;
option domain-name "example.com";
# IP address of TFTP server
next-server 192.168.0.1 ;
# path of boot loader obtained via tftp
filename "FreeBSD/install/boot/pxeboot" ;
# pxeboot boot loader will try to NFS mount this directory for root FS
option root-path "192.168.0.1:/b/tftpboot/FreeBSD/install/" ;
}The next-server directive is used to
specify the IP address of the
TFTP server.The filename directive defines the path
to /boot/pxeboot. A relative filename is
used, meaning that /b/tftpboot is not
included in the path.The root-path option defines the path
to the NFS root file system.Once the edits are saved, enable DHCP at
boot time by adding the following line to
/etc/rc.conf:dhcpd_enable="YES"Then start the DHCP service:&prompt.root; service isc-dhcpd startDebugging PXE ProblemsOnce all of the services are configured and started,
PXE clients should be able to
automatically load &os; over the network. If a particular
client is unable to connect, when that client machine boots
up, enter the BIOS configuration menu and
confirm that it is set to boot from the network.This section describes some troubleshooting tips for
isolating the source of the configuration problem should no
clients be able to PXE boot.Use the net/wireshark package or
port to debug the network traffic involved during the
PXE booting process, which is
illustrated in the diagram below.PXE Booting Process with
NFS Root MountClient broadcasts a
DHCPDISCOVER message.The DHCP server responds
with the IP address,
next-server,
filename, and
root-path values.The client sends a TFTP
request to next-server,
asking to retrieve
filename.The TFTP server responds
and sends filename to
client.The client executes
filename, which is
&man.pxeboot.8;, which then loads the kernel.
When the kernel executes, the root file system
specified by root-path is
mounted over NFS.On the
TFTP server, read
- /var/log/xferlog to ensure that the
- pxeboot file is being retrieved from
+ /var/log/xferlog to ensure that
+ pxeboot is being retrieved from
the correct location. To test this example
configuration:&prompt.root; tftp 192.168.0.1
tftp> get FreeBSD/install/boot/pxeboot
Received 264951 bytes in 0.1 secondsThe BUGS sections in &man.tftpd.8;
and &man.tftp.1; document some limitations with
TFTP.Make sure that the root file system can be mounted
via NFS. To test this example
configuration:&prompt.root; mount -t nfs 192.168.0.1:/b/tftpboot/FreeBSD/install /mntIPv6AaronKaplanOriginally Written by TomRhodesRestructured and Added by BradDavisExtended by IPv6 is the new version of the well known
IP protocol, also known as
IPv4. IPv6 provides
several advantages over IPv4 as well as many
new features:Its 128-bit address space allows for
340,282,366,920,938,463,463,374,607,431,768,211,456
addresses. This addresses the IPv4
address shortage and eventual IPv4
address exhaustion.Routers only store network aggregation addresses in
their routing tables, thus reducing the average space of a
routing table to 8192 entries. This addresses the
scalability issues associated with IPv4,
which required every allocated block of
IPv4 addresses to be exchanged between
Internet routers, causing their routing tables to become too
large to allow efficient routing.Address autoconfiguration (RFC2462).Mandatory multicast addresses.Built-in IPsec (IP
security).Simplified header structure.Support for mobile IP.IPv6-to-IPv4
transition mechanisms.&os; includes the http://www.kame.net/
IPv6 reference implementation and comes
with everything needed to use IPv6. This
section focuses on getting IPv6 configured
and running.Background on IPv6 AddressesThere are three different types of IPv6
addresses:UnicastA packet sent to a unicast address arrives at the
interface belonging to the address.AnycastThese addresses are syntactically indistinguishable
from unicast addresses but they address a group of
interfaces. The packet destined for an anycast address
will arrive at the nearest router interface. Anycast
addresses are only used by routers.MulticastThese addresses identify a group of interfaces. A
packet destined for a multicast address will arrive at
all interfaces belonging to the multicast group. The
IPv4 broadcast address, usually
xxx.xxx.xxx.255, is
expressed by multicast addresses in
IPv6.When reading an IPv6 address, the
canonical form is represented as
x:x:x:x:x:x:x:x, where each
x represents a 16 bit hex value. An
example is
FEBC:A574:382B:23C1:AA49:4592:4EFE:9982.Often, an address will have long substrings of all zeros.
A :: (double colon) can be used to replace
one substring per address. Also, up to three leading
0s per hex value can be omitted. For
example, fe80::1 corresponds to the
canonical form
fe80:0000:0000:0000:0000:0000:0000:0001.A third form is to write the last 32 bits using the well
known IPv4 notation. For example,
2002::10.0.0.1 corresponds to the
hexadecimal canonical representation
2002:0000:0000:0000:0000:0000:0a00:0001,
which in turn is equivalent to
2002::a00:1.To view a &os; system's IPv6 address,
use &man.ifconfig.8;:&prompt.root; ifconfigrl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255
inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1
ether 00:00:21:03:08:e1
media: Ethernet autoselect (100baseTX )
status: activeIn this example,
fe80::200:21ff:fe03:8e1%rl0 is an
auto-configured link-local address which was automatically
generated from the MAC address.Some IPv6 addresses are reserved. A
summary of these reserved addresses is seen in :
Reserved IPv6 AddressesIPv6 addressPrefixlength (Bits)DescriptionNotes::128 bitsunspecifiedEquivalent to 0.0.0.0 in
IPv4.::1128 bitsloopback addressEquivalent to 127.0.0.1 in
IPv4.::00:xx:xx:xx:xx96 bitsembedded IPv4The lower 32 bits are the compatible
IPv4 address.::ff:xx:xx:xx:xx96 bitsIPv4 mapped
IPv6 addressThe lower 32 bits are the IPv4
address for hosts which do not support
IPv6.fe80::/1010 bitslink-localEquivalent to 169.254.0.0/16 in
IPv4.fc00::/77 bitsunique-localUnique local addresses are intended for local
communication and are only routable within a set of
cooperating sites.ff00::8 bitsmulticast2000::-3fff:: 3 bitsglobal unicastAll global unicast addresses are assigned from
this pool. The first 3 bits are
001.
For further information on the structure of
IPv6 addresses, refer to RFC3513.Configuring IPv6To configure a &os; system as an IPv6
client, add these two lines to
rc.conf:ifconfig_em0_ipv6="inet6 accept_rtadv"
rtsold_enable="YES"The first line enables the specified interface to receive
router solicitation messages. The second line enables the
router solicitation daemon, &man.rtsol.8;.For &os; 8.x, add a third
line:ipv6_enable="YES"If the interface needs a statically assigned
IPv6 address, add an entry to specify the
static address and associated prefix length:ifconfig_fxp0_ipv6="inet6 2001:db8:4672:6565:2026:5043:2d42:5344 prefixlen 64"On a &os; 8.x system, that
line uses this format instead:ipv6_ifconfig_fxp0="2001:db8:4672:6565:2026:5043:2d42:5344"To assign a default router, specify its address:ipv6_defaultrouter="2001:db8:4672:6565::1"Connecting to a ProviderIn order to connect to other IPv6
networks, one must have a provider or a tunnel that supports
IPv6:Contact an Internet Service Provider to see if they
offer IPv6.SixXS
offers tunnels with end-points all around the
globe.Hurricane
Electric offers tunnels with end-points all
around the globe.Install the net/freenet6 package or
port for a dial-up connection.This section demonstrates how to take the directions from
a tunnel provider and convert them into
/etc/rc.conf settings that will persist
through reboots.The first /etc/rc.conf entry creates
the generic tunneling interface
gif0:gif_interfaces="gif0"Next, configure that interface with the
IPv4 addresses of the local and remote
endpoints. Replace MY_IPv4_ADDR
and REMOTE_IPv4_ADDR with the
actual IPv4 addresses:gifconfig_gif0="MY_IPv4_ADDR REMOTE_IPv4_ADDR"To apply the IPv6 address that has been
assigned for use as the IPv6 tunnel
endpoint, add this line, replacing
MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR
with the assigned address:ifconfig_gif0_ipv6="inet6 MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR"For &os; 8.x, that line
should instead use this format:ipv6_ifconfig_gif0="MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR"Then, set the default route for the other side of the
IPv6 tunnel. Replace
MY_IPv6_REMOTE_TUNNEL_ENDPOINT_ADDR
with the default gateway address assigned by the
provider:ipv6_defaultrouter="MY_IPv6_REMOTE_TUNNEL_ENDPOINT_ADDR"If the &os; system will route IPv6
packets between the rest of the network and the world, enable
the gateway using this line:ipv6_gateway_enable="YES"Router Advertisement and Host Auto ConfigurationThis section demonstrates how to setup &man.rtadvd.8; to
advertise the IPv6 default route.To enable &man.rtadvd.8;, add the following to
/etc/rc.conf:rtadvd_enable="YES"It is important to specify the interface on which to
do IPv6 router solicitation. For example,
to tell &man.rtadvd.8; to use
fxp0:rtadvd_interfaces="fxp0"Next, create the configuration file,
/etc/rtadvd.conf as seen in this
example:fxp0:\
:addrs#1:addr="2001:471:1f11:246::":prefixlen#64:tc=ether:Replace fxp0 with the interface
to be used and 2001:471:1f11:246::
with the prefix of the allocation.For a dedicated /64 subnet, nothing else needs
to be changed. Otherwise, change the
prefixlen# to the correct value.IPv6 and IPv6
Address MappingWhen IPv6 is enabled on a server, there
may be a need to enable IPv4 mapped
IPv6 address communication. This
compatibility option allows for IPv4
addresses to be represented as IPv6
addresses. Permitting IPv6 applications
to communicate with IPv4 and vice versa
may be a security issue.This option may not be required in most cases and is
available only for compatibility. This option will allow
IPv6-only applications to work with
IPv4 in a dual stack environment. This
is most useful for third party applications which may not
support an IPv6-only environment. To
enable this feature,
add the following to /etc/rc.conf:ipv6_ipv4mapping="YES"Reviewing the information in RFC 3493,
section 3.6 and 3.7 as well as RFC 4038
section 4.2 may be useful to some adminstrators.Common Address Redundancy Protocol
(CARP)TomRhodesContributed by AllanJudeUpdated by CARPCommon Address Redundancy ProtocolThe Common Address Redundancy Protocol
(CARP) allows multiple hosts to share the
same IP address and Virtual Host ID
(VHID) in order to provide high
availability for one or more services. This means
that one or more hosts can fail, and the other hosts will
transparently take over so that users do not see a service
failure.In addition to the shared IP address,
each host has its own IP address for
management and configuration. All of the machines that share an
IP address have the same
VHID. The VHID for each
virtual IP address must be unique across the
broadcast domain of the network interface.High availability using CARP is built
into &os;, though the steps to configure it vary slightly
depending upon the &os; version. This section provides the same
example configuration for versions before and equal to or after
&os; 10.This example configures failover support with three hosts,
all with unique IP addresses, but providing
the same web content. It has two different masters named
hosta.example.org and
hostb.example.org, with a shared backup
named hostc.example.org.These machines are load balanced with a Round Robin
DNS configuration. The master and backup
machines are configured identically except for their hostnames
and management IP addresses. These servers
must have the same configuration and run the same services.
When the failover occurs, requests to the service on the shared
IP address can only be answered correctly if
the backup server has access to the same content. The backup
machine has two additional CARP interfaces,
one for each of the master content server's
IP addresses. When a failure occurs, the
backup server will pick up the failed master machine's
IP address.Using CARP on &os; 10 and
LaterEnable boot-time support for CARP by
adding an entry for the carp.ko kernel
module in /boot/loader.conf:carp_load="YES"To load the module now without rebooting:&prompt.root; kldload carpFor users who prefer to use a custom kernel, include the
following line in the custom kernel configuration file and
compile the kernel as described in :device carpThe hostname, management IP address and
subnet mask, shared IP address, and
VHID are all set by adding entries to
/etc/rc.conf. This example is for
hosta.example.org:hostname="hosta.example.org"
ifconfig_em0="inet 192.168.1.3 netmask 255.255.255.0"
ifconfig_em0_alias0="vhid 1 pass testpass alias 192.168.1.50/32"The next set of entries are for
hostb.example.org. Since it
represents a second master, it uses a different shared
IP address and VHID.
However, the passwords specified with
must be identical as CARP will only listen
to and accept advertisements from machines with the correct
password.hostname="hostb.example.org"
ifconfig_em0="inet 192.168.1.4 netmask 255.255.255.0"
ifconfig_em0_alias0="vhid 2 pass testpass alias 192.168.1.51/32"The third machine,
hostc.example.org, is configured to
handle failover from either master. This machine is
configured with two CARP
VHIDs, one to handle the virtual
IP address for each of the master hosts.
The CARP advertising skew,
, is set to ensure that the backup
host advertises later than the master, since
controls the order of precedence when
there are multiple backup servers.hostname="hostc.example.org"
ifconfig_em0="inet 192.168.1.5 netmask 255.255.255.0"
ifconfig_em0_alias0="vhid 1 advskew 100 pass testpass alias 192.168.1.50/32"
ifconfig_em0_alias1="vhid 2 advskew 100 pass testpass alias 192.168.1.51/32"Having two CARP
VHIDs configured means that
hostc.example.org will notice if
either of the master servers becomes unavailable. If a master
fails to advertise before the backup server, the backup server
will pick up the shared IP address until
the master becomes available again.Preemption is disabled by default. If preemption has
been enabled, hostc.example.org
might not release the virtual IP address
back to the original master server. The administrator
can force the backup server to return the
IP address to the master with the
command:&prompt.root; ifconfig em0 vhid 1 state backupOnce the configuration is complete, either restart
networking or reboot each system. High availability is now
enabled.CARP functionality can be controlled
via several &man.sysctl.8; variables documented in the
&man.carp.4; manual pages. Other actions can be triggered
from CARP events by using
&man.devd.8;.Using CARP on &os; 9 and
EarlierThe configuration for these versions of &os; is similar to
the one described in the previous section, except that a
CARP device must first be created and
referred to in the configuration.Enable boot-time support for CARP by
loading the if_carp.ko kernel module in
/boot/loader.conf:if_carp_load="YES"To load the module now without rebooting:&prompt.root; kldload carpFor users who prefer to use a custom kernel, include the
following line in the custom kernel configuration file and
compile the kernel as described in :device carpNext, on each host, create a CARP
device:&prompt.root; ifconfig carp0 createSet the hostname, management IP
address, the shared IP address, and
VHID by adding the required lines to
/etc/rc.conf. Since a virtual
CARP device is used instead of an alias,
the actual subnet mask of /24 is used
instead of /32. Here are the entries for
hosta.example.org:hostname="hosta.example.org"
ifconfig_fxp0="inet 192.168.1.3 netmask 255.255.255.0"
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 pass testpass192.168.1.50/24"On hostb.example.org:hostname="hostb.example.org"
ifconfig_fxp0="inet 192.168.1.4 netmask 255.255.255.0"
cloned_interfaces="carp0"
ifconfig_carp0="vhid 2 pass testpass192.168.1.51/24"The third machine,
hostc.example.org, is configured to
handle failover from either of the master hosts:hostname="hostc.example.org"
ifconfig_fxp0="inet 192.168.1.5 netmask 255.255.255.0"
cloned_interfaces="carp0 carp1"
ifconfig_carp0="vhid 1 advskew 100 pass testpass192.168.1.50/24"
ifconfig_carp1="vhid 2 advskew 100 pass testpass192.168.1.51/24"Preemption is disabled in the GENERIC &os; kernel. If
preemption has been enabled with a custom kernel,
hostc.example.org may not release
the IP address back to the original
content server. The administrator can force the backup
server to return the IP address to the
master with the command:&prompt.root; ifconfig carp0 down && ifconfig carp0 upThis should be done on the carp
interface which corresponds to the correct host.Once the configuration is complete, either restart
networking or reboot each system. High availability is now
enabled.
Index: head/en_US.ISO8859-1/books/handbook/bsdinstall/chapter.xml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/bsdinstall/chapter.xml (revision 46060)
+++ head/en_US.ISO8859-1/books/handbook/bsdinstall/chapter.xml (revision 46061)
@@ -1,2743 +1,2743 @@
Installing &os; 9.X and
LaterJimMockRestructured, reorganized, and parts rewritten
by GavinAtkinsonUpdated for bsdinstall by WarrenBlockAllanJudeUpdated for root-on-ZFS by SynopsisinstallationBeginning with &os; 9.0-RELEASE, &os; provides an easy
to use, text-based installation
program named bsdinstall. This
chapter describes how to install &os; using
bsdinstall. The use of
sysinstall, which is the installation
program used by &os; 8.x, is covered in .In general, the installation instructions in this chapter
are written for the &i386; and AMD64
architectures. Where applicable, instructions specific to other
platforms will be listed. There may be minor differences
between the installer and what is shown here, so use this
chapter as a general guide rather than as a set of literal
instructions.Users who prefer to install &os; using a graphical
installer may be interested in
pc-sysinstall, the installer used
by the PC-BSD Project. It can be used to install either a
graphical desktop (PC-BSD) or a command line version of &os;.
Refer to the PC-BSD Users Handbook for details (http://wiki.pcbsd.org/index.php/PC-BSD%C2%AE_Users_Handbook/10.1).After reading this chapter, you will know:The minimum hardware requirements and &os; supported
architectures.How to create the &os; installation media.How to start
bsdinstall.The questions bsdinstall will
ask, what they mean, and how to answer them.How to troubleshoot a failed installation.How to access a live version of &os; before committing
to an installation.Before reading this chapter, you should:Read the supported hardware list that shipped with the
version of &os; to be installed and verify that the system's
hardware is supported.Minimum Hardware RequirementsThe hardware requirements to install &os; vary by the &os;
version and the hardware architecture. Hardware architectures
and devices supported by a &os; release are listed in the
Hardware Notes file. Usually named
HARDWARE.TXT, the file is located in the
root directory of the release media. Copies of the supported
hardware list are also available on the Release Information page
of the &os; web site (http://www.FreeBSD.org/releases/index.html).A &os; installation will require at least 64 MB of
RAM and 1.5 GB of free hard drive space
for the most minimal installation. However, that is a
very minimal install, leaving almost no
free space. A more realistic minimum is 4 GB without a
graphical environment, and 8 GB or more if a graphical user
interface will be used. Third-party application software
requires more space. It is recommended to increase
RAM and hard drive space to meet the needs of
the applications that will be used and the amount of data that
will be stored.The processor requirements for each architecture can be
summarized as follows:&arch.amd64;There are two classes of processors capable of running
&arch.amd64;. The first are AMD64
processors, including the &amd.athlon;64 and &amd.opteron;
processors.The second class of processors includes those using
the &intel; EM64T architecture. Examples of these
processors include all multi-core &intel; &xeon;
processors except Sossaman, the single-core
&intel; &xeon; processors Nocona, Irwindale, Potomac,
and Cranford, the &intel; &core; 2 (not Core
Duo) and later processors, all &intel; &pentium; D
processors, the &intel; &pentium; 4s and Celeron Ds
using the Cedar Mill core, and some &intel; &pentium;
4s and Celeron Ds using the Prescott core.Both Uniprocessor (UP) and
Symmetric Multi-processor (SMP)
configurations are supported.&arch.i386;Almost all i386-compatible processors with a floating
point unit are supported. All &intel; processors 486 or
higher are supported.&os; will take advantage of Physical Address
Extensions (PAE) support on
CPUs that support this feature. A
kernel with the PAE feature enabled
will detect memory above 4 GB and allow it to be used
by the system. This feature places constraints on the
device drivers and other features of &os; which may be
used; refer to &man.pae.4; for details.ia64Currently supported processors are the &itanium; and
the &itanium; 2. Supported chipsets include the HP zx1,
&intel; 460GX, and &intel; E8870. Both Uniprocessor
(UP) and Symmetric Multi-processor
(SMP) configurations are
supported.pc98NEC PC-9801/9821 series with almost all
i386-compatible processors, including 80486, &pentium;,
&pentium; Pro, and &pentium; II, are all supported. All
i386-compatible processors by AMD, Cyrix, IBM, and IDT are
also supported. EPSON PC-386/486/586 series, which are
compatible with NEC PC-9801 series, are supported. The
NEC FC-9801/9821 and NEC SV-98 series should be
supported.High-resolution mode is not supported. NEC
PC-98XA/XL/RL/XL^2, and NEC PC-H98 series are supported in
normal (PC-9801 compatible) mode only. The
SMP-related features of &os; are not
supported. The New Extend Standard Architecture
(NESA) bus used in the PC-H98, SV-H98,
and FC-H98 series, is not supported.&arch.powerpc;All New World ROM &apple;
&mac; systems with built-in USB
are supported. SMP is supported on
machines with multiple CPUs.A 32-bit kernel can only use the first 2 GB of
RAM.&arch.sparc64;Systems supported by &os;/&arch.sparc64; are listed at
the FreeBSD/sparc64 Project (http://www.freebsd.org/platforms/sparc.html).SMP is supported on all systems
with more than 1 processor. A dedicated disk is required
as it is not possible to share a disk with another
operating system at this time.Pre-Installation TasksOnce it has been determined that the system meets the
minimum hardware requirements for installing &os;, the
installation file should be downloaded and the installation
media prepared. Before doing this, check that the system is
ready for an installation by verifying the items in this
checklist:Back Up Important DataBefore installing any operating system,
always backup all important data first.
Do not store the backup on the system being installed.
Instead, save the data to a removable disk such as a
USB drive, another system on the network,
or an online backup service. Test the backup before
starting the installation to make sure it contains all of
the needed files. Once the installer formats the system's
disk, all data stored on that disk will be lost.Decide Where to Install &os;If &os; will be the only operating system installed,
this step can be skipped. But if &os; will share the disk
with another operating system, decide which disk or
partition will be used for &os;.In the &arch.i386; and &arch.amd64; architectures, disks
can be divided into multiple partitions using one of two
partitioning schemes. A traditional Master Boot
Record (MBR) holds a
partition table defining up to four primary
partitions. For historical reasons, &os;
calls these primary partition
slices. One of these primary
partitions can be made into an extended
partition containing multiple
logical partitions. The
GUID Partition Table
(GPT) is a newer and simpler method of
partitioning a disk. Common GPT
implementations allow up to 128 partitions per disk,
eliminating the need for logical partitions.Some older operating systems, like &windows; XP,
are not compatible with the GPT
partition scheme. If &os; will be sharing a disk with
such an operating system, MBR
partitioning is required.The &os; boot loader requires either a primary or
GPT partition. If all of the primary or
GPT partitions are already in use, one
must be freed for &os;. To create a partition without
deleting existing data, use a partition resizing tool to
shrink an existing partition and create a new partition
using the freed space.A variety of free and commercial partition resizing
tools are listed at http://en.wikipedia.org/wiki/List_of_disk_partitioning_software.
GParted Live (http://gparted.sourceforge.net/livecd.php)
is a free live CD which includes the
GParted partition editor.
GParted is also included with
many other Linux live CD
distributions.When used properly, disk shrinking utilities can
safely create space for creating a new partition. Since
the possibility of selecting the wrong partition exists,
always backup any important data and verify the integrity
of the backup before modifying disk partitions.Disk partitions containing different operating systems
make it possible to install multiple operating systems on
one computer. An alternative is to use virtualization
() which allows multiple
operating systems to run at the same time without modifying
any disk partitions.Collect Network InformationSome &os; installation methods require a network
connection in order to download the installation files.
After any installation, the installer will offer to setup
the system's network interfaces.If the network has a DHCP server, it
can be used to provide automatic network configuration. If
DHCP is not available, the following
network information for the system must be obtained from the
local network administrator or Internet service
provider:Required Network InformationIP addressSubnet maskIP address of default
gatewayDomain name of the networkIP addresses of the network's
DNS serversCheck for &os; ErrataAlthough the &os; Project strives to ensure that
each release of &os; is as stable as possible, bugs
occasionally creep into the process. On very rare occasions
those bugs affect the installation process. As these
problems are discovered and fixed, they are noted in the
&os; Errata (http://www.freebsd.org/releases/&rel.current;R/errata.html)
on the &os; web site. Check the errata before installing to
make sure that there are no problems that might affect the
installation.Information and errata for all the releases can be found
on the release information section of the &os; web site
(http://www.freebsd.org/releases/index.html).Prepare the Installation MediaThe &os; installer is not an application that can be run
from within another operating system. Instead, download a
&os; installation file, burn it to the media associated with
its file type and size (CD,
DVD, or USB), and boot
the system to install from the inserted media.&os; installation files are available at www.freebsd.org/where.html#download.
Each installation file's name includes the release version of
&os;, the architecture, and the type of file. For example, to
install &os; 10.0 on an &arch.amd64; system from a
DVD, download
FreeBSD-10.0-RELEASE-amd64-dvd1.iso, burn
this file to a DVD, and boot the system
with the DVD inserted.Several file types are available, though not all file
types are available for all architectures. The possible file
types are:-bootonly.iso: This is the smallest
installation file as it only contains the installer. A
working Internet connection is required during
installation as the installer will download the files it
needs to complete the &os; installation. This file should
be burned to a CD using a
CD burning application.-disc1.iso: This file contains all
of the files needed to install &os;, its source, and the
Ports Collection. It should be burned to a
CD using a CD
burning application.-dvd1.iso: This file contains all
of the files needed to install &os;, its source, and the
Ports Collection. It also contains a set of popular
binary packages for installing a window manager and some
applications so that a complete system can be installed
from media without requiring a connection to the Internet.
This file should be burned to a DVD
using a DVD burning application.-memstick.img: This file contains
all of the files needed to install &os;, its source, and
the Ports Collection. It should be burned to a
USB stick using the instructions
below.Also download CHECKSUM.SHA256 from
the same directory as the image file and use it to check the
image file's integrity by calculating a
checksum. &os; provides &man.sha256.1;
for this, while other operating systems have similar programs.
Compare the calculated checksum with the one shown in
CHECKSUM.SHA256. The checksums must
match exactly. If the checksums do not match, the file is
corrupt and should be downloaded again.Writing an Image File to USBThe *.img file is an
image of the complete contents of a
memory stick. It cannot be copied to
the target device as a file. Several applications are
available for writing the *.img to a
USB stick. This section describes two of
these utilities.Before proceeding, back up any important data on the
USB stick. This procedure will erase
the existing data on the stick.Using dd to Write the
ImageThis example uses /dev/da0 as
the target device where the image will be written. Be
very careful that the correct
device is used as this command will destroy the existing
data on the specified target device.The &man.dd.1; command-line utility is
available on BSD, &linux;, and &macos; systems. To burn
the image using dd, insert the
USB stick and determine its device
name. Then, specify the name of the downloaded
installation file and the device name for the
USB stick. This example burns the
&arch.amd64; installation image to the first
USB device on an existing &os;
system.&prompt.root; dd if=FreeBSD-10.0-RELEASE-amd64-memstick.img of=/dev/da0 bs=64kIf this command fails, verify that the
USB stick is not mounted and that the
device name is for the disk, not a partition. Some
operating systems might require this command to be run
with &man.sudo.8;. Systems like &linux; might buffer
writes. To force all writes to complete, use
&man.sync.8;.Using &windows; to Write the ImageBe sure to give the correct drive letter as the
existing data on the specified drive will be overwritten
and destroyed.Obtaining Image Writer for
&windows;Image Writer for
&windows; is a free application that can
correctly write an image file to a memory stick.
Download it from https://launchpad.net/win32-image-writer/
and extract it into a folder.Writing the Image with Image WriterDouble-click the
Win32DiskImager icon to start
the program. Verify that the drive letter shown under
Device is the drive
with the memory stick. Click the folder icon and select
the image to be written to the memory stick. Click
[ Save ] to accept the
image file name. Verify that everything is correct, and
that no folders on the memory stick are open in other
windows. When everything is ready, click
[ Write ] to write the
image file to the memory stick.You are now ready to start installing &os;.Starting the InstallationBy default, the installation will not make any changes to
the disk(s) before the following message:Your changes will now be written to disk. If you
have chosen to overwrite existing data, it will
be PERMANENTLY ERASED. Are you sure you want to
commit your changes?The install can be exited at any time prior to this
warning. If
there is a concern that something is incorrectly configured,
just turn the computer off before this point and no changes
will be made to the system's disks.This section describes how to boot the system from the
installation media which was prepared using the instructions in
. When using a
bootable USB stick, plug in the USB stick
before turning on the computer. When booting from
CD or DVD, turn on the
computer and insert the media at the first opportunity. How to
configure the system to boot from the inserted media depends
upon the architecture.Booting on &i386; and &arch.amd64;These architectures provide a BIOS
menu for selecting the boot device. Depending upon the
installation media being used, select the
CD/DVD or
USB device as the first boot device. Most
systems also provide a key for selecting the boot device
during startup without having to enter the
BIOS. Typically, the key is either
F10, F11,
F12, or Escape.If the computer loads the existing operating system
instead of the &os; installer, then either:The installation media was not inserted early enough
in the boot process. Leave the media inserted and try
restarting the computer.The BIOS changes were incorrect or
not saved. Double-check that the right boot device is
selected as the first boot device.This system is too old to support booting from the
chosen media. In this case, the Plop Boot
Manager (http://www.plop.at/en/bootmanager.html)
can be used to boot the system from the selected
media.Booting on &powerpc;On most machines, holding C on the
keyboard during boot will boot from the CD.
Otherwise, hold CommandOptionOF, or
WindowsAltOF on non-&apple; keyboards. At the
0 > prompt, enterboot cd:,\ppc\loader cd:0Booting on &sparc64;Most &sparc64; systems are set up to boot automatically
from disk. To install &os; from a CD
requires a break into the PROM.To do this, reboot the system and wait until the boot
message appears. The message depends on the model, but should
look something like this:Sun Blade 100 (UltraSPARC-IIe), Keyboard Present
Copyright 1998-2001 Sun Microsystems, Inc. All rights reserved.
OpenBoot 4.2, 128 MB memory installed, Serial #51090132.
Ethernet address 0:3:ba:b:92:d4, Host ID: 830b92d4.If the system proceeds to boot from disk at this point,
press L1A
or StopA
on the keyboard, or send a BREAK over the
serial console. When using tip or
cu, ~# will
issue a BREAK. The PROM prompt will be
ok on systems with one
CPU and ok {0} on
SMP systems, where the digit indicates the
number of the active CPU.At this point, place the CD into the
drive and type boot cdrom from the
PROM prompt.&os; Boot MenuOnce the system boots from the installation media, a menu
similar to the following will be displayed:&os; Boot Loader MenuBy default, the menu will wait ten seconds for user input
before booting into the &os; installer or, if &os; is already
installed, before booting into &os;. To pause the boot timer
in order to review the selections, press
Space. To select an option, press its
highlighted number, character, or key. The following options
are available.Boot Multi User: This will
continue the &os; boot process. If the boot timer has
been paused, press 1, upper- or
lower-case B, or
Enter.Boot Single User: This mode can be
used to fix an existing &os; installation as described in
. Press
2 or the upper- or lower-case
S to enter this mode.Escape to loader prompt: This will
boot the system into a repair prompt that contains a
limited number of low-level commands. This prompt is
described in . Press
3 or Esc to boot into
this prompt.Reboot: Reboots the system.Configure Boot Options: Opens the
menu shown in, and described under, .&os; Boot Options MenuThe boot options menu is divided into two sections. The
first section can be used to either return to the main boot
menu or to reset any toggled options back to their
defaults.The next section is used to toggle the available options
to On or Off by pressing
the option's highlighted number or character. The system will
always boot using the settings for these options until they
are modified. Several options can be toggled using this
menu:ACPI Support: If the system hangs
during boot, try toggling this option to
Off.Safe Mode: If the system still
hangs during boot even with ACPI
Support set to Off, try
setting this option to On.Single User: Toggle this option to
On to fix an existing &os; installation
as described in . Once
the problem is fixed, set it back to
Off.Verbose: Toggle this option to
On to see more detailed messages during
the boot process. This can be useful when troubleshooting
a piece of hardware.After making the needed selections, press
1 or Backspace to return to
the main boot menu, then press Enter to
continue booting into &os;. A series of boot messages will
appear as &os; carries out its hardware device probes and
loads the installation program. Once the boot is complete,
the welcome menu shown in will be displayed.Welcome MenuPress Enter to select the default of
[ Install ] to enter the
installer. The rest of this chapter describes how to use this
installer. Otherwise, use the right or left arrows or the
colorized letter to select the desired menu item. The
[ Shell ] can be used to
access a &os; shell in order to use command line utilities to
prepare the disks before installation. The
[ Live CD ] option can be
used to try out &os; before installing it. The live version
is described in .To review the boot messages, including the hardware
device probe, press the upper- or lower-case
S and then Enter to access
a shell. At the shell prompt, type more
/var/run/dmesg.boot and use the space bar to
scroll through the messages. When finished, type
exit to return to the welcome
menu.Using bsdinstallThis section shows the order of the
bsdinstall menus and the type of
information that will be asked before the system is installed.
Use the arrow keys to highlight a menu option, then
Space to select or deselect that menu item.
When finished, press Enter to save the
selection and move onto the next screen.Selecting the Keymap MenuDepending on the system console being used,
bsdinstall may initially display
the menu shown in .Keymap SelectionTo configure the keyboard layout, press
Enter with
[ YES ] selected, which will
display the menu shown in . To instead use the
default layout, use the arrow key to select
[ NO ] and press
Enter to skip this menu screen.Selecting Keyboard MenuWhen configuring the keyboard layout, use the up and down
arrows to select the keymap that most closely represents the
mapping of the keyboard attached to the system. Press
Enter to save the selection.Pressing Esc will exit this menu and
use the default keymap. If the choice of keymap is not
clear, United States of America
ISO-8859-1 is also a safe option.In &os; 10.0-RELEASE and later, this menu has been
enhanced. The full selection of keymaps is shown, with the
default preselected. In addition, when selecting a different
keymap, a dialog is displayed that allows the user to try the
keymap and ensure it is correct before proceeding.Enhanced Keymap MenuSetting the HostnameThe next bsdinstall menu is
used to set the hostname for the newly installed
system.Setting the HostnameType in a hostname that is unique for the network. It
should be a fully-qualified hostname, such as machine3.example.com.Selecting Components to InstallNext, bsdinstall will prompt to
select optional components to install.Selecting Components to InstallDeciding which components to install will depend largely
on the intended use of the system and the amount of disk space
available. The &os; kernel and userland, collectively known
as the base system, are always
installed. Depending on the architecture, some of these
components may not appear:doc - Additional documentation,
mostly of historical interest, to install into
/usr/share/doc. The documentation
provided by the FreeBSD Documentation Project may be
installed later using the instructions in .games - Several traditional
BSD games, including
fortune,
rot13, and others.lib32 - Compatibility libraries for
running 32-bit applications on a 64-bit version of
&os;.ports - The &os; Ports Collection
is a collection of files which automates the downloading,
compiling and installation of third-party software
packages. discusses how to use
the Ports Collection.The installation program does not check for
adequate disk space. Select this option only if
sufficient hard disk space is available. The &os; Ports
Collection takes up about &ports.size; of disk
space.src - The complete &os; source code
for both the kernel and the userland. Although not
required for the majority of applications, it may be
required to build device drivers, kernel modules, or some
applications from the Ports Collection. It is also used
for developing &os; itself. The full source tree requires
1 GB of disk space and recompiling the entire &os;
system requires an additional 5 GB of space.Installing from the NetworkThe menu shown in only appears when
installing from a -bootonly.iso
CD as this installation media does not hold
copies of the installation files. Since the installation
files must be retrieved over a network connection, this menu
indicates that the network interface must be first
configured.Installing from the NetworkTo configure the network connection, press
Enter and follow the instructions in . Once the
interface is configured, select a mirror site that is
located in the same region of the world as the computer on
which &os; is being installed. Files can be retrieved more
quickly when the mirror is close to the target computer,
reducing installation time.Choosing a MirrorInstallation will then continue as if the installation
files were located on the local installation media.Allocating Disk SpaceThe next menu is used to determine the method for
allocating disk space. The options available in the menu
depend upon the version of &os; being installed.Partitioning Choices on &os; 9.xPartitioning Choices on &os; 10.x and HigherGuided partitioning automatically sets up
the disk partitions, Manual partitioning
allows advanced users to create customized partitions from menu
options, and Shell opens a shell prompt where
advanced users can create customized partitions using
command-line utilities like &man.gpart.8;, &man.fdisk.8;, and
&man.bsdlabel.8;. ZFS partitioning, only
available in &os; 10 and later, creates an optionally encrypted
root-on-ZFS system with support for boot
environments.This section describes what to consider when laying out the
disk partitions. It then demonstrates how to use the different
partitioning methods.Designing the Partition Layoutpartition layout/etc/var/usrWhen laying out file systems, remember that hard drives
transfer data faster from the outer tracks to the inner.
Thus, smaller and heavier-accessed file systems should be
closer to the outside of the drive, while larger partitions
like /usr should be placed toward the
inner parts of the disk. It is a good idea to create
partitions in an order similar to: /,
swap, /var, and
/usr.The size of the /var partition
reflects the intended machine's usage. This partition is
used to hold mailboxes, log files, and printer spools.
Mailboxes and log files can grow to unexpected sizes
depending on the number of users and how long log files are
kept. On average, most users rarely need more than about a
gigabyte of free disk space in
/var.Sometimes, a lot of disk space is required in
/var/tmp. When new software is
installed, the packaging tools extract a temporary copy of
the packages under /var/tmp. Large
software packages, like Firefox,
OpenOffice or
LibreOffice may be tricky to
install if there is not enough disk space under
/var/tmp.The /usr partition holds many of the
files which support the system, including the &os; Ports
Collection and system source code. At least 2 gigabytes is
recommended for this partition.When selecting partition sizes, keep the space
requirements in mind. Running out of space in one partition
while barely using another can be a hassle.swap sizingswap partitionAs a rule of thumb, the swap partition should be about
double the size of physical memory (RAM).
Systems with minimal RAM may perform
better with more swap. Configuring too little swap can lead
to inefficiencies in the VM page scanning
code and might create issues later if more memory is
added.On larger systems with multiple SCSI
disks or multiple IDE disks operating on
different controllers, it is recommended that swap be
configured on each drive, up to four drives. The swap
partitions should be approximately the same size. The
kernel can handle arbitrary sizes but internal data structures
scale to 4 times the largest swap partition. Keeping the swap
partitions near the same size will allow the kernel to
optimally stripe swap space across disks. Large swap sizes
are fine, even if swap is not used much. It might be easier
to recover from a runaway program before being forced to
reboot.By properly partitioning a system, fragmentation
introduced in the smaller write heavy partitions will not
bleed over into the mostly read partitions. Keeping the
write loaded partitions closer to the disk's edge will
increase I/O performance in the
partitions where it occurs the most. While
I/O performance in the larger partitions
may be needed, shifting them more toward the edge of the disk
will not lead to a significant performance improvement over
moving /var to the edge.Guided PartitioningWhen this method is selected, a menu will display the
available disk(s). If multiple disks are connected, choose
the one where &os; is to be installed.Selecting from Multiple DisksOnce the disk is selected, the next menu prompts to
install to either the entire disk or to create a partition
using free space. If
[ Entire Disk ] is
chosen, a general partition layout filling the whole disk is
automatically created. Selecting
[ Partition ] creates a
partition layout from the unused space on the disk.Selecting Entire Disk or PartitionAfter the partition layout has been created, review it to
ensure it meets the needs of the installation. Selecting
[ Revert ] will reset the
partitions to their original values and pressing
[ Auto ] will recreate the
automatic &os; partitions. Partitions can also be manually
created, modified, or deleted. When the partitioning is
correct, select [ Finish ] to
continue with the installation.Review Created PartitionsManual PartitioningSelecting this method opens the partition editor:Manually Create PartitionsHighlight the installation drive
(ada0 in this example) and select
[ Create ] to display a menu
of available partition schemes:Manually Create PartitionsGPT is usually the most appropriate
choice for &arch.amd64; computers. Older computers that are
not compatible with GPT should use
MBR. The other partition schemes are
generally used for uncommon or older computers.
Partitioning SchemesAbbreviationDescriptionAPMApple Partition Map, used by &powerpc;.BSDBSD label without an
MBR, sometimes called
dangerously dedicated mode as
non-BSD disk utilities may not
recognize it.GPTGUID Partition Table (http://en.wikipedia.org/wiki/GUID_Partition_Table).MBRMaster Boot Record (http://en.wikipedia.org/wiki/Master_boot_record).PC98MBR variant used by NEC PC-98
computers (http://en.wikipedia.org/wiki/Pc9801).VTOC8Volume Table Of Contents used by Sun SPARC64 and
UltraSPARC computers.
After the partitioning scheme has been selected and
created, select [ Create ]
again to create the partitions.Manually Create PartitionsA standard &os; GPT installation uses
at least three partitions:freebsd-boot - Holds the &os; boot
code.freebsd-ufs - A &os;
UFS file system.freebsd-swap - &os; swap
space.Another partition type worth noting is
freebsd-zfs, used for partitions that will
contain a &os; ZFS file system (). Refer to &man.gpart.8; for
descriptions of the available GPT partition
types.Multiple file system partitions can be created and some
people prefer a traditional layout with separate partitions
- for the /, /var,
- /tmp, and /usr file
- systems. See
- for an example.
+ for /, /var,
+ /tmp, and /usr. See
+ for an
+ example.
The Size may be entered with common
abbreviations: K for kilobytes,
M for megabytes, or
G for gigabytes.Proper sector alignment provides the best performance,
and making partition sizes even multiples of 4K-bytes helps
to ensure alignment on drives with either 512-byte or
4K-byte sectors. Generally, using partition sizes that are
even multiples of 1M or 1G is the easiest way to make sure
every partition starts at an even multiple of 4K. There is
one exception: the freebsd-boot
partition should be no larger than 512K due to current boot
code limitations.A Mountpoint is needed if the partition
will contain a file system. If only a single
UFS partition will be created, the
mountpoint should be /.The Label is a name by which the
partition will be known. Drive names or numbers can change if
the drive is connected to a different controller or port, but
the partition label does not change. Referring to labels
instead of drive names and partition numbers in files like
/etc/fstab makes the system more tolerant
to hardware changes. GPT labels appear in
/dev/gpt/ when a disk is attached. Other
partitioning schemes have different label capabilities and
their labels appear in different directories in
/dev/.Use a unique label on every partition to avoid
conflicts from identical labels. A few letters from the
computer's name, use, or location can be added to the label.
For instance, use labroot or
rootfslab for the UFS
root partition on the computer named
lab.Creating Traditional Split File System
PartitionsFor a traditional partition layout where the
/, /var,
/tmp, and /usr
directories are separate file systems on their own
partitions, create a GPT partitioning
scheme, then create the partitions as shown. Partition
sizes shown are typical for a 20G target disk. If more
space is available on the target disk, larger swap or
/var partitions may be useful. Labels
shown here are prefixed with ex for
example, but readers should use other unique
label values as described above.By default, &os;'s gptboot expects
the first UFS partition to be the
/ partition.Partition TypeSizeMountpointLabelfreebsd-boot512Kfreebsd-ufs2G/exrootfsfreebsd-swap4Gexswapfreebsd-ufs2G/varexvarfsfreebsd-ufs1G/tmpextmpfsfreebsd-ufsaccept the default (remainder of the
disk)/usrexusrfsAfter the custom partitions have been created, select
[ Finish ] to continue with
the installation.Root-on-ZFS Automatic PartitioningSupport for automatic creation of root-on-ZFS
installations was added in &os; 10.0-RELEASE. This
partitioning mode only works with whole disks and will erase
the contents of the entire disk. The installer will
automatically create partitions aligned to 4k boundaries and
force ZFS to use 4k sectors. This is safe
even with 512 byte sector disks, and has the added benefit of
ensuring that pools created on 512 byte disks will be able to
have 4k sector disks added in the future, either as additional
storage space or as replacements for failed disks. The
installer can also optionally employ GELI
disk encryption as described in .
If encryption is enabled, a 2 GB unencrypted boot pool
containing the /boot directory is
created. It holds the kernel and other files necessary to
boot the system. A swap partition of a user selectable size
is also created, and all remaining space is used for the
ZFS pool.The main ZFS configuration menu offers
a number of options to control the creation of the
pool.ZFS Partitioning MenuSelect T to configure the Pool
Type and the disk(s) that will constitute the
pool. The automatic ZFS installer
currently only supports the creation of a single top level
vdev, except in stripe mode. To create more complex pools,
use the instructions in to create the pool. The
installer supports the creation of various pool types,
including stripe (not recommended, no redundancy), mirror
(best performance, least usable space), and RAID-Z 1, 2, and 3
(with the capability to withstand the concurrent failure of 1,
2, and 3 disks, respectively). while selecting the pool type,
a tooltip is displayed across the bottom of the screen with
advice about the number of required disks, and in the case of
RAID-Z, the optimal number of disks for each
configuration.ZFS Pool TypeOnce a Pool Type has been selected, a
list of available disks is displayed, and the user is prompted
to select one or more disks to make up the pool. The
configuration is then validated, to ensure enough disks are
selected. If not, select <Change
Selection> to return to the list of disks, or
<Cancel> to change the pool
type.Disk SelectionInvalid SelectionIf one or more disks are missing from the list, or if
disks were attached after the installer was started, select
- Rescan Devices to repopulate the list
of available disks. To ensure that the correct disks are
selected, so as not to accidently destroy the wrong disks, the
- Disk Info menu can be used to inspect
each disk, including its partition table and various other
information such as the device model number and serial number,
if available.Analysing a DiskThe main ZFS configuration menu also
allows the user to enter a pool name, disable forcing 4k
sectors, enable or disable encryption, switch between
GPT (recommended) and
MBR partition table types, and select the
amount of swap space. Once all options have been set to the
desired values, select the
>>> Install option at the
top of the menu.If GELI disk encryption was enabled,
the installer will prompt twice for the passphrase to be used
to encrypt the disks.Disk Encryption PasswordThe installer then offers a last chance to cancel before
the contents of the selected drives are destroyed to create
the ZFS pool.Last ChanceThe installation then proceeds normally.Shell Mode PartitioningWhen creating advanced installations, the
bsdinstall paritioning menus may
not provide the level of flexibility required. Advanced users
can select the Shell option from the
partitioning menu in order to manually partition the drives,
create the file system(s), populate
/tmp/bsdinstall_etc/fstab, and mount the
file systems under /mnt. Once this is
done, type exit to return to
bsdinstall and continue the
installation.Committing to the InstallationOnce the disks are configured, the next menu provides the
last chance to make changes before the selected hard drive(s)
are formatted. If changes need to be made, select
[ Back ] to return to the main
partitioning menu.
[ Revert & Exit ]
will exit the installer without making any changes to the hard
drive.Final ConfirmationTo instead start the actual installation, select
[ Commit ] and press
Enter.Installation time will vary depending on the distributions
chosen, installation media, and speed of the computer. A series
of messages will indicate the progress.First, the installer formats the selected disk(s) and
initializes the partitions. Next, in the case of a bootonly
media, it downloads the selected components:Fetching Distribution FilesNext, the integrity of the distribution files is verified
to ensure they have not been corrupted during download or
misread from the installation media:Verifying Distribution FilesFinally, the verified distribution files are extracted to
the disk:Extracting Distribution FilesOnce all requested distribution files have been extracted,
bsdinstall displays the first
post-installation configuration screen. The available
post-configuration options are described in the next
section.Post-InstallationOnce &os; is installed,
bsdinstall will prompt to configure
several options before booting into the newly installed system.
This section describes these configuration options.Once the system has booted,
bsdconfig provides a menu-driven method for
configuring the system using these and additional
options.Setting the root PasswordFirst, the root
password must be set. While entering the password, the
characters being typed are not displayed on the screen. After
the password has been entered, it must be entered again. This
helps prevent typing errors.Setting the root PasswordConfiguring Network InterfacesNext, a list of the network interfaces found on the
computer is shown. Select the interface to configure.The network configuration menus will be skipped if the
network was previously configured as part of a
bootonly installation.Choose a Network InterfaceIf an Ethernet interface is selected, the installer will
skip ahead to the menu shown in . If a wireless
network interface is chosen, the system will instead scan for
wireless access points:Scanning for Wireless Access PointsWireless networks are identified by a Service Set
Identifier (SSID), a short, unique name
given to each network. SSIDs found during
the scan are listed, followed by a description of the
encryption types available for that network. If the desired
SSID does not appear in the list, select
[ Rescan ] to scan again. If
the desired network still does not appear, check for problems
with antenna connections or try moving the computer closer to
the access point. Rescan after each change is made.Choosing a Wireless NetworkNext, enter the encryption information for connecting to
the selected wireless network. WPA2
encryption is strongly recommended as older encryption types,
like WEP, offer little security. If the
network uses WPA2, input the password, also
known as the Pre-Shared Key (PSK). For
security reasons, the characters typed into the input box are
displayed as asterisks.WPA2 SetupNext, choose whether or not an IPv4
address should be configured on the Ethernet or wireless
interface:Choose IPv4 NetworkingThere are two methods of IPv4
configuration. DHCP will automatically
configure the network interface correctly and should be used
if the network provides a DHCP server.
Otherwise, the addressing information needs to be input
manually as a static configuration.Do not enter random network information as it will not
work. If a DHCP server is not available,
obtain the information listed in from
the network administrator or Internet service
provider.If a DHCP server is available, select
[ Yes ] in the next menu to
automatically configure the network interface. The installer
will appear to pause for a minute or so as it finds the
DHCP server and obtains the addressing
information for the system.Choose IPv4 DHCP
ConfigurationIf a DHCP server is not available,
select [ No ] and input the
following addressing information in this menu:IPv4 Static ConfigurationIP Address - The
IPv4 address assigned to this computer.
The address must be unique and not already in use by
another piece of equipment on the local network.Subnet Mask - The subnet mask for
the network.Default Router - The
IP address of the network's default
gateway.The next screen will ask if the interface should be
configured for IPv6. If
IPv6 is available and desired, choose
[ Yes ] to select it.Choose IPv6 NetworkingIPv6 also has two methods of
configuration. StateLess Address AutoConfiguration
(SLAAC) will automatically request the
correct configuration information from a local router. Refer
to http://tools.ietf.org/html/rfc4862
for more information. Static configuration requires manual
entry of network information.If an IPv6 router is available, select
[ Yes ] in the next menu to
automatically configure the network interface. The installer
will appear to pause for a minute or so as it finds the router
and obtains the addressing information for the system.Choose IPv6 SLAAC ConfigurationIf an IPv6 router is not available,
select [ No ] and input the
following addressing information in this menu:IPv6 Static ConfigurationIPv6 Address - The
IPv6 address assigned to this computer.
The address must be unique and not already in use by
another piece of equipment on the local network.Default Router - The
IPv6 address of the network's default
gateway.The last network configuration menu is used to configure
the Domain Name System (DNS) resolver,
which converts hostnames to and from network addresses. If
DHCP or SLAAC was used
to autoconfigure the network interface, the Resolver
Configuration values may already be filled in.
Otherwise, enter the local network's domain name in the
Search field. DNS #1
and DNS #2 are the IPv4
and/or IPv6 addresses of the
DNS servers. At least one
DNS server is required.DNS ConfigurationSetting the Time ZoneThe next menu asks if the system clock uses
UTC or local time. When in doubt, select
[ No ] to choose the more
commonly-used local time.Select Local or UTC ClockThe next series of menus are used to determine the correct
local time by selecting the geographic region, country, and
time zone. Setting the time zone allows the system to
automatically correct for regional time changes, such as
daylight savings time, and perform other time zone related
functions properly.The example shown here is for a machine located in the
Eastern time zone of the United States. The selections will
vary according to the geographical location.Select a RegionThe appropriate region is selected using the arrow keys
and then pressing Enter.Select a CountrySelect the appropriate country using the arrow keys and
press Enter.Select a Time ZoneThe appropriate time zone is selected using the arrow keys
and pressing Enter.Confirm Time ZoneConfirm the abbreviation for the time zone is correct. If
it is, press Enter to continue with the
post-installation configuration.Enabling ServicesThe next menu is used to configure which system services
will be started whenever the system boots. All of these
services are optional. Only start the services that are
needed for the system to function.Selecting Additional Services to EnableHere is a summary of the services which can be enabled in
this menu:sshd - The Secure Shell
(SSH) daemon is used to remotely access
a system over an encrypted connection. Only enable this
service if the system should be available for remote
logins.moused - Enable this service if the
mouse will be used from the command-line system
console.ntpd - The Network Time Protocol
(NTP) daemon for automatic clock
synchronization. Enable this service if there is a
&windows;, Kerberos, or LDAP server on
the network.powerd - System power control
utility for power control and energy saving.Enabling Crash DumpsThe next menu is used to configure whether or not crash
dumps should be enabled. Enabling crash dumps can be useful
in debugging issues with the system, so users are encouraged
to enable crash dumps.Enabling Crash DumpsAdd UsersThe next menu prompts to create at least one user account.
It is recommended to login to the system using a user account
rather than as root.
When logged in as root, there are essentially no
limits or protection on what can be done. Logging in as a
normal user is safer and more secure.Select [ Yes ] to add new
users.Add User AccountsFollow the prompts and input the requested information for
the user account. The example shown in creates the asample user account.Enter User InformationHere is a summary of the information to input:Username - The name the user will
enter to log in. A common convention is to use the first
letter of the first name combined with the last name, as
long as each username is unique for the system. The
username is case sensitive and should not contain any
spaces.Full name - The user's full name.
This can contain spaces and is used as a description for
the user account.Uid - User ID.
Typically, this is left blank so the system will assign a
value.Login group - The user's group.
Typically this is left blank to accept the default.Invite user into
other groups? - Additional groups to which the
user will be added as a member. If the user needs
administrative access, type wheel
here.Login class - Typically left blank
for the default.Shell - Type in one of the listed
values to set the interactive shell for the user. Refer
to for more information about
shells.Home directory - The user's home
directory. The default is usually correct.Home directory permissions -
Permissions on the user's home directory. The default is
usually correct.Use password-based authentication?
- Typically yes so that the user is
prompted to input their password at login.Use an empty password? -
Typically no as it is insecure to have
a blank password.Use a random password? - Typically
no so that the user can set their own
password in the next prompt.Enter password - The password for
this user. Characters typed will not show on the
screen.Enter password again - The password
must be typed again for verification.Lock out the account after
creation? - Typically no so
that the user can login.After entering everything, a summary is shown for review.
If a mistake was made, enter no and try
again. If everything is correct, enter yes
to create the new user.Exit User and Group ManagementIf there are more users to add, answer the Add
another user? question with
yes. Enter no to finish
adding users and continue the installation.For more information on adding users and user management,
see .Final ConfigurationAfter everything has been installed and configured, a
final chance is provided to modify settings.Final ConfigurationUse this menu to make any changes or do any additional
configuration before completing the installation.Add User - Described in .Root Password - Described in .Hostname - Described in .Network - Described in .Services - Described in .Time Zone - Described in .Handbook - Download and install the
&os; Handbook.After any final configuration is complete, select
Exit.Manual Configurationbsdinstall will prompt if there
are any additional configuration that needs to be done before
rebooting into the new system. Select
[ Yes ] to exit to a shell
within the new system or
[ No ] to proceed to the last
step of the installation.Complete the InstallationIf further configuration or special setup is needed,
select [ Live CD ] to
boot the install media into Live CD
mode.If the installation is complete, select
[ Reboot ] to reboot the
computer and start the new &os; system. Do not forget to
remove the &os; install media or the computer may boot from it
again.As &os; boots, informational messages are displayed.
After the system finishes booting, a login prompt is
displayed. At the login: prompt, enter the
username added during the installation. Avoid logging in as
root. Refer to
for instructions on how to
become the superuser when administrative access is
needed.The messages that appeared during boot can be reviewed by
pressing Scroll-Lock to turn on the
scroll-back buffer. The PgUp,
PgDn, and arrow keys can be used to scroll
back through the messages. When finished, press
Scroll-Lock again to unlock the display and
return to the console. To review these messages once the
system has been up for some time, type less
/var/run/dmesg.boot from a command prompt. Press
q to return to the command line after
viewing.If sshd was enabled in , the first boot may be
a bit slower as the system will generate the
RSA and DSA keys.
Subsequent boots will be faster. The fingerprints of the keys
will be displayed, as seen in this example:Generating public/private rsa1 key pair.
Your identification has been saved in /etc/ssh/ssh_host_key.
Your public key has been saved in /etc/ssh/ssh_host_key.pub.
The key fingerprint is:
10:a0:f5:af:93:ae:a3:1a:b2:bb:3c:35:d9:5a:b3:f3 root@machine3.example.com
The key's randomart image is:
+--[RSA1 1024]----+
| o.. |
| o . . |
| . o |
| o |
| o S |
| + + o |
|o . + * |
|o+ ..+ . |
|==o..o+E |
+-----------------+
Generating public/private dsa key pair.
Your identification has been saved in /etc/ssh/ssh_host_dsa_key.
Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.
The key fingerprint is:
7e:1c:ce:dc:8a:3a:18:13:5b:34:b5:cf:d9:d1:47:b2 root@machine3.example.com
The key's randomart image is:
+--[ DSA 1024]----+
| .. . .|
| o . . + |
| . .. . E .|
| . . o o . . |
| + S = . |
| + . = o |
| + . * . |
| . . o . |
| .o. . |
+-----------------+
Starting sshd.Refer to for more information
about fingerprints and SSH.&os; does not install a graphical environment by default.
Refer to for more information about
installing and configuring a graphical window manager.Proper shutdown of a &os; computer helps protect data and
hardware from damage. Do not turn off the power
before the system has been properly shut down! If
the user is a member of the wheel group, become the
superuser by typing su at the command line
and entering the root password. Then, type
shutdown -p now and the system will shut
down cleanly, and if the hardware supports it, turn itself
off.TroubleshootinginstallationtroubleshootingThis section covers basic installation
troubleshooting, such as common problems people have
reported.Check the Hardware Notes (http://www.freebsd.org/releases/index.html)
document for the version of &os; to make sure the hardware is
supported. If the hardware is supported and lock-ups or other
problems occur, build a custom kernel using the instructions in
to add support for devices which
are not present in the GENERIC kernel. The
default kernel assumes that most hardware devices are in their
factory default configuration in terms of
IRQs, I/O addresses, and
DMA channels. If the hardware has been
reconfigured, a custom kernel configuration file can tell &os;
where to find things.Some installation problems can be avoided or alleviated by
updating the firmware on various hardware components, most
notably the motherboard. Motherboard firmware is usually
referred to as the BIOS. Most motherboard
and computer manufacturers have a website for upgrades and
upgrade information.Manufacturers generally advise against upgrading the
motherboard BIOS unless there is a good
reason for doing so, like a critical update. The upgrade
process can go wrong, leaving the
BIOS incomplete and the computer
inoperative.If the system hangs while probing hardware during boot, or
it behaves strangely during install, ACPI may
be the culprit. &os; makes extensive use of the system
ACPI service on the &arch.i386;,
&arch.amd64;, and ia64 platforms to aid in system configuration
if it is detected during boot. Unfortunately, some bugs still
exist in both the ACPI driver and within
system motherboards and BIOS firmware.
ACPI can be disabled by setting the
hint.acpi.0.disabled hint in the third stage
boot loader:set hint.acpi.0.disabled="1"This is reset each time the system is booted, so it is
necessary to add hint.acpi.0.disabled="1" to
the file /boot/loader.conf. More
information about the boot loader can be found in .Using the Live CDThe welcome menu of bsdinstall,
shown in , provides a
[ Live CD ] option. This
is useful for those who are still wondering whether &os; is the
right operating system for them and want to test some of the
features before installing.The following points should be noted before using the
[ Live CD ]:To gain access to the system, authentication is
required. The username is root and the password is
blank.As the system runs directly from the installation media,
performance will be significantly slower than that of a
system installed on a hard disk.This option only provides a command prompt and not a
graphical interface.
Index: head/en_US.ISO8859-1/books/handbook/geom/chapter.xml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/geom/chapter.xml (revision 46060)
+++ head/en_US.ISO8859-1/books/handbook/geom/chapter.xml (revision 46061)
@@ -1,1698 +1,1698 @@
GEOM: Modular Disk Transformation FrameworkTomRhodesWritten by SynopsisGEOMGEOM Disk FrameworkGEOMIn &os;, the GEOM framework permits
access and control to classes, such as Master Boot Records and
BSD labels, through the use of providers, or
the disk devices in /dev. By supporting
various software RAID configurations,
GEOM transparently provides access to the
operating system and operating system utilities.This chapter covers the use of disks under the
GEOM framework in &os;. This includes the
major RAID control utilities which use the
framework for configuration. This chapter is not a definitive
guide to RAID configurations and only
GEOM-supported RAID
classifications are discussed.After reading this chapter, you will know:What type of RAID support is
available through GEOM.How to use the base utilities to configure, maintain,
and manipulate the various RAID
levels.How to mirror, stripe, encrypt, and remotely connect
disk devices through GEOM.How to troubleshoot disks attached to the
GEOM framework.Before reading this chapter, you should:Understand how &os; treats disk devices ().Know how to configure and install a new kernel (.RAID0 - StripingTomRhodesWritten by MurrayStokelyGEOMStripingStriping combines several disk drives into a single volume.
Striping can be performed through the use of hardware
RAID controllers. The
GEOM disk subsystem provides software support
for disk striping, also known as RAID0,
without the need for a RAID disk
controller.In RAID0, data is split into blocks that
are written across all the drives in the array. As seen in the
following illustration, instead of having to wait on the system
to write 256k to one disk, RAID0 can
simultaneously write 64k to each of the four disks in the array,
offering superior I/O performance. This
performance can be enhanced further by using multiple disk
controllers.Disk Striping IllustrationEach disk in a RAID0 stripe must be of
the same size, since I/O requests are
interleaved to read or write to multiple disks in
parallel.RAID0 does not
provide any redundancy. This means that if one disk in the
array fails, all of the data on the disks is lost. If the
data is important, implement a backup strategy that regularly
saves backups to a remote system or device.The process for creating a software,
GEOM-based RAID0 on a &os;
system using commodity disks is as follows. Once the stripe is
created, refer to &man.gstripe.8; for more information on how
to control an existing stripe.Creating a Stripe of Unformatted ATA
DisksLoad the geom_stripe.ko
module:&prompt.root; kldload geom_stripeEnsure that a suitable mount point exists. If this
volume will become a root partition, then temporarily use
another mount point such as
/mnt.Determine the device names for the disks which will
be striped, and create the new stripe device. For example,
to stripe two unused and unpartitioned
ATA disks with device names of
/dev/ad2 and
/dev/ad3:&prompt.root; gstripe label -v st0 /dev/ad2 /dev/ad3
Metadata value stored on /dev/ad2.
Metadata value stored on /dev/ad3.
Done.Write a standard label, also known as a partition table,
on the new volume and install the default bootstrap
code:&prompt.root; bsdlabel -wB /dev/stripe/st0This process should create two other devices in
/dev/stripe in addition to
st0. Those include
st0a and st0c. At
this point, a UFS file system can be
created on st0a using
newfs:&prompt.root; newfs -U /dev/stripe/st0aMany numbers will glide across the screen, and after a
few seconds, the process will be complete. The volume has
been created and is ready to be mounted.To manually mount the created disk stripe:&prompt.root; mount /dev/stripe/st0a /mntTo mount this striped file system automatically during
the boot process, place the volume information in
/etc/fstab. In this example, a
permanent mount point, named stripe, is
created:&prompt.root; mkdir /stripe
&prompt.root; echo "/dev/stripe/st0a /stripe ufs rw 2 2" \>> /etc/fstabThe geom_stripe.ko module must also
be automatically loaded during system initialization, by
adding a line to
/boot/loader.conf:&prompt.root; echo 'geom_stripe_load="YES"' >> /boot/loader.confRAID1 - MirroringGEOMDisk MirroringRAID1RAID1, or
mirroring, is the technique of writing
the same data to more than one disk drive. Mirrors are usually
used to guard against data loss due to drive failure. Each
drive in a mirror contains an identical copy of the data. When
an individual drive fails, the mirror continues to work,
providing data from the drives that are still functioning. The
computer keeps running, and the administrator has time to
replace the failed drive without user interruption.Two common situations are illustrated in these examples.
The first creates a mirror out of two new drives and uses it as
a replacement for an existing single drive. The second example
creates a mirror on a single new drive, copies the old drive's
data to it, then inserts the old drive into the mirror. While
this procedure is slightly more complicated, it only requires
one new drive.Traditionally, the two drives in a mirror are identical in
model and capacity, but &man.gmirror.8; does not require that.
Mirrors created with dissimilar drives will have a capacity
equal to that of the smallest drive in the mirror. Extra space
on larger drives will be unused. Drives inserted into the
mirror later must have at least as much capacity as the smallest
drive already in the mirror.The mirroring procedures shown here are non-destructive,
but as with any major disk operation, make a full backup
first.While &man.dump.8; is used in these procedures
to copy file systems, it does not work on file systems with
soft updates journaling. See &man.tunefs.8; for information
on detecting and disabling soft updates journaling.Metadata IssuesMany disk systems store metadata at the end of each disk.
Old metadata should be erased before reusing the disk for a
mirror. Most problems are caused by two particular types of
leftover metadata: GPT partition tables and
old metadata from a previous mirror.GPT metadata can be erased with
&man.gpart.8;. This example erases both primary and backup
GPT partition tables from disk
ada8:&prompt.root; gpart destroy -F ada8A disk can be removed from an active mirror and the
metadata erased in one step using &man.gmirror.8;. Here, the
example disk ada8 is removed from the
active mirror gm4:&prompt.root; gmirror remove gm4 ada8If the mirror is not running, but old mirror metadata is
still on the disk, use gmirror clear to
remove it:&prompt.root; gmirror clear ada8&man.gmirror.8; stores one block of metadata at the end of
the disk. Because GPT partition schemes
also store metadata at the end of the disk, mirroring entire
GPT disks with &man.gmirror.8; is not
recommended. MBR partitioning is used here
because it only stores a partition table at the start of the
disk and does not conflict with the mirror metadata.Creating a Mirror with Two New DisksIn this example, &os; has already been installed on a
single disk, ada0. Two new disks,
ada1 and ada2, have
been connected to the system. A new mirror will be created on
these two disks and used to replace the old single
disk.The geom_mirror.ko kernel module must
either be built into the kernel or loaded at boot- or
run-time. Manually load the kernel module now:&prompt.root; gmirror loadCreate the mirror with the two new drives:&prompt.root; gmirror label -v gm0 /dev/ada1 /dev/ada2gm0 is a user-chosen device name
assigned to the new mirror. After the mirror has been
started, this device name appears in
/dev/mirror/.MBR and
bsdlabel partition tables can now
be created on the mirror with &man.gpart.8;. This example
uses a traditional file system layout, with partitions for
/, swap, /var,
/tmp, and /usr. A
- single / file system and a swap partition
+ single / and a swap partition
will also work.Partitions on the mirror do not have to be the same size
as those on the existing disk, but they must be large enough
to hold all the data already present on
ada0.&prompt.root; gpart create -s MBR mirror/gm0
&prompt.root; gpart add -t freebsd -a 4k mirror/gm0
&prompt.root; gpart show mirror/gm0
=> 63 156301423 mirror/gm0 MBR (74G)
63 63 - free - (31k)
126 156301299 1 freebsd (74G)
156301425 61 - free - (30k)&prompt.root; gpart create -s BSD mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k -s 2g mirror/gm0s1
&prompt.root; gpart add -t freebsd-swap -a 4k -s 4g mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k -s 2g mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k -s 1g mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k mirror/gm0s1
&prompt.root; gpart show mirror/gm0s1
=> 0 156301299 mirror/gm0s1 BSD (74G)
0 2 - free - (1.0k)
2 4194304 1 freebsd-ufs (2.0G)
4194306 8388608 2 freebsd-swap (4.0G)
12582914 4194304 4 freebsd-ufs (2.0G)
16777218 2097152 5 freebsd-ufs (1.0G)
18874370 137426928 6 freebsd-ufs (65G)
156301298 1 - free - (512B)Make the mirror bootable by installing bootcode in the
MBR and bsdlabel and setting the active
slice:&prompt.root; gpart bootcode -b /boot/mbr mirror/gm0
&prompt.root; gpart set -a active -i 1 mirror/gm0
&prompt.root; gpart bootcode -b /boot/boot mirror/gm0s1Format the file systems on the new mirror, enabling
soft-updates.&prompt.root; newfs -U /dev/mirror/gm0s1a
&prompt.root; newfs -U /dev/mirror/gm0s1d
&prompt.root; newfs -U /dev/mirror/gm0s1e
&prompt.root; newfs -U /dev/mirror/gm0s1fFile systems from the original ada0
disk can now be copied onto the mirror with &man.dump.8; and
&man.restore.8;.&prompt.root; mount /dev/mirror/gm0s1a /mnt
&prompt.root; dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
&prompt.root; mount /dev/mirror/gm0s1d /mnt/var
&prompt.root; mount /dev/mirror/gm0s1e /mnt/tmp
&prompt.root; mount /dev/mirror/gm0s1f /mnt/usr
&prompt.root; dump -C16 -b64 -0aL -f - /var | (cd /mnt/var && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /tmp | (cd /mnt/tmp && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /usr | (cd /mnt/usr && restore -rf -)Edit /mnt/etc/fstab to point to
the new mirror file systems:# Device Mountpoint FStype Options Dump Pass#
/dev/mirror/gm0s1a / ufs rw 1 1
/dev/mirror/gm0s1b none swap sw 0 0
/dev/mirror/gm0s1d /var ufs rw 2 2
/dev/mirror/gm0s1e /tmp ufs rw 2 2
/dev/mirror/gm0s1f /usr ufs rw 2 2If the geom_mirror.ko kernel module
has not been built into the kernel,
/mnt/boot/loader.conf is edited to load
the module at boot:geom_mirror_load="YES"Reboot the system to test the new mirror and verify that
all data has been copied. The BIOS will
see the mirror as two individual drives rather than a mirror.
Because the drives are identical, it does not matter which is
selected to boot.See if there are
problems booting. Powering down and disconnecting the
original ada0 disk will allow it to be
kept as an offline backup.In use, the mirror will behave just like the original
single drive.Creating a Mirror with an Existing DriveIn this example, &os; has already been installed on a
single disk, ada0. A new disk,
ada1, has been connected to the system.
A one-disk mirror will be created on the new disk, the
existing system copied onto it, and then the old disk will be
inserted into the mirror. This slightly complex procedure is
required because gmirror needs to put a
512-byte block of metadata at the end of each disk, and the
existing ada0 has usually had all of its
space already allocated.Load the geom_mirror.ko kernel
module:&prompt.root; gmirror loadCheck the media size of the original disk with
diskinfo:&prompt.root; diskinfo -v ada0 | head -n3
/dev/ada0
512 # sectorsize
1000204821504 # mediasize in bytes (931G)Create a mirror on the new disk. To make certain that the
mirror capacity is not any larger than the original
ada0 drive, &man.gnop.8; is used to
create a fake drive of the exact same size. This drive does
not store any data, but is used only to limit the size of the
mirror. When &man.gmirror.8; creates the mirror, it will
restrict the capacity to the size of
gzero.nop, even if the new
ada1 drive has more space. Note that the
1000204821504 in the second line is
equal to ada0's media size as shown by
diskinfo above.&prompt.root; geom zero load
&prompt.root; gnop create -s 1000204821504 gzero
&prompt.root; gmirror label -v gm0 gzero.nop ada1
&prompt.root; gmirror forget gm0Since gzero.nop does not store any
data, the mirror does not see it as connected. The mirror is
told to forget unconnected components, removing
references to gzero.nop. The result is a
mirror device containing only a single disk,
ada1.After creating gm0, view the
partition table on ada0. This output is
from a 1 TB drive. If there is some unallocated space at
the end of the drive, the contents may be copied directly from
ada0 to the new mirror.However, if the output shows that all of the space on the
disk is allocated, as in the following listing, there is no
space available for the 512-byte mirror metadata at the end of
the disk.&prompt.root; gpart show ada0
=> 63 1953525105 ada0 MBR (931G)
63 1953525105 1 freebsd [active] (931G)In this case, the partition table must be edited to reduce
the capacity by one sector on mirror/gm0.
The procedure will be explained later.In either case, partition tables on the primary disk
should be first copied using gpart backup
and gpart restore.&prompt.root; gpart backup ada0 > table.ada0
&prompt.root; gpart backup ada0s1 > table.ada0s1These commands create two files,
table.ada0 and
table.ada0s1. This example is from a
1 TB drive:&prompt.root; cat table.ada0
MBR 4
1 freebsd 63 1953525105 [active]&prompt.root; cat table.ada0s1
BSD 8
1 freebsd-ufs 0 4194304
2 freebsd-swap 4194304 33554432
4 freebsd-ufs 37748736 50331648
5 freebsd-ufs 88080384 41943040
6 freebsd-ufs 130023424 838860800
7 freebsd-ufs 968884224 984640881If no free space is shown at the end of the disk, the size
of both the slice and the last partition must be reduced by
one sector. Edit the two files, reducing the size of both the
slice and last partition by one. These are the last numbers
in each listing.&prompt.root; cat table.ada0
MBR 4
1 freebsd 63 1953525104 [active]&prompt.root; cat table.ada0s1
BSD 8
1 freebsd-ufs 0 4194304
2 freebsd-swap 4194304 33554432
4 freebsd-ufs 37748736 50331648
5 freebsd-ufs 88080384 41943040
6 freebsd-ufs 130023424 838860800
7 freebsd-ufs 968884224 984640880If at least one sector was unallocated at the end of the
disk, these two files can be used without modification.Now restore the partition table into
mirror/gm0:&prompt.root; gpart restore mirror/gm0 < table.ada0
&prompt.root; gpart restore mirror/gm0s1 < table.ada0s1Check the partition table with
gpart show. This example has
gm0s1a for /,
gm0s1d for /var,
gm0s1e for /usr,
gm0s1f for /data1,
and gm0s1g for
/data2.&prompt.root; gpart show mirror/gm0
=> 63 1953525104 mirror/gm0 MBR (931G)
63 1953525042 1 freebsd [active] (931G)
1953525105 62 - free - (31k)
&prompt.root; gpart show mirror/gm0s1
=> 0 1953525042 mirror/gm0s1 BSD (931G)
0 2097152 1 freebsd-ufs (1.0G)
2097152 16777216 2 freebsd-swap (8.0G)
18874368 41943040 4 freebsd-ufs (20G)
60817408 20971520 5 freebsd-ufs (10G)
81788928 629145600 6 freebsd-ufs (300G)
710934528 1242590514 7 freebsd-ufs (592G)
1953525042 63 - free - (31k)Both the slice and the last partition must have at least
one free block at the end of the disk.Create file systems on these new partitions. The number
of partitions will vary to match the original disk,
ada0.&prompt.root; newfs -U /dev/mirror/gm0s1a
&prompt.root; newfs -U /dev/mirror/gm0s1d
&prompt.root; newfs -U /dev/mirror/gm0s1e
&prompt.root; newfs -U /dev/mirror/gm0s1f
&prompt.root; newfs -U /dev/mirror/gm0s1gMake the mirror bootable by installing bootcode in the
MBR and bsdlabel and setting the active
slice:&prompt.root; gpart bootcode -b /boot/mbr mirror/gm0
&prompt.root; gpart set -a active -i 1 mirror/gm0
&prompt.root; gpart bootcode -b /boot/boot mirror/gm0s1Adjust /etc/fstab to use the new
partitions on the mirror. Back up this file first by copying
it to /etc/fstab.orig.&prompt.root; cp /etc/fstab /etc/fstab.origEdit /etc/fstab, replacing
/dev/ada0 with
mirror/gm0.# Device Mountpoint FStype Options Dump Pass#
/dev/mirror/gm0s1a / ufs rw 1 1
/dev/mirror/gm0s1b none swap sw 0 0
/dev/mirror/gm0s1d /var ufs rw 2 2
/dev/mirror/gm0s1e /usr ufs rw 2 2
/dev/mirror/gm0s1f /data1 ufs rw 2 2
/dev/mirror/gm0s1g /data2 ufs rw 2 2If the geom_mirror.ko kernel module
has not been built into the kernel, edit
/boot/loader.conf to load it at
boot:geom_mirror_load="YES"File systems from the original disk can now be copied onto
the mirror with &man.dump.8; and &man.restore.8;. Each file
system dumped with dump -L will create a
snapshot first, which can take some time.&prompt.root; mount /dev/mirror/gm0s1a /mnt
&prompt.root; dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
&prompt.root; mount /dev/mirror/gm0s1d /mnt/var
&prompt.root; mount /dev/mirror/gm0s1e /mnt/usr
&prompt.root; mount /dev/mirror/gm0s1f /mnt/data1
&prompt.root; mount /dev/mirror/gm0s1g /mnt/data2
&prompt.root; dump -C16 -b64 -0aL -f - /usr | (cd /mnt/usr && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /var | (cd /mnt/var && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /data1 | (cd /mnt/data1 && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /data2 | (cd /mnt/data2 && restore -rf -)Restart the system, booting from
ada1. If everything is working, the
system will boot from mirror/gm0, which
now contains the same data as ada0 had
previously. See if
there are problems booting.At this point, the mirror still consists of only the
single ada1 disk.After booting from mirror/gm0
successfully, the final step is inserting
ada0 into the mirror.When ada0 is inserted into the
mirror, its former contents will be overwritten by data from
the mirror. Make certain that
mirror/gm0 has the same contents as
ada0 before adding
ada0 to the mirror. If the contents
previously copied by &man.dump.8; and &man.restore.8; are
not identical to what was on ada0,
revert /etc/fstab to mount the file
systems on ada0, reboot, and start the
whole procedure again.&prompt.root; gmirror insert gm0 ada0
GEOM_MIRROR: Device gm0: rebuilding provider ada0Synchronization between the two disks will start
immediately. Use gmirror status to view
the progress.&prompt.root; gmirror status
Name Status Components
mirror/gm0 DEGRADED ada1 (ACTIVE)
ada0 (SYNCHRONIZING, 64%)After a while, synchronization will finish.GEOM_MIRROR: Device gm0: rebuilding provider ada0 finished.
&prompt.root; gmirror status
Name Status Components
mirror/gm0 COMPLETE ada1 (ACTIVE)
ada0 (ACTIVE)mirror/gm0 now consists
of the two disks ada0 and
ada1, and the contents are automatically
synchronized with each other. In use,
mirror/gm0 will behave just like the
original single drive.TroubleshootingIf the system no longer boots, BIOS
settings may have to be changed to boot from one of the new
mirrored drives. Either mirror drive can be used for booting,
as they contain identical data.If the boot stops with this message, something is wrong
with the mirror device:Mounting from ufs:/dev/mirror/gm0s1a failed with error 19.
Loader variables:
vfs.root.mountfrom=ufs:/dev/mirror/gm0s1a
vfs.root.mountfrom.options=rw
Manual root filesystem specification:
<fstype>:<device> [options]
Mount <device> using filesystem <fstype>
and with the specified (optional) option list.
eg. ufs:/dev/da0s1a
zfs:tank
cd9660:/dev/acd0 ro
(which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /)
? List valid disk boot devices
. Yield 1 second (for background tasks)
<empty line> Abort manual input
mountroot>Forgetting to load the geom_mirror.ko
module in /boot/loader.conf can cause
this problem. To fix it, boot from a &os; 9.0 or later
installation media and choose Shell at the
first prompt. Then load the mirror module and mount the
mirror device:&prompt.root; gmirror load
&prompt.root; mount /dev/mirror/gm0s1a /mntEdit /mnt/boot/loader.conf, adding a
line to load the mirror module:geom_mirror_load="YES"Save the file and reboot.Other problems that cause error 19
require more effort to fix. Although the system should boot
from ada0, another prompt to select a
shell will appear if /etc/fstab is
incorrect. Enter ufs:/dev/ada0s1a at the
boot loader prompt and press Enter. Undo the
edits in /etc/fstab then mount the file
systems from the original disk (ada0)
instead of the mirror. Reboot the system and try the
procedure again.Enter full pathname of shell or RETURN for /bin/sh:
&prompt.root; cp /etc/fstab.orig /etc/fstab
&prompt.root; rebootRecovering from Disk FailureThe benefit of disk mirroring is that an individual disk
can fail without causing the mirror to lose any data. In the
above example, if ada0 fails, the mirror
will continue to work, providing data from the remaining
working drive, ada1.To replace the failed drive, shut down the system and
physically replace the failed drive with a new drive of equal
or greater capacity. Manufacturers use somewhat arbitrary
values when rating drives in gigabytes, and the only way to
really be sure is to compare the total count of sectors shown
by diskinfo -v. A drive with larger
capacity than the mirror will work, although the extra space
on the new drive will not be used.After the computer is powered back up, the mirror will be
running in a degraded mode with only one drive.
The mirror is told to forget drives that are not currently
connected:&prompt.root; gmirror forget gm0Any old metadata should be cleared from the replacement
disk using the instructions in
. Then the replacement
disk, ada4 for this example, is inserted
into the mirror:&prompt.root; gmirror insert gm0 /dev/ada4Resynchronization begins when the new drive is inserted
into the mirror. This process of copying mirror data to a new
drive can take a while. Performance of the mirror will be
greatly reduced during the copy, so inserting new drives is
best done when there is low demand on the computer.Progress can be monitored with gmirror
status, which shows drives that are being
synchronized and the percentage of completion. During
resynchronization, the status will be
DEGRADED, changing to
COMPLETE when the process is
finished.RAID3 - Byte-level Striping with
Dedicated ParityMarkGladmanWritten by DanielGerzoTomRhodesBased on documentation by MurrayStokelyGEOMRAID3RAID3 is a method used to combine several
disk drives into a single volume with a dedicated parity disk.
In a RAID3 system, data is split up into a
number of bytes that are written across all the drives in the
array except for one disk which acts as a dedicated parity disk.
This means that disk reads from a RAID3
implementation access all disks in the array. Performance can
be enhanced by using multiple disk controllers. The
RAID3 array provides a fault tolerance of 1
drive, while providing a capacity of 1 - 1/n times the total
capacity of all drives in the array, where n is the number of
hard drives in the array. Such a configuration is mostly
suitable for storing data of larger sizes such as multimedia
files.At least 3 physical hard drives are required to build a
RAID3 array. Each disk must be of the same
size, since I/O requests are interleaved to
read or write to multiple disks in parallel. Also, due to the
nature of RAID3, the number of drives must be
equal to 3, 5, 9, 17, and so on, or 2^n + 1.This section demonstrates how to create a software
RAID3 on a &os; system.While it is theoretically possible to boot from a
RAID3 array on &os;, that configuration is
uncommon and is not advised.Creating a Dedicated RAID3
ArrayIn &os;, support for RAID3 is
implemented by the &man.graid3.8; GEOM
class. Creating a dedicated RAID3 array on
&os; requires the following steps.First, load the geom_raid3.ko
kernel module by issuing one of the following
commands:&prompt.root; graid3 loador:&prompt.root; kldload geom_raid3Ensure that a suitable mount point exists. This
command creates a new directory to use as the mount
point:&prompt.root; mkdir /multimediaDetermine the device names for the disks which will be
added to the array, and create the new
RAID3 device. The final device listed
will act as the dedicated parity disk. This example uses
three unpartitioned ATA drives:
ada1 and
ada2 for
data, and
ada3 for
parity.&prompt.root; graid3 label -v gr0 /dev/ada1 /dev/ada2 /dev/ada3
Metadata value stored on /dev/ada1.
Metadata value stored on /dev/ada2.
Metadata value stored on /dev/ada3.
Done.Partition the newly created gr0
device and put a UFS file system on
it:&prompt.root; gpart create -s GPT /dev/raid3/gr0
&prompt.root; gpart add -t freebsd-ufs /dev/raid3/gr0
&prompt.root; newfs -j /dev/raid3/gr0p1Many numbers will glide across the screen, and after a
bit of time, the process will be complete. The volume has
been created and is ready to be mounted:&prompt.root; mount /dev/raid3/gr0p1 /multimedia/The RAID3 array is now ready to
use.Additional configuration is needed to retain this setup
across system reboots.The geom_raid3.ko module must be
loaded before the array can be mounted. To automatically
load the kernel module during system initialization, add
the following line to
/boot/loader.conf:geom_raid3_load="YES"The following volume information must be added to
/etc/fstab in order to
automatically mount the array's file system during the
system boot process:/dev/raid3/gr0p1 /multimedia ufs rw 2 2Software RAID DevicesWarrenBlockOriginally contributed by GEOMSoftware RAID DevicesHardware-assisted RAIDSome motherboards and expansion cards add some simple
hardware, usually just a ROM, that allows the
computer to boot from a RAID array. After
booting, access to the RAID array is handled
by software running on the computer's main processor. This
hardware-assisted software
RAID gives RAID
arrays that are not dependent on any particular operating
system, and which are functional even before an operating system
is loaded.Several levels of RAID are supported,
depending on the hardware in use. See &man.graid.8; for a
complete list.&man.graid.8; requires the geom_raid.ko
kernel module, which is included in the
GENERIC kernel starting with &os; 9.1.
If needed, it can be loaded manually with
graid load.Creating an ArraySoftware RAID devices often have a menu
that can be entered by pressing special keys when the computer
is booting. The menu can be used to create and delete
RAID arrays. &man.graid.8; can also create
arrays directly from the command line.graid label is used to create a new
array. The motherboard used for this example has an Intel
software RAID chipset, so the Intel
metadata format is specified. The new array is given a label
of gm0, it is a mirror
(RAID1), and uses drives
ada0 and
ada1.Some space on the drives will be overwritten when they
are made into a new array. Back up existing data
first!&prompt.root; graid label Intel gm0 RAID1 ada0 ada1
GEOM_RAID: Intel-a29ea104: Array Intel-a29ea104 created.
GEOM_RAID: Intel-a29ea104: Disk ada0 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:0-ada0 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Disk ada1 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Array started.
GEOM_RAID: Intel-a29ea104: Volume gm0 state changed from STARTING to OPTIMAL.
Intel-a29ea104 created
GEOM_RAID: Intel-a29ea104: Provider raid/r0 for volume gm0 created.A status check shows the new mirror is ready for
use:&prompt.root; graid status
Name Status Components
raid/r0 OPTIMAL ada0 (ACTIVE (ACTIVE))
ada1 (ACTIVE (ACTIVE))The array device appears in
/dev/raid/. The first array is called
r0. Additional arrays, if present, will
be r1, r2, and so
on.The BIOS menu on some of these devices
can create arrays with special characters in their names. To
avoid problems with those special characters, arrays are given
simple numbered names like r0. To show
the actual labels, like gm0 in the
example above, use &man.sysctl.8;:&prompt.root; sysctl kern.geom.raid.name_format=1Multiple VolumesSome software RAID devices support
more than one volume on an array.
Volumes work like partitions, allowing space on the physical
drives to be split and used in different ways. For example,
Intel software RAID devices support two
volumes. This example creates a 40 G mirror for safely
storing the operating system, followed by a 20 G
RAID0 (stripe) volume for fast temporary
storage:&prompt.root; graid label -S 40G Intel gm0 RAID1 ada0 ada1
&prompt.root; graid add -S 20G gm0 RAID0Volumes appear as additional
rX entries
in /dev/raid/. An array with two volumes
will show r0 and
r1.See &man.graid.8; for the number of volumes supported by
different software RAID devices.Converting a Single Drive to a MirrorUnder certain specific conditions, it is possible to
convert an existing single drive to a &man.graid.8; array
without reformatting. To avoid data loss during the
conversion, the existing drive must meet these minimum
requirements:The drive must be partitioned with the
MBR partitioning scheme.
GPT or other partitioning schemes with
metadata at the end of the drive will be overwritten and
corrupted by the &man.graid.8; metadata.There must be enough unpartitioned and unused space at
the end of the drive to hold the &man.graid.8; metadata.
This metadata varies in size, but the largest occupies
64 M, so at least that much free space is
recommended.If the drive meets these requirements, start by making a
full backup. Then create a single-drive mirror with that
drive:&prompt.root; graid label Intel gm0 RAID1 ada0 NONE&man.graid.8; metadata was written to the end of the drive
in the unused space. A second drive can now be inserted into
the mirror:&prompt.root; graid insert raid/r0 ada1Data from the original drive will immediately begin to be
copied to the second drive. The mirror will operate in
degraded status until the copy is complete.Inserting New Drives into the ArrayDrives can be inserted into an array as replacements for
drives that have failed or are missing. If there are no
failed or missing drives, the new drive becomes a spare. For
example, inserting a new drive into a working two-drive mirror
results in a two-drive mirror with one spare drive, not a
three-drive mirror.In the example mirror array, data immediately begins to be
copied to the newly-inserted drive. Any existing information
on the new drive will be overwritten.&prompt.root; graid insert raid/r0 ada1
GEOM_RAID: Intel-a29ea104: Disk ada1 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 state changed from NONE to NEW.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 state changed from NEW to REBUILD.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 rebuild start at 0.Removing Drives from the ArrayIndividual drives can be permanently removed from a
from an array and their metadata erased:&prompt.root; graid remove raid/r0 ada1
GEOM_RAID: Intel-a29ea104: Disk ada1 state changed from ACTIVE to OFFLINE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-[unknown] state changed from ACTIVE to NONE.
GEOM_RAID: Intel-a29ea104: Volume gm0 state changed from OPTIMAL to DEGRADED.Stopping the ArrayAn array can be stopped without removing metadata from the
drives. The array will be restarted when the system is
booted.&prompt.root; graid stop raid/r0Checking Array StatusArray status can be checked at any time. After a drive
was added to the mirror in the example above, data is being
copied from the original drive to the new drive:&prompt.root; graid status
Name Status Components
raid/r0 DEGRADED ada0 (ACTIVE (ACTIVE))
ada1 (ACTIVE (REBUILD 28%))Some types of arrays, like RAID0 or
CONCAT, may not be shown in the status
report if disks have failed. To see these partially-failed
arrays, add :&prompt.root; graid status -ga
Name Status Components
Intel-e2d07d9a BROKEN ada6 (ACTIVE (ACTIVE))Deleting ArraysArrays are destroyed by deleting all of the volumes from
them. When the last volume present is deleted, the array is
stopped and metadata is removed from the drives:&prompt.root; graid delete raid/r0Deleting Unexpected ArraysDrives may unexpectedly contain &man.graid.8; metadata,
either from previous use or manufacturer testing.
&man.graid.8; will detect these drives and create an array,
interfering with access to the individual drive. To remove
the unwanted metadata:Boot the system. At the boot menu, select
2 for the loader prompt. Enter:OK set kern.geom.raid.enable=0
OK bootThe system will boot with &man.graid.8;
disabled.Back up all data on the affected drive.As a workaround, &man.graid.8; array detection
can be disabled by addingkern.geom.raid.enable=0to /boot/loader.conf.To permanently remove the &man.graid.8; metadata
from the affected drive, boot a &os; installation
CD-ROM or memory stick, and select
Shell. Use status
to find the name of the array, typically
raid/r0:&prompt.root; graid status
Name Status Components
raid/r0 OPTIMAL ada0 (ACTIVE (ACTIVE))
ada1 (ACTIVE (ACTIVE))Delete the volume by name:&prompt.root; graid delete raid/r0If there is more than one volume shown, repeat the
process for each volume. After the last array has been
deleted, the volume will be destroyed.Reboot and verify data, restoring from backup if
necessary. After the metadata has been removed, the
kern.geom.raid.enable=0 entry in
/boot/loader.conf can also be
removed.GEOM Gate NetworkGEOM provides a simple mechanism for
providing remote access to devices such as disks,
CDs, and file systems through the use of the
GEOM Gate network daemon,
ggated. The system with the device
runs the server daemon which handles requests made by clients
using ggatec. The devices should not
contain any sensitive data as the connection between the client
and the server is not encrypted.Similar to NFS, which is discussed in
, ggated
is configured using an exports file. This file specifies which
systems are permitted to access the exported resources and what
level of access they are offered. For example, to give the
client 192.168.1.5
read and write access to the fourth slice on the first
SCSI disk, create
/etc/gg.exports with this line:192.168.1.5 RW /dev/da0s4dBefore exporting the device, ensure it is not currently
mounted. Then, start ggated:&prompt.root; ggatedSeveral options are available for specifying an alternate
listening port or changing the default location of the exports
file. Refer to &man.ggated.8; for details.To access the exported device on the client machine, first
use ggatec to specify the
IP address of the server and the device name
of the exported device. If successful, this command will
display a ggate device name to mount. Mount
that specified device name on a free mount point. This example
connects to the /dev/da0s4d partition on
192.168.1.1, then mounts
/dev/ggate0 on
/mnt:&prompt.root; ggatec create -o rw 192.168.1.1 /dev/da0s4d
ggate0
&prompt.root; mount /dev/ggate0 /mntThe device on the server may now be accessed through
/mnt on the client. For more details about
ggatec and a few usage examples, refer to
&man.ggatec.8;.The mount will fail if the device is currently mounted on
either the server or any other client on the network. If
simultaneous access is needed to network resources, use
NFS instead.When the device is no longer needed, unmount it with
umount so that the resource is available to
other clients.Labeling Disk DevicesGEOMDisk LabelsDuring system initialization, the &os; kernel creates
device nodes as devices are found. This method of probing for
devices raises some issues. For instance, what if a new disk
device is added via USB? It is likely that
a flash device may be handed the device name of
da0 and the original
da0 shifted to
da1. This will cause issues mounting
file systems if they are listed in
/etc/fstab which may also prevent the
system from booting.One solution is to chain SCSI devices
in order so a new device added to the SCSI
card will be issued unused device numbers. But what about
USB devices which may replace the primary
SCSI disk? This happens because
USB devices are usually probed before the
SCSI card. One solution is to only insert
these devices after the system has been booted. Another method
is to use only a single ATA drive and never
list the SCSI devices in
/etc/fstab.A better solution is to use glabel to
label the disk devices and use the labels in
/etc/fstab. Because
glabel stores the label in the last sector of
a given provider, the label will remain persistent across
reboots. By using this label as a device, the file system may
always be mounted regardless of what device node it is accessed
through.glabel can create both transient and
permanent labels. Only permanent labels are consistent across
reboots. Refer to &man.glabel.8; for more information on the
differences between labels.Label Types and ExamplesPermanent labels can be a generic or a file system label.
Permanent file system labels can be created with
&man.tunefs.8; or &man.newfs.8;. These types of labels are
created in a sub-directory of /dev, and
will be named according to the file system type. For example,
UFS2 file system labels will be created in
/dev/ufs. Generic permanent labels can
be created with glabel label. These are
not file system specific and will be created in
/dev/label.Temporary labels are destroyed at the next reboot. These
labels are created in /dev/label and are
suited to experimentation. A temporary label can be created
using glabel create.To create a permanent label for a
UFS2 file system without destroying any
data, issue the following command:&prompt.root; tunefs -L home/dev/da3If the file system is full, this may cause data
corruption.A label should now exist in /dev/ufs
which may be added to /etc/fstab:/dev/ufs/home /home ufs rw 2 2The file system must not be mounted while attempting
to run tunefs.Now the file system may be mounted:&prompt.root; mount /homeFrom this point on, so long as the
geom_label.ko kernel module is loaded at
boot with /boot/loader.conf or the
GEOM_LABEL kernel option is present,
the device node may change without any ill effect on the
system.File systems may also be created with a default label
by using the flag with
newfs. Refer to &man.newfs.8; for
more information.The following command can be used to destroy the
label:&prompt.root; glabel destroy homeThe following example shows how to label the partitions of
a boot disk.Labeling Partitions on the Boot DiskBy permanently labeling the partitions on the boot disk,
the system should be able to continue to boot normally, even
if the disk is moved to another controller or transferred to
a different system. For this example, it is assumed that a
single ATA disk is used, which is
currently recognized by the system as
ad0. It is also assumed that the
standard &os; partition scheme is used, with
/,
/var,
/usr and
/tmp, as
well as a swap partition.Reboot the system, and at the &man.loader.8; prompt,
press 4 to boot into single user mode.
Then enter the following commands:&prompt.root; glabel label rootfs /dev/ad0s1a
GEOM_LABEL: Label for provider /dev/ad0s1a is label/rootfs
&prompt.root; glabel label var /dev/ad0s1d
GEOM_LABEL: Label for provider /dev/ad0s1d is label/var
&prompt.root; glabel label usr /dev/ad0s1f
GEOM_LABEL: Label for provider /dev/ad0s1f is label/usr
&prompt.root; glabel label tmp /dev/ad0s1e
GEOM_LABEL: Label for provider /dev/ad0s1e is label/tmp
&prompt.root; glabel label swap /dev/ad0s1b
GEOM_LABEL: Label for provider /dev/ad0s1b is label/swap
&prompt.root; exitThe system will continue with multi-user boot. After
the boot completes, edit /etc/fstab and
replace the conventional device names, with their respective
labels. The final /etc/fstab will
look like this:# Device Mountpoint FStype Options Dump Pass#
/dev/label/swap none swap sw 0 0
/dev/label/rootfs / ufs rw 1 1
/dev/label/tmp /tmp ufs rw 2 2
/dev/label/usr /usr ufs rw 2 2
/dev/label/var /var ufs rw 2 2The system can now be rebooted. If everything went
well, it will come up normally and mount
will show:&prompt.root; mount
/dev/label/rootfs on / (ufs, local)
devfs on /dev (devfs, local)
/dev/label/tmp on /tmp (ufs, local, soft-updates)
/dev/label/usr on /usr (ufs, local, soft-updates)
/dev/label/var on /var (ufs, local, soft-updates)Starting with &os; 7.2, the &man.glabel.8; class
supports a new label type for UFS file
systems, based on the unique file system id,
ufsid. These labels may be found in
/dev/ufsid and are
created automatically during system startup. It is possible
to use ufsid labels to mount partitions
using /etc/fstab. Use glabel
status to receive a list of file systems and their
corresponding ufsid labels:&prompt.user; glabel status
Name Status Components
ufsid/486b6fc38d330916 N/A ad4s1d
ufsid/486b6fc16926168e N/A ad4s1fIn the above example, ad4s1d
represents /var,
while ad4s1f represents
/usr.
Using the ufsid values shown, these
partitions may now be mounted with the following entries in
/etc/fstab:/dev/ufsid/486b6fc38d330916 /var ufs rw 2 2
/dev/ufsid/486b6fc16926168e /usr ufs rw 2 2Any partitions with ufsid labels can be
mounted in this way, eliminating the need to manually create
permanent labels, while still enjoying the benefits of device
name independent mounting.UFS Journaling Through GEOMGEOMJournalingBeginning with &os; 7.0, support for journals on
UFS file systems is available. The
implementation is provided through the GEOM
subsystem and is configured using gjournal.
Unlike other file system journaling implementations, the
gjournal method is block based and not
implemented as part of the file system. It is a
GEOM extension.Journaling stores a log of file system transactions, such as
changes that make up a complete disk write operation, before
meta-data and file writes are committed to the disk. This
transaction log can later be replayed to redo file system
transactions, preventing file system inconsistencies.This method provides another mechanism to protect against
data loss and inconsistencies of the file system. Unlike Soft
Updates, which tracks and enforces meta-data updates, and
snapshots, which create an image of the file system, a log is
stored in disk space specifically for this task. For better
performance, the journal may be stored on another disk. In this
configuration, the journal provider or storage device should be
listed after the device to enable journaling on.The GENERIC kernel provides support for
gjournal. To automatically load the
geom_journal.ko kernel module at boot time,
add the following line to
/boot/loader.conf:geom_journal_load="YES"If a custom kernel is used, ensure the following line is in
the kernel configuration file:options GEOM_JOURNALOnce the module is loaded, a journal can be created on a new
file system using the following steps. In this example,
da4 is a new SCSI
disk:&prompt.root; gjournal load
&prompt.root; gjournal label /dev/da4This will load the module and create a
/dev/da4.journal device node on
/dev/da4.A UFS file system may now be created on
the journaled device, then mounted on an existing mount
point:&prompt.root; newfs -O 2 -J /dev/da4.journal
&prompt.root; mount /dev/da4.journal /mntIn the case of several slices, a journal will be created
for each individual slice. For instance, if
ad4s1 and ad4s2 are
both slices, then gjournal will create
ad4s1.journal and
ad4s2.journal.Journaling may also be enabled on current file systems by
using tunefs. However,
always make a backup before attempting to
alter an existing file system. In most cases,
gjournal will fail if it is unable to create
the journal, but this does not protect against data loss
incurred as a result of misusing tunefs.
Refer to &man.gjournal.8; and &man.tunefs.8; for more
information about these commands.It is possible to journal the boot disk of a &os; system.
Refer to the article Implementing UFS
Journaling on a Desktop PC for detailed
instructions.
Index: head/en_US.ISO8859-1/books/handbook/security/chapter.xml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/security/chapter.xml (revision 46060)
+++ head/en_US.ISO8859-1/books/handbook/security/chapter.xml (revision 46061)
@@ -1,3927 +1,3927 @@
SecurityTomRhodesRewritten by securitySynopsisSecurity, whether physical or virtual, is a topic so broad
that an entire industry has grown up around it. Hundreds of
standard practices have been authored about how to secure
systems and networks, and as a user of &os;, understanding how
to protect against attacks and intruders is a must.In this chapter, several fundamentals and techniques will be
discussed. The &os; system comes with multiple layers of
security, and many more third party utilities may be added to
enhance security.After reading this chapter, you will know:Basic &os; system security concepts.The various crypt mechanisms available in &os;.How to set up one-time password authentication.How to configure TCP Wrapper
for use with &man.inetd.8;.How to set up Kerberos on
&os;.How to configure IPsec and create a
VPN.How to configure and use
OpenSSH on &os;.How to use file system ACLs.How to use portaudit to audit
third party software packages installed from the Ports
Collection.How to utilize &os; security advisories.What Process Accounting is and how to enable it on
&os;.How to control user resources using login classes or the
resource limits database.Before reading this chapter, you should:Understand basic &os; and Internet concepts.Additional security topics are covered elsewhere in this
Handbook. For example, Mandatory Access Control is discussed in
and Internet firewalls are discussed in
.IntroductionSecurity is everyone's responsibility. A weak entry point
in any system could allow intruders to gain access to critical
information and cause havoc on an entire network. One of the
core principles of information security is the
CIA triad, which stands for the
Confidentiality, Integrity, and Availability of information
systems.The CIA triad is a bedrock concept of
computer security as customers and users expect their data to be
protected. For example, a customer expects that their credit
card information is securely stored (confidentiality), that
their orders are not changed behind the scenes (integrity), and
that they have access to their order information at all times
(availablility).To provide CIA, security professionals
apply a defense in depth strategy. The idea of defense in depth
is to add several layers of security to prevent one single layer
failing and the entire security system collapsing. For example,
a system administrator cannot simply turn on a firewall and
consider the network or system secure. One must also audit
accounts, check the integrity of binaries, and ensure malicious
tools are not installed. To implement an effective security
strategy, one must understand threats and how to defend against
them.What is a threat as it pertains to computer security?
Threats are not limited to remote attackers who attempt to
access a system without permission from a remote location.
Threats also include employees, malicious software, unauthorized
network devices, natural disasters, security vulnerabilities,
and even competing corporations.Systems and networks can be accessed without permission,
sometimes by accident, or by remote attackers, and in some
cases, via corporate espionage or former employees. As a user,
it is important to prepare for and admit when a mistake has lead
to a security breach and report possible issues to the security
team. As an administrator, it is important to know of the
threats and be prepared to mitigate them.When applying security to systems, it is recommended to
start by securing the basic accounts and system configuration,
and then to secure the network layer so that it adheres to the
system policy and the organization's security procedures. Many
organizations already have a security policy that covers the
configuration of technology devices. The policy should include
the security configuration of workstations, desktops, mobile
devices, phones, production servers, and development servers.
In many cases, standard operating procedures
(SOPs) already exist. When in doubt, ask the
security team.The rest of this introduction describes how some of these
basic security configurations are performed on a &os; system.
The rest of this chapter describes some specific tools which can
be used when implementing a security policy on a &os;
system.Preventing LoginsIn securing a system, a good starting point is an audit of
accounts. Ensure that root has a strong password and
that this password is not shared. Disable any accounts that
do not need login access.To deny login access to accounts, two methods exist. The
first is to lock the account. This example locks the
toor account:&prompt.root; pw lock toorThe second method is to prevent login access by changing
the shell to /sbin/nologin. Only the
superuser can change the shell for other users:&prompt.root; chsh -s /usr/sbin/nologin toorThe /usr/sbin/nologin shell prevents
the system from assigning a shell to the user when they
attempt to login.Permitted Account EscalationIn some cases, system administration needs to be shared
with other users. &os; has two methods to handle this. The
first one, which is not recommended, is a shared root password
used by members of the wheel group. With this
method, a user types su and enters the
password for wheel
whenever superuser access is needed. The user should then
type exit to leave privileged access after
finishing the commands that required administrative access.
To add a user to this group, edit
/etc/group and add the user to the end of
the wheel entry. The user must be
separated by a comma character with no space.The second, and recommended, method to permit privilege
escalation is to install the security/sudo
package or port. This software provides additional auditing,
more fine-grained user control, and can be configured to lock
users into running only the specified privileged
commands.After installation, use visudo to edit
/usr/local/etc/sudoers. This example
creates a new webadmin group, adds the
trhodes account to
that group, and configures that group access to restart
apache24:&prompt.root; pw groupadd webadmin -M trhodes -g 6000
&prompt.root; visudo
%webadmin ALL=(ALL) /usr/sbin/service apache24 *Password HashesPasswords are a necessary evil of technology. When they
must be used, they should be complex and a powerful hash
mechanism should be used to encrypt the version that is stored
in the password database. &os; supports the
DES, MD5,
SHA256, SHA512, and
Blowfish hash algorithms in its crypt()
library. The default of SHA512 should not
be changed to a less secure hashing algorithm, but can be
changed to the more secure Blowfish algorithm.Blowfish is not part of AES and is
not considered compliant with any Federal Information
Processing Standards (FIPS). Its use may
not be permitted in some environments.To determine which hash algorithm is used to encrypt a
user's password, the superuser can view the hash for the user
in the &os; password database. Each hash starts with a symbol
which indicates the type of hash mechanism used to encrypt the
password. If DES is used, there is no
beginning symbol. For MD5, the symbol is
$. For SHA256 and
SHA512, the symbol is
$6$. For Blowfish, the symbol is
$2a$. In this example, the password for
dru is hashed using
the default SHA512 algorithm as the hash
starts with $6$. Note that the encrypted
hash, not the password itself, is stored in the password
database:&prompt.root; grep dru /etc/master.passwd
dru:$6$pzIjSvCAn.PBYQBA$PXpSeWPx3g5kscj3IMiM7tUEUSPmGexxta.8Lt9TGSi2lNQqYGKszsBPuGME0:1001:1001::0:0:dru:/usr/home/dru:/bin/cshThe hash mechanism is set in the user's login class. For
this example, the user is in the default
login class and the hash algorithm is set with this line in
/etc/login.conf: :passwd_format=sha512:\To change the algorithm to Blowfish, modify that line to
look like this: :passwd_format=blf:\Then run cap_mkdb /etc/login.conf as
described in . Note that this
change will not affect any existing password hashes. This
means that all passwords should be re-hashed by asking users
to run passwd in order to change their
password.For remote logins, two-factor authentication should be
used. An example of two-factor authentication is
something you have, such as a key, and
something you know, such as the passphrase for
that key. Since OpenSSH is part of
the &os; base system, all network logins should be over an
encrypted connection and use key-based authentication instead
of passwords. For more information, refer to . Kerberos users may need to make
additional changes to implement
OpenSSH in their network. These
changes are described in .Password Policy EnforcementEnforcing a strong password policy for local accounts is a
fundamental aspect of system security. In &os;, password
length, password strength, and password complexity can be
implemented using built-in Pluggable Authentication Modules
(PAM).This section demonstrates how to configure the minimum and
maximum password length and the enforcement of mixed
characters using the pam_passwdqc.so
module. This module is enforced when a user changes their
password.To configure this module, become the superuser and
uncomment the line containing
pam_passwdqc.so in
/etc/pam.d/passwd. Then, edit that line
to match the password policy:password requisite pam_passwdqc.so min=disabled,disabled,disabled,12,10 similar=deny retry=3 enforce=usersThis example sets several requirements for new passwords.
The min setting controls the minimum
password length. It has five values because this module
defines five different types of passwords based on their
complexity. Complexity is defined by the type of characters
that must exist in a password, such as letters, numbers,
symbols, and case. The types of passwords are described in
&man.pam.passwdqc.8;. In this example, the first three types
of passwords are disabled, meaning that passwords that meet
those complexity requirements will not be accepted, regardless
of their length. The 12 sets a minimum
password policy of at least twelve characters, if the password
also contains characters with three types of complexity. The
10 sets the password policy to also allow
passwords of at least ten characters, if the password contains
characters with four types of complexity.The similar setting denies passwords
that are similar to the user's previous password. The
retry setting provides a user with three
opportunities to enter a new password.Once this file is saved, a user changing their password
will see a message similar to the following:&prompt.user; passwd
Changing local password for trhodes
Old Password:
You can now choose the new password.
A valid password should be a mix of upper and lower case letters,
digits and other characters. You can use a 12 character long
password with characters from at least 3 of these 4 classes, or
a 10 character long password containing characters from all the
classes. Characters that form a common pattern are discarded by
the check.
Alternatively, if noone else can see your terminal now, you can
pick this as your password: "trait-useful&knob".
Enter new password:If a password that does not match the policy is entered,
it will be rejected with a warning and the user will have an
opportunity to try again, up to the configured number of
retries.Most password policies require passwords to expire after
so many days. To set a password age time in &os;, set
for the user's login class in
/etc/login.conf. The
default login class contains an
example:# :passwordtime=90d:\So, to set an expiry of 90 days for this login class,
remove the comment symbol (#), save the
edit, and run cap_mkdb
/etc/login.conf.To set the expiration on individual users, pass an
expiration date or the number of days to expiry and a username
to pw:&prompt.root; pw usermod -p 30-apr-2015 -n trhodesAs seen here, an expiration date is set in the form of
day, month, and year. For more information, see
&man.pw.8;.Detecting RootkitsA rootkit is any unauthorized
software that attempts to gain root access to a system. Once
installed, this malicious software will normally open up
another avenue of entry for an attacker. Realistically, once
a system has been compromised by a rootkit and an
investigation has been performed, the system should be
reinstalled from scratch. There is tremendous risk that even
the most prudent security or systems engineer will miss
something an attacker left behind.A rootkit does do one thing usefulfor administrators: once
detected, it is a sign that a compromise happened at some
point. But, these types of applications tend to be very well
hidden. This section demonstrates a tool that can be used to
detect rootkits, security/rkhunter.After installation of this package or port, the system may
be checked using the following command. It will produce a lot
- of information and will require some manual pressing of the
- ENTER key:
+ of information and will require some manual pressing of
+ ENTER:
&prompt.root; rkhunter -cAfter the process completes, a status message will be
printed to the screen. This message will include the amount
of files checked, suspect files, possible rootkits, and more.
During the check, some generic security warnings may
be produced about hidden files, the
OpenSSH protocol selection, and
known vulnerable versions of installed software. These can be
handled now or after a more detailed analysis has been
performed.Every administrator should know what is running on the
systems they are responsible for. Third-party tools like
rkhunter and
sysutils/lsof, and native commands such
as netstat and ps, can
show a great deal of information on the system. Take notes on
what is normal, ask questions when something seems out of
place, and be paranoid. While preventing a compromise is
ideal, detecting a compromise is a must.Binary VerificationVerification of system files and binaries is important
because it provides the system administration and security
teams information about system changes. A software
application that monitors the system for changes is called an
Intrusion Detection System (IDS).&os; provides native support for a basic
IDS system. While the nightly security
emails will notify an administrator of changes, the
information is stored locally and there is a chance that a
malicious user could modify this information in order to hide
their changes to the system. As such, it is recommended to
create a separate set of binary signatures and store them on a
read-only, root-owned directory or, preferably, on a removable
USB disk or remote
rsync server.The built-in mtree utility can be used
to generate a specification of the contents of a directory. A
seed, or a numeric constant, is used to generate the
specification and is required to check that the specification
has not changed. This makes it possible to determine if a
file or binary has been modified. Since the seed value is
unknown by an attacker, faking or checking the checksum values
of files will be difficult to impossible. The following
example generates a set of SHA256 hashes,
one for each system binary in /bin, and
saves those values to a hidden file in root's home directory,
/root/.bin_chksum_mtree:&prompt.root; mtree -s 3483151339707503 -c -K cksum,sha256digest -p /bin > /root/.bin_chksum_mtree
&prompt.root; mtree: /bin checksum: 3427012225The 3483151339707503 represents
the seed. This value should be remembered, but not
shared.Viewing /root/.bin_cksum_mtree should
yield output similar to the following:# user: root
# machine: dreadnaught
# tree: /bin
# date: Mon Feb 3 10:19:53 2014
# .
/set type=file uid=0 gid=0 mode=0555 nlink=1 flags=none
. type=dir mode=0755 nlink=2 size=1024 \
time=1380277977.000000000
\133 nlink=2 size=11704 time=1380277977.000000000 \
cksum=484492447 \
sha256digest=6207490fbdb5ed1904441fbfa941279055c3e24d3a4049aeb45094596400662a
cat size=12096 time=1380277975.000000000 cksum=3909216944 \
sha256digest=65ea347b9418760b247ab10244f47a7ca2a569c9836d77f074e7a306900c1e69
chflags size=8168 time=1380277975.000000000 cksum=3949425175 \
sha256digest=c99eb6fc1c92cac335c08be004a0a5b4c24a0c0ef3712017b12c89a978b2dac3
chio size=18520 time=1380277975.000000000 cksum=2208263309 \
sha256digest=ddf7c8cb92a58750a675328345560d8cc7fe14fb3ccd3690c34954cbe69fc964
chmod size=8640 time=1380277975.000000000 cksum=2214429708 \
sha256digest=a435972263bf814ad8df082c0752aa2a7bdd8b74ff01431ccbd52ed1e490bbe7The machine's hostname, the date and time the
specification was created, and the name of the user who
created the specification are included in this report. There
is a checksum, size, time, and SHA256
digest for each binary in the directory.To verify that the binary signatures have not changed,
compare the current contents of the directory to the
previously generated specification, and save the results to a
file. This command requires the seed that was used to
generate the original specification:&prompt.root; mtree -s 3483151339707503 -p /bin < /root/.bin_chksum_mtree >> /root/.bin_chksum_output
&prompt.root; mtree: /bin checksum: 3427012225This should produce the same checksum for
/bin that was produced when the
specification was created. If no changes have occurred to the
binaries in this directory, the
/root/.bin_chksum_output output file will
be empty. To simulate a change, change the date on
/bin/cat using touch
and run the verification command again:&prompt.root; touch /bin/cat
&prompt.root; mtree -s 3483151339707503 -p /bin < /root/.bin_chksum_mtree >> /root/.bin_chksum_output
&prompt.root; more /root/.bin_chksum_output
cat changed
modification time expected Fri Sep 27 06:32:55 2013 found Mon Feb 3 10:28:43 2014It is recommended to create specifications for the
directories which contain binaries and configuration files, as
well as any directories containing sensitive data. Typically,
specifications are created for /bin,
/sbin, /usr/bin,
/usr/sbin,
/usr/local/bin,
/etc, and
/usr/local/etc.More advanced IDS systems exist, such
as security/aide. In most cases,
mtree provides the functionality
administrators need. It is important to keep the seed value
and the checksum output hidden from malicious users. More
information about mtree can be found in
&man.mtree.8;.System Tuning for SecurityIn &os;, many system features can be tuned using
sysctl. A few of the security features
which can be tuned to prevent Denial of Service
(DoS) attacks will be covered in this
section. More information about using
sysctl, including how to temporarily change
values and how to make the changes permanent after testing,
can be found in .Any time a setting is changed with
sysctl, the chance to cause undesired
harm is increased, affecting the availability of the system.
All changes should be monitored and, if possible, tried on a
testing system before being used on a production
system.By default, the &os; kernel boots with a security level of
-1. This is called insecure
mode because immutable file flags may be turned off
and all devices may be read from or written to. The security
level will remain at -1 unless it is
altered through sysctl or by a setting in
the startup scripts. The security level may be increased
during system startup by setting
kern_securelevel_enable to
YES in /etc/rc.conf,
and the value of kern_securelevel to the
desired security level. See &man.security.7; and &man.init.8;
for more information on these settings and the available
security levels.Increasing the securelevel can break
Xorg and cause other issues. Be
prepared to do some debugging.The net.inet.tcp.blackhole and
net.inet.udp.blackhole settings can be used
to drop incoming SYN packets on closed
ports without sending a return RST
response. The default behavior is to return an
RST to show a port is closed. Changing the
default provides some level of protection against ports scans,
which are used to determine which applications are running on
a system. Set net.inet.tcp.blackhole to
2 and
net.inet.udp.blackhole to
1. Refer to &man.blackhole.4; for more
information about these settings.The net.inet.icmp.drop_redirect and
net.inet.ip.redirect settings help prevent
against redirect attacks. A redirect
attack is a type of DoS which sends mass
numbers of ICMP type 5 packets. Since
these packets are not required, set
net.inet.icmp.drop_redirect to
1 and set
net.inet.ip.redirect to
0.Source routing is a method for detecting and accessing
non-routable addresses on the internal network. This should
be disabled as non-routable addresses are normally not
routable on purpose. To disable this feature, set
net.inet.ip.sourceroute and
net.inet.ip.accept_sourceroute to
0.When a machine on the network needs to send messages to
all hosts on a subnet, an ICMP echo request
message is sent to the broadcast address. However, there is
no reason for an external host to perform such an action. To
reject all external broadcast requests, set
net.inet.icmp.bmcastecho to
0.Some additional settings are documented in
&man.security.7;.One-time Passwordsone-time passwordssecurityone-time passwordsBy default, &os; includes support for One-time Passwords In
Everything (OPIE). OPIE
is designed to prevent replay attacks, in which an attacker
discovers a user's password and uses it to access a system.
Since a password is only used once in OPIE, a
discovered password is of little use to an attacker.
OPIE uses a secure hash and a
challenge/response system to manage passwords. The &os;
implementation uses the MD5 hash by
default.OPIE uses three different types of
passwords. The first is the usual &unix; or Kerberos password.
The second is the one-time password which is generated by
opiekey. The third type of password is the
secret password which is used to generate
one-time passwords. The secret password has nothing to do with,
and should be different from, the &unix; password.There are two other pieces of data that are important to
OPIE. One is the seed or
key, consisting of two letters and five digits.
The other is the iteration count, a number
between 1 and 100. OPIE creates the one-time
password by concatenating the seed and the secret password,
applying the MD5 hash as many times as
specified by the iteration count, and turning the result into
six short English words which represent the one-time password.
The authentication system keeps track of the last one-time
password used, and the user is authenticated if the hash of the
user-provided password is equal to the previous password.
Because a one-way hash is used, it is impossible to generate
future one-time passwords if a successfully used password is
captured. The iteration count is decremented after each
successful login to keep the user and the login program in sync.
When the iteration count gets down to 1,
OPIE must be reinitialized.There are a few programs involved in this process. A
one-time password, or a consecutive list of one-time passwords,
is generated by passing an iteration count, a seed, and a secret
password to &man.opiekey.1;. In addition to initializing
OPIE, &man.opiepasswd.1; is used to change
passwords, iteration counts, or seeds. The relevant credential
files in /etc/opiekeys are examined by
&man.opieinfo.1; which prints out the invoking user's current
iteration count and seed.This section describes four different sorts of operations.
The first is how to set up one-time-passwords for the first time
over a secure connection. The second is how to use
opiepasswd over an insecure connection. The
third is how to log in over an insecure connection. The fourth
is how to generate a number of keys which can be written down or
printed out to use at insecure locations.Initializing OPIETo initialize OPIE for the first time,
run this command from a secure location:&prompt.user; opiepasswd -c
[grimreaper] ~ $ opiepasswd -f -c
Adding unfurl:
Only use this method from the console; NEVER from remote. If you are using
telnet, xterm, or a dial-in, type ^C now or exit with no password.
Then run opiepasswd without the -c parameter.
Using MD5 to compute responses.
Enter new secret pass phrase:
Again new secret pass phrase:
ID unfurl OTP key is 499 to4268
MOS MALL GOAT ARM AVID COEDThe sets console mode which assumes
that the command is being run from a secure location, such as
a computer under the user's control or a
SSH session to a computer under the user's
control.When prompted, enter the secret password which will be
used to generate the one-time login keys. This password
should be difficult to guess and should be different than the
password which is associated with the user's login account.
It must be between 10 and 127 characters long. Remember this
password.The ID line lists the login name
(unfurl), default iteration count
(499), and default seed
(to4268). When logging in, the system will
remember these parameters and display them, meaning that they
do not have to be memorized. The last line lists the
generated one-time password which corresponds to those
parameters and the secret password. At the next login, use
this one-time password.Insecure Connection InitializationTo initialize or change the secret password on an
insecure system, a secure connection is needed to some place
where opiekey can be run. This might be a
shell prompt on a trusted machine. An iteration count is
needed, where 100 is probably a good value, and the seed can
either be specified or the randomly-generated one used. On
the insecure connection, the machine being initialized, use
&man.opiepasswd.1;:&prompt.user; opiepasswd
Updating unfurl:
You need the response from an OTP generator.
Old secret pass phrase:
otp-md5 498 to4268 ext
Response: GAME GAG WELT OUT DOWN CHAT
New secret pass phrase:
otp-md5 499 to4269
Response: LINE PAP MILK NELL BUOY TROY
ID mark OTP key is 499 gr4269
LINE PAP MILK NELL BUOY TROYTo accept the default seed, press Return.
Before entering an access password, move over to the secure
connection and give it the same parameters:&prompt.user; opiekey 498 to4268
Using the MD5 algorithm to compute response.
Reminder: Do not use opiekey from telnet or dial-in sessions.
Enter secret pass phrase:
GAME GAG WELT OUT DOWN CHATSwitch back over to the insecure connection, and copy the
generated one-time password over to the relevant
program.Generating a Single One-time PasswordAfter initializing OPIE and logging in,
a prompt like this will be displayed:&prompt.user; telnet example.com
Trying 10.0.0.1...
Connected to example.com
Escape character is '^]'.
FreeBSD/i386 (example.com) (ttypa)
login: <username>
otp-md5 498 gr4269 ext
Password: The OPIE prompts provides a useful
feature. If Return is pressed at the
password prompt, the prompt will turn echo on and display
what is typed. This can be useful when attempting to type in
a password by hand from a printout.MS-DOSWindowsMacOSAt this point, generate the one-time password to answer
this login prompt. This must be done on a trusted system
where it is safe to run &man.opiekey.1;. There are versions
of this command for &windows;, &macos; and &os;. This command
needs the iteration count and the seed as command line
options. Use cut-and-paste from the login prompt on the
machine being logged in to.On the trusted system:&prompt.user; opiekey 498 to4268
Using the MD5 algorithm to compute response.
Reminder: Do not use opiekey from telnet or dial-in sessions.
Enter secret pass phrase:
GAME GAG WELT OUT DOWN CHATOnce the one-time password is generated, continue to log
in.Generating Multiple One-time PasswordsSometimes there is no access to a trusted machine or
secure connection. In this case, it is possible to use
&man.opiekey.1; to generate a number of one-time passwords
beforehand. For example:&prompt.user; opiekey -n 5 30 zz99999
Using the MD5 algorithm to compute response.
Reminder: Do not use opiekey from telnet or dial-in sessions.
Enter secret pass phrase: <secret password>
26: JOAN BORE FOSS DES NAY QUIT
27: LATE BIAS SLAY FOLK MUCH TRIG
28: SALT TIN ANTI LOON NEAL USE
29: RIO ODIN GO BYE FURY TIC
30: GREW JIVE SAN GIRD BOIL PHIThe requests five keys in sequence,
and specifies what the last iteration
number should be. Note that these are printed out in
reverse order of use. The really
paranoid might want to write the results down by hand;
otherwise, print the list. Each line shows both the iteration
count and the one-time password. Scratch off the passwords as
they are used.Restricting Use of &unix; PasswordsOPIE can restrict the use of &unix;
passwords based on the IP address of a login session. The
relevant file is /etc/opieaccess, which
is present by default. Refer to &man.opieaccess.5; for more
information on this file and which security considerations to
be aware of when using it.Here is a sample opieaccess:permit 192.168.0.0 255.255.0.0This line allows users whose IP source address (which is
vulnerable to spoofing) matches the specified value and mask,
to use &unix; passwords at any time.If no rules in opieaccess are
matched, the default is to deny non-OPIE
logins.TCP WrapperTomRhodesWritten
by TCP WrapperTCP Wrapper is a host-based
access control system which extends the abilities of . It can be configured to provide
logging support, return messages, and connection restrictions
for the server daemons under the control of
inetd. Refer to &man.tcpd.8; for
more information about
TCP Wrapper and its features.TCP Wrapper should not be
considered a replacement for a properly configured firewall.
Instead, TCP Wrapper should be used
in conjunction with a firewall and other security enhancements
in order to provide another layer of protection in the
implementation of a security policy.Initial ConfigurationTo enable TCP Wrapper in &os;,
add the following lines to
/etc/rc.conf:inetd_enable="YES"
inetd_flags="-Ww"Then, properly configure
/etc/hosts.allow.Unlike other implementations of
TCP Wrapper, the use of
hosts.deny is deprecated in &os;. All
configuration options should be placed in
/etc/hosts.allow.In the simplest configuration, daemon connection policies
are set to either permit or block, depending on the options in
/etc/hosts.allow. The default
configuration in &os; is to allow all connections to the
daemons started with inetd.Basic configuration usually takes the form of
daemon : address : action, where
daemon is the daemon which
inetd started,
address is a valid hostname,
IP address, or an IPv6 address enclosed in
brackets ([ ]), and action is either
allow or deny.
TCP Wrapper uses a first rule match
semantic, meaning that the configuration file is scanned from
the beginning for a matching rule. When a match is found, the
rule is applied and the search process stops.For example, to allow POP3 connections
via the mail/qpopper daemon, the following
lines should be appended to
hosts.allow:# This line is required for POP3 connections:
qpopper : ALL : allowWhenever this file is edited, restart
inetd:&prompt.root; service inetd restartAdvanced ConfigurationTCP Wrapper provides advanced
options to allow more control over the way connections are
handled. In some cases, it may be appropriate to return a
comment to certain hosts or daemon connections. In other
cases, a log entry should be recorded or an email sent to the
administrator. Other situations may require the use of a
service for local connections only. This is all possible
through the use of configuration options known as wildcards,
expansion characters, and external command execution.Suppose that a situation occurs where a connection should
be denied yet a reason should be sent to the host who
attempted to establish that connection. That action is
possible with . When a connection
attempt is made, executes a shell
command or script. An example exists in
hosts.allow:# The rest of the daemons are protected.
ALL : ALL \
: severity auth.info \
: twist /bin/echo "You are not welcome to use %d from %h."In this example, the message You are not allowed to
use daemon name from
hostname. will be
returned for any daemon not configured in
hosts.allow. This is useful for sending
a reply back to the connection initiator right after the
established connection is dropped. Any message returned
must be wrapped in quote
(") characters.It may be possible to launch a denial of service attack
on the server if an attacker floods these daemons with
connection requests.Another possibility is to use .
Like , implicitly
denies the connection and may be used to run external shell
commands or scripts. Unlike ,
will not send a reply back to the host
who established the connection. For example, consider the
following configuration:# We do not allow connections from example.com:
ALL : .example.com \
: spawn (/bin/echo %a from %h attempted to access %d >> \
/var/log/connections.log) \
: denyThis will deny all connection attempts from *.example.com and log the
hostname, IP address, and the daemon to
which access was attempted to
/var/log/connections.log. This example
uses the substitution characters %a and
%h. Refer to &man.hosts.access.5; for the
complete list.To match every instance of a daemon, domain, or
IP address, use ALL.
Another wildcard is PARANOID which may be
used to match any host which provides an IP
address that may be forged because the IP
address differs from its resolved hostname. In this example,
all connection requests to Sendmail
which have an IP address that varies from
its hostname will be denied:# Block possibly spoofed requests to sendmail:
sendmail : PARANOID : denyUsing the PARANOID wildcard will
result in denied connections if the client or server has a
broken DNS setup.To learn more about wildcards and their associated
functionality, refer to &man.hosts.access.5;.When adding new configuration lines, make sure that any
unneeded entries for that daemon are commented out in
hosts.allow.KerberosTillmanHodgsonContributed by MarkMurrayBased on a contribution by Kerberos is a network
authentication protocol which was originally created by the
Massachusetts Institute of Technology (MIT)
as a way to securely provide authentication across a potentially
hostile network. The Kerberos
protocol uses strong cryptography so that both a client and
server can prove their identity without sending any unencrypted
secrets over the network. Kerberos
can be described as an identity-verifying proxy system and as a
trusted third-party authentication system. After a user
authenticates with Kerberos, their
communications can be encrypted to assure privacy and data
integrity.The only function of Kerberos is
to provide the secure authentication of users and servers on the
network. It does not provide authorization or auditing
functions. It is recommended that
Kerberos be used with other security
methods which provide authorization and audit services.The current version of the protocol is version 5, described
in RFC 4120. Several free
implementations of this protocol are available, covering a wide
range of operating systems. MIT continues to
develop their Kerberos package. It
is commonly used in the US as a cryptography
product, and has historically been subject to
US export regulations. In &os;,
MIT Kerberos is
available as the security/krb5 package or
port. The Heimdal Kerberos
implementation was explicitly developed outside of the
US to avoid export regulations. The Heimdal
Kerberos distribution is included in
the base &os; installation, and another distribution with more
configurable options is available as
security/heimdal in the Ports
Collection.In Kerberos users and services
are identified as principals which are contained
within an administrative grouping, called a
realm. A typical user principal would be of the
form
user@REALM
(realms are traditionally uppercase).This section provides a guide on how to set up
Kerberos using the Heimdal
distribution included in &os;.For purposes of demonstrating a
Kerberos installation, the name
spaces will be as follows:The DNS domain (zone) will be
example.org.The Kerberos realm will be
EXAMPLE.ORG.Use real domain names when setting up
Kerberos, even if it will run
internally. This avoids DNS problems and
assures inter-operation with other
Kerberos realms.Setting up a Heimdal KDCKerberos5Key Distribution CenterThe Key Distribution Center (KDC) is
the centralized authentication service that
Kerberos provides, the
trusted third party of the system. It is the
computer that issues Kerberos
tickets, which are used for clients to authenticate to
servers. Because the KDC is considered
trusted by all other computers in the
Kerberos realm, it has heightened
security concerns. Direct access to the KDC should be
limited.While running a KDC requires few
computing resources, a dedicated machine acting only as a
KDC is recommended for security
reasons.To begin setting up a KDC, add these
lines to /etc/rc.conf:kerberos5_server_enable="YES"
kadmind5_server_enable="YES"Next, edit /etc/krb5.conf as
follows:[libdefaults]
default_realm = EXAMPLE.ORG
[realms]
EXAMPLE.ORG = {
kdc = kerberos.example.org
admin_server = kerberos.example.org
}
[domain_realm]
.example.org = EXAMPLE.ORGIn this example, the KDC will use the
fully-qualified hostname kerberos.example.org. The
hostname of the KDC must be resolvable in the
DNS.Kerberos can also use the
DNS to locate KDCs, instead of a
[realms] section in
/etc/krb5.conf. For large organizations
that have their own DNS servers, the above
example could be trimmed to:[libdefaults]
default_realm = EXAMPLE.ORG
[domain_realm]
.example.org = EXAMPLE.ORGWith the following lines being included in the
example.org zone
file:_kerberos._udp IN SRV 01 00 88 kerberos.example.org.
_kerberos._tcp IN SRV 01 00 88 kerberos.example.org.
_kpasswd._udp IN SRV 01 00 464 kerberos.example.org.
_kerberos-adm._tcp IN SRV 01 00 749 kerberos.example.org.
_kerberos IN TXT EXAMPLE.ORGIn order for clients to be able to find the
Kerberos services, they
must have either
a fully configured /etc/krb5.conf or a
minimally configured /etc/krb5.confand a properly configured
DNS server.Next, create the Kerberos
database which contains the keys of all principals (users and
hosts) encrypted with a master password. It is not required
to remember this password as it will be stored in
/var/heimdal/m-key; it would be
reasonable to use a 45-character random password for this
purpose. To create the master key, run
kstash and enter a password:&prompt.root; kstash
Master key: xxxxxxxxxxxxxxxxxxxxxxx
Verifying password - Master key: xxxxxxxxxxxxxxxxxxxxxxxOnce the master key has been created, the database should
be initialized. The Kerberos
administrative tool &man.kadmin.8; can be used on the KDC in a
mode that operates directly on the database, without using the
&man.kadmind.8; network service, as
kadmin -l. This resolves the
chicken-and-egg problem of trying to connect to the database
before it is created. At the kadmin
prompt, use init to create the realm's
initial database:&prompt.root; kadmin -l
kadmin> init EXAMPLE.ORG
Realm max ticket life [unlimited]:Lastly, while still in kadmin, create
the first principal using add. Stick to
the default options for the principal for now, as these can be
changed later with modify. Type
? at the prompt to see the available
options.kadmin> add tillman
Max ticket life [unlimited]:
Max renewable life [unlimited]:
Attributes []:
Password: xxxxxxxx
Verifying password - Password: xxxxxxxxNext, start the KDC services by running
service kerberos start and
service kadmind start. While there will
not be any kerberized daemons running at this point, it is
possible to confirm that the KDC is
functioning by obtaining a ticket for the
principal that was just created:&prompt.user; kinit tillman
tillman@EXAMPLE.ORG's Password:Confirm that a ticket was successfully obtained using
klist:&prompt.user; klist
Credentials cache: FILE:/tmp/krb5cc_1001
Principal: tillman@EXAMPLE.ORG
Issued Expires Principal
Aug 27 15:37:58 2013 Aug 28 01:37:58 2013 krbtgt/EXAMPLE.ORG@EXAMPLE.ORGThe temporary ticket can be destroyed when the test is
finished:&prompt.user; kdestroyConfiguring a Server to Use
KerberosKerberos5enabling servicesThe first step in configuring a server to use
Kerberos authentication is to
ensure that it has the correct configuration in
/etc/krb5.conf. The version from the
KDC can be used as-is, or it can be
regenerated on the new system.Next, create /etc/krb5.keytab on the
server. This is the main part of Kerberizing a
service — it corresponds to generating a secret shared
between the service and the KDC. The
secret is a cryptographic key, stored in a
keytab. The keytab contains the server's host
key, which allows it and the KDC to verify
each others' identity. It must be transmitted to the server
in a secure fashion, as the security of the server can be
broken if the key is made public. Typically, the
keytab is generated on an administrator's
trusted machine using kadmin, then securely
transferred to the server, e.g., with &man.scp.1;; it can also
be created directly on the server if that is consistent with
the desired security policy. It is very important that the
keytab is transmitted to the server in a secure fashion: if
the key is known by some other party, that party can
impersonate any user to the server! Using
kadmin on the server directly is
convenient, because the entry for the host principal in the
KDC database is also created using
kadmin.Of course, kadmin is a kerberized
service; a Kerberos ticket is
needed to authenticate to the network service, but to ensure
that the user running kadmin is actually
present (and their session has not been hijacked),
kadmin will prompt for the password to get
a fresh ticket. The principal authenticating to the kadmin
service must be permitted to use the kadmin
interface, as specified in kadmind.acl.
See the section titled Remote administration in
info heimdal for details on designing
access control lists. Instead of enabling remote
kadmin access, the administrator could
securely connect to the KDC via the local
console or &man.ssh.1;, and perform administration locally
using kadmin -l.After installing /etc/krb5.conf,
use add --random-key in
kadmin. This adds the server's host
principal to the database, but does not extract a copy of the
host principal key to a keytab. To generate the keytab, use
ext to extract the server's host principal
key to its own keytab:&prompt.root; kadmin
kadmin> add --random-key host/myserver.example.org
Max ticket life [unlimited]:
Max renewable life [unlimited]:
Principal expiration time [never]:
Password expiration time [never]:
Attributes []:
kadmin> ext_keytab host/myserver.example.org
kadmin> exitNote that ext_keytab stores the
extracted key in /etc/krb5.keytab by
default. This is good when being run on the server being
kerberized, but the --keytab
path/to/file argument
should be used when the keytab is being extracted
elsewhere:&prompt.root; kadmin
kadmin> ext_keytab --keytab=/tmp/example.keytab host/myserver.example.org
kadmin> exitThe keytab can then be securely copied to the server
using &man.scp.1; or a removable media. Be sure to specify a
non-default keytab name to avoid inserting unneeded keys into
the system's keytab.At this point, the server can read encrypted messages from
the KDC using its shared key, stored in
krb5.keytab. It is now ready for the
Kerberos-using services to be
enabled. One of the most common such services is
&man.sshd.8;, which supports
Kerberos via the
GSS-API. In
/etc/ssh/sshd_config, add the
line:GSSAPIAuthentication yesAfter making this change, &man.sshd.8; must be restared
for the new configuration to take effect:
service sshd restart.Configuring a Client to Use
KerberosKerberos5configure clientsAs it was for the server, the client requires
configuration in /etc/krb5.conf. Copy
the file in place (securely) or re-enter it as needed.Test the client by using kinit,
klist, and kdestroy from
the client to obtain, show, and then delete a ticket for an
existing principal. Kerberos
applications should also be able to connect to
Kerberos enabled servers. If that
does not work but obtaining a ticket does, the problem is
likely with the server and not with the client or the
KDC. In the case of kerberized
&man.ssh.1;, GSS-API is disabled by
default, so test using ssh -o
GSSAPIAuthentication=yes
hostname.When testing a Kerberized application, try using a packet
sniffer such as tcpdump to confirm that no
sensitive information is sent in the clear.Various Kerberos client
applications are available. With the advent of a bridge so
that applications using SASL for
authentication can use GSS-API mechanisms
as well, large classes of client applications can use
Kerberos for authentication, from
Jabber clients to IMAP clients..k5login.k5usersUsers within a realm typically have their
Kerberos principal mapped to a
local user account. Occasionally, one needs to grant access
to a local user account to someone who does not have a
matching Kerberos principal. For
example, tillman@EXAMPLE.ORG may need
access to the local user account webdevelopers. Other
principals may also need access to that local account.The .k5login and
.k5users files, placed in a user's home
directory, can be used to solve this problem. For example, if
the following .k5login is placed in the
home directory of webdevelopers, both principals
listed will have access to that account without requiring a
shared password.:tillman@example.org
jdoe@example.orgRefer to &man.ksu.1; for more information about
.k5users.MIT DifferencesThe major difference between the MIT
and Heimdal implementations is that kadmin
has a different, but equivalent, set of commands and uses a
different protocol. If the KDC is
MIT, the Heimdal version of
kadmin cannot be used to administer the
KDC remotely, and vice versa.Client applications may also use slightly different
command line options to accomplish the same tasks. Following
the instructions at http://web.mit.edu/Kerberos/www/
is recommended. Be careful of path issues: the
MIT port installs into
/usr/local/ by default, and the &os;
system applications run instead of the
MIT versions if PATH lists
the system directories first.When using MIT Kerberos as a KDC on
&os;, the following edits should also be made to
rc.conf:kerberos5_server="/usr/local/sbin/krb5kdc"
kadmind5_server="/usr/local/sbin/kadmind"
kerberos5_server_flags=""
kerberos5_server_enable="YES"
kadmind5_server_enable="YES"Kerberos Tips, Tricks, and
TroubleshootingWhen configuring and troubleshooting
Kerberos, keep the following points
in mind:When using either Heimdal or MIT
Kerberos from ports, ensure
that the PATH lists the port's versions of
the client applications before the system versions.If all the computers in the realm do not have
synchronized time settings, authentication may fail.
describes how to synchronize
clocks using NTP.If the hostname is changed, the host/ principal must be
changed and the keytab updated. This also applies to
special keytab entries like the HTTP/ principal used for
Apache's www/mod_auth_kerb.All hosts in the realm must be both forward and
reverse resolvable in DNS or, at a
minimum, exist in /etc/hosts. CNAMEs
will work, but the A and PTR records must be correct and
in place. The error message for unresolvable hosts is not
intuitive: Kerberos5 refuses authentication
because Read req failed: Key table entry not
found.Some operating systems that act as clients to the
KDC do not set the permissions for
ksu to be setuid root. This means that
ksu does not work. This is a
permissions problem, not a KDC
error.With MIT
Kerberos, to allow a principal
to have a ticket life longer than the default lifetime of
ten hours, use modify_principal at the
&man.kadmin.8; prompt to change the
maxlife of both the principal in
question and the
krbtgt
principal. The principal can then use
kinit -l to request a ticket with a
longer lifetime.When running a packet sniffer on the
KDC to aid in troubleshooting while
running kinit from a workstation, the
Ticket Granting Ticket (TGT) is sent
immediately, even before the password is typed. This is
because the Kerberos server
freely transmits a TGT to any
unauthorized request. However, every
TGT is encrypted in a key derived from
the user's password. When a user types their password, it
is not sent to the KDC, it is instead
used to decrypt the TGT that
kinit already obtained. If the
decryption process results in a valid ticket with a valid
time stamp, the user has valid
Kerberos credentials. These
credentials include a session key for establishing secure
communications with the
Kerberos server in the future,
as well as the actual TGT, which is
encrypted with the Kerberos
server's own key. This second layer of encryption allows
the Kerberos server to verify
the authenticity of each TGT.Host principals can have a longer ticket lifetime. If
the user principal has a lifetime of a week but the host
being connected to has a lifetime of nine hours, the user
cache will have an expired host principal and the ticket
cache will not work as expected.When setting up krb5.dict to
prevent specific bad passwords from being used as
described in &man.kadmind.8;, remember that it only
applies to principals that have a password policy assigned
to them. The format used in
krb5.dict is one string per line.
Creating a symbolic link to
/usr/share/dict/words might be
useful.Mitigating Kerberos
LimitationsKerberos5limitations and shortcomingsSince Kerberos is an all or
nothing approach, every service enabled on the network must
either be modified to work with
Kerberos or be otherwise secured
against network attacks. This is to prevent user credentials
from being stolen and re-used. An example is when
Kerberos is enabled on all remote
shells but the non-Kerberized POP3 mail
server sends passwords in plain text.The KDC is a single point of failure.
By design, the KDC must be as secure as its
master password database. The KDC should
have absolutely no other services running on it and should be
physically secure. The danger is high because
Kerberos stores all passwords
encrypted with the same master key which is stored as a file
on the KDC.A compromised master key is not quite as bad as one might
fear. The master key is only used to encrypt the
Kerberos database and as a seed for
the random number generator. As long as access to the
KDC is secure, an attacker cannot do much
with the master key.If the KDC is unavailable, network
services are unusable as authentication cannot be performed.
This can be alleviated with a single master
KDC and one or more slaves, and with
careful implementation of secondary or fall-back
authentication using PAM.Kerberos allows users, hosts
and services to authenticate between themselves. It does not
have a mechanism to authenticate the
KDC to the users, hosts, or services. This
means that a trojanned kinit could record
all user names and passwords. File system integrity checking
tools like security/tripwire can
alleviate this.Resources and Further InformationKerberos5external resources
The Kerberos
FAQDesigning
an Authentication System: a Dialog in Four
ScenesRFC
4120, The Kerberos Network
Authentication Service (V5)MIT
Kerberos home
pageHeimdal
Kerberos home
pageOpenSSLTomRhodesWritten
by securityOpenSSLOpenSSL is an open source
implementation of the SSL and
TLS protocols. It provides an encryption
transport layer on top of the normal communications layer,
allowing it to be intertwined with many network applications and
services.The version of OpenSSL included
in &os; supports the Secure Sockets Layer v2/v3 (SSLv2/SSLv3)
and Transport Layer Security v1 (TLSv1) network security
protocols and can be used as a general cryptographic
library.OpenSSL is often used to encrypt
authentication of mail clients and to secure web based
transactions such as credit card payments. Some ports, such as
www/apache24 and
databases/postgresql91-server, include a
compile option for building with
OpenSSL.&os; provides two versions of
OpenSSL: one in the base system and
one in the Ports Collection. Users can choose which version to
use by default for other ports using the following knobs:WITH_OPENSSL_PORT: when set, the port will use
OpenSSL from the
security/openssl port, even if the
version in the base system is up to date or newer.WITH_OPENSSL_BASE: when set, the port will compile
against OpenSSL provided by the
base system.Another common use of OpenSSL is
to provide certificates for use with software applications.
Certificates can be used to verify the credentials of a company
or individual. If a certificate has not been signed by an
external Certificate Authority
(CA), such as http://www.verisign.com,
the application that uses the certificate will produce a
warning. There is a cost associated with obtaining a signed
certificate and using a signed certificate is not mandatory as
certificates can be self-signed. However, using an external
authority will prevent warnings and can put users at
ease.This section demonstrates how to create and use certificates
on a &os; system. Refer to for an
example of how to create a CA for signing
one's own certificates.Generating CertificatesOpenSSLcertificate generationTo generate a certificate that will be signed by an
external CA, issue the following command
and input the information requested at the prompts. This
input information will be written to the certificate. At the
Common Name prompt, input the fully
qualified name for the system that will use the certificate.
If this name does not match the server, the application
verifying the certificate will issue a warning to the user,
rendering the verification provided by the certificate as
useless.&prompt.root; openssl req -new -nodes -out req.pem -keyout cert.pem
Generating a 1024 bit RSA private key
................++++++
.......................................++++++
writing new private key to 'cert.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:PA
Locality Name (eg, city) []:Pittsburgh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:Systems Administrator
Common Name (eg, YOUR name) []:localhost.example.org
Email Address []:trhodes@FreeBSD.org
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:SOME PASSWORD
An optional company name []:Another NameOther options, such as the expire time and alternate
encryption algorithms, are available when creating a
certificate. A complete list of options is described in
&man.openssl.1;.This command will create two files in the current
directory. The certificate request,
req.pem, can be sent to a
CA who will validate the entered
credentials, sign the request, and return the signed
certificate. The second file,
cert.pem, is the private key for the
certificate and should be stored in a secure location. If
this falls in the hands of others, it can be used to
impersonate the user or the server.Alternately, if a signature from a CA
is not required, a self-signed certificate can be created.
First, generate the RSA key:&prompt.root; openssl dsaparam -rand -genkey -out myRSA.key 1024
0 semi-random bytes loaded
Generating DSA parameters, 1024 bit long prime
This could take some time
.............+........+...........+...+....+........+.....+++++++++++++++++++++++++++++++++++++++++++++++++++*
..........+.+...........+....+........+.................+.+++++++++++++++++++++++++++++++++++++++++++++++++++*Next, generate the CA key. When
prompted, enter a passphrase between 4 to 1023 characters.
Remember this passphrase as it is needed whenever the key is
used to sign a certificate.&prompt.root; openssl gendsa -des3 -out myca.key myRSA.key
Generating DSA key, 1024 bits
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:Use this key to create a self-signed certificate. When
prompted, enter the passphrase. Then follow the usual prompts
for creating a certificate:&prompt.root; openssl req -new -x509 -days 365 -key myca.key -out new.crt
Enter pass phrase for myca.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:PA
Locality Name (eg, city) []:Pittsburgh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:Systems Administrator
Common Name (e.g. server FQDN or YOUR name) []:localhost.example.org
Email Address []:trhodes@FreeBSD.orgThis will create two new files in the current directory: a
certificate authority signature file,
myca.key, and the certificate itself,
new.crt. These should be placed in a
directory, preferably under /etc, which
is readable only by root. Permissions of
0700 are appropriate for these files and
can be set using chmod.Using CertificatesOne use for a certificate is to encrypt connections to the
Sendmail mail server in order to
prevent the use of clear text authentication.Some mail clients will display an error if the user has
not installed a local copy of the certificate. Refer to the
documentation included with the software for more
information on certificate installation.In &os; 10.0-RELEASE and above, it is possible to create a
self-signed certificate for
Sendmail automatically. To enable
this, add the following lines to
/etc/rc.conf:sendmail_enable="YES"
sendmail_cert_create="YES"
sendmail_cert_cn="localhost.example.org"This will automatically create a self-signed certificate,
/etc/mail/certs/host.cert, a signing key,
/etc/mail/certs/host.key, and a
CA certificate,
/etc/mail/certs/cacert.pem. The
certificate will use the Common Name
specified in . After saving
the edits, restart Sendmail:&prompt.root; service sendmail restartIf all went well, there will be no error messages in
/var/log/maillog. For a simple test,
connect to the mail server's listening port using
telnet:&prompt.root; telnet example.com 25
Trying 192.0.34.166...
Connected to example.com.
Escape character is '^]'.
220 example.com ESMTP Sendmail 8.14.7/8.14.7; Fri, 18 Apr 2014 11:50:32 -0400 (EDT)
ehlo example.com
250-example.com Hello example.com [192.0.34.166], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH LOGIN PLAIN
250-STARTTLS
250-DELIVERBY
250 HELP
quit
221 2.0.0 example.com closing connection
Connection closed by foreign host.If the STARTTLS line appears in the
output, everything is working correctly.VPN over
IPsecNikClaytonnik@FreeBSD.orgWritten by Hiten M.Pandyahmp@FreeBSD.orgWritten by IPsecInternet Protocol Security (IPsec) is a
set of protocols which sit on top of the Internet Protocol
(IP) layer. It allows two or more hosts to
communicate in a secure manner by authenticating and encrypting
each IP packet of a communication session.
The &os; IPsec network stack is based on the
http://www.kame.net/
implementation and supports both IPv4 and
IPv6 sessions.IPsecESPIPsecAHIPsec is comprised of the following
sub-protocols:Encapsulated Security Payload
(ESP): this protocol
protects the IP packet data from third
party interference by encrypting the contents using
symmetric cryptography algorithms such as Blowfish and
3DES.Authentication Header
(AH)): this protocol
protects the IP packet header from third
party interference and spoofing by computing a cryptographic
checksum and hashing the IP packet
header fields with a secure hashing function. This is then
followed by an additional header that contains the hash, to
allow the information in the packet to be
authenticated.IP Payload Compression Protocol
(IPComp): this protocol
tries to increase communication performance by compressing
the IP payload in order ro reduce the
amount of data sent.These protocols can either be used together or separately,
depending on the environment.VPNvirtual private networkVPNIPsec supports two modes of operation.
The first mode, Transport Mode, protects
communications between two hosts. The second mode,
Tunnel Mode, is used to build virtual
tunnels, commonly known as Virtual Private Networks
(VPNs). Consult &man.ipsec.4; for detailed
information on the IPsec subsystem in
&os;.To add IPsec support to the kernel, add
the following options to the custom kernel configuration file
and rebuild the kernel using the instructions in :kernel optionsIPSECoptions IPSEC #IP security
device cryptokernel optionsIPSEC_DEBUGIf IPsec debugging support is desired,
the following kernel option should also be added:options IPSEC_DEBUG #debug for IP securityThis rest of this chapter demonstrates the process of
setting up an IPsec VPN
between a home network and a corporate network. In the example
scenario:Both sites are connected to the Internet through a
gateway that is running &os;.The gateway on each network has at least one external
IP address. In this example, the
corporate LAN's external
IP address is 172.16.5.4 and the home
LAN's external IP
address is 192.168.1.12.The internal addresses of the two networks can be either
public or private IP addresses. However,
the address space must not collide. For example, both
networks cannot use 192.168.1.x. In this
example, the corporate LAN's internal
IP address is 10.246.38.1 and the home
LAN's internal IP
address is 10.0.0.5.Configuring a VPN on &os;TomRhodestrhodes@FreeBSD.orgWritten by To begin, security/ipsec-tools must be
installed from the Ports Collection. This software provides a
number of applications which support the configuration.The next requirement is to create two &man.gif.4;
pseudo-devices which will be used to tunnel packets and allow
both networks to communicate properly. As root, run the following
commands, replacing internal and
external with the real IP
addresses of the internal and external interfaces of the two
gateways:&prompt.root; ifconfig gif0 create
&prompt.root; ifconfig gif0 internal1 internal2
&prompt.root; ifconfig gif0 tunnel external1 external2Verify the setup on each gateway, using
ifconfig. Here is the output from Gateway
1:gif0: flags=8051 mtu 1280
tunnel inet 172.16.5.4 --> 192.168.1.12
inet6 fe80::2e0:81ff:fe02:5881%gif0 prefixlen 64 scopeid 0x6
inet 10.246.38.1 --> 10.0.0.5 netmask 0xffffff00Here is the output from Gateway 2:gif0: flags=8051 mtu 1280
tunnel inet 192.168.1.12 --> 172.16.5.4
inet 10.0.0.5 --> 10.246.38.1 netmask 0xffffff00
inet6 fe80::250:bfff:fe3a:c1f%gif0 prefixlen 64 scopeid 0x4Once complete, both internal IP
addresses should be reachable using &man.ping.8;:priv-net# ping 10.0.0.5
PING 10.0.0.5 (10.0.0.5): 56 data bytes
64 bytes from 10.0.0.5: icmp_seq=0 ttl=64 time=42.786 ms
64 bytes from 10.0.0.5: icmp_seq=1 ttl=64 time=19.255 ms
64 bytes from 10.0.0.5: icmp_seq=2 ttl=64 time=20.440 ms
64 bytes from 10.0.0.5: icmp_seq=3 ttl=64 time=21.036 ms
--- 10.0.0.5 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 19.255/25.879/42.786/9.782 ms
corp-net# ping 10.246.38.1
PING 10.246.38.1 (10.246.38.1): 56 data bytes
64 bytes from 10.246.38.1: icmp_seq=0 ttl=64 time=28.106 ms
64 bytes from 10.246.38.1: icmp_seq=1 ttl=64 time=42.917 ms
64 bytes from 10.246.38.1: icmp_seq=2 ttl=64 time=127.525 ms
64 bytes from 10.246.38.1: icmp_seq=3 ttl=64 time=119.896 ms
64 bytes from 10.246.38.1: icmp_seq=4 ttl=64 time=154.524 ms
--- 10.246.38.1 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 28.106/94.594/154.524/49.814 msAs expected, both sides have the ability to send and
receive ICMP packets from the privately
configured addresses. Next, both gateways must be told how to
route packets in order to correctly send traffic from either
network. The following commands will achieve this
goal:&prompt.root; corp-net# route add 10.0.0.0 10.0.0.5 255.255.255.0
&prompt.root; corp-net# route add net 10.0.0.0: gateway 10.0.0.5
&prompt.root; priv-net# route add 10.246.38.0 10.246.38.1 255.255.255.0
&prompt.root; priv-net# route add host 10.246.38.0: gateway 10.246.38.1At this point, internal machines should be reachable from
each gateway as well as from machines behind the gateways.
Again, use &man.ping.8; to confirm:corp-net# ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8): 56 data bytes
64 bytes from 10.0.0.8: icmp_seq=0 ttl=63 time=92.391 ms
64 bytes from 10.0.0.8: icmp_seq=1 ttl=63 time=21.870 ms
64 bytes from 10.0.0.8: icmp_seq=2 ttl=63 time=198.022 ms
64 bytes from 10.0.0.8: icmp_seq=3 ttl=63 time=22.241 ms
64 bytes from 10.0.0.8: icmp_seq=4 ttl=63 time=174.705 ms
--- 10.0.0.8 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 21.870/101.846/198.022/74.001 ms
priv-net# ping 10.246.38.107
PING 10.246.38.1 (10.246.38.107): 56 data bytes
64 bytes from 10.246.38.107: icmp_seq=0 ttl=64 time=53.491 ms
64 bytes from 10.246.38.107: icmp_seq=1 ttl=64 time=23.395 ms
64 bytes from 10.246.38.107: icmp_seq=2 ttl=64 time=23.865 ms
64 bytes from 10.246.38.107: icmp_seq=3 ttl=64 time=21.145 ms
64 bytes from 10.246.38.107: icmp_seq=4 ttl=64 time=36.708 ms
--- 10.246.38.107 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 21.145/31.721/53.491/12.179 msSetting up the tunnels is the easy part. Configuring a
secure link is a more in depth process. The following
configuration uses pre-shared (PSK)
RSA keys. Other than the
IP addresses, the
/usr/local/etc/racoon/racoon.conf on both
gateways will be identical and look similar to:path pre_shared_key "/usr/local/etc/racoon/psk.txt"; #location of pre-shared key file
log debug; #log verbosity setting: set to 'notify' when testing and debugging is complete
padding # options are not to be changed
{
maximum_length 20;
randomize off;
strict_check off;
exclusive_tail off;
}
timer # timing options. change as needed
{
counter 5;
interval 20 sec;
persend 1;
# natt_keepalive 15 sec;
phase1 30 sec;
phase2 15 sec;
}
listen # address [port] that racoon will listen on
{
isakmp 172.16.5.4 [500];
isakmp_natt 172.16.5.4 [4500];
}
remote 192.168.1.12 [500]
{
exchange_mode main,aggressive;
doi ipsec_doi;
situation identity_only;
my_identifier address 172.16.5.4;
peers_identifier address 192.168.1.12;
lifetime time 8 hour;
passive off;
proposal_check obey;
# nat_traversal off;
generate_policy off;
proposal {
encryption_algorithm blowfish;
hash_algorithm md5;
authentication_method pre_shared_key;
lifetime time 30 sec;
dh_group 1;
}
}
sainfo (address 10.246.38.0/24 any address 10.0.0.0/24 any) # address $network/$netmask $type address $network/$netmask $type ( $type being any or esp)
{ # $network must be the two internal networks you are joining.
pfs_group 1;
lifetime time 36000 sec;
encryption_algorithm blowfish,3des,des;
authentication_algorithm hmac_md5,hmac_sha1;
compression_algorithm deflate;
}For descriptions of each available option, refer to the
manual page for racoon.conf.The Security Policy Database (SPD)
needs to be configured so that &os; and
racoon are able to encrypt and
decrypt network traffic between the hosts.This can be achieved with a shell script, similar to the
following, on the corporate gateway. This file will be used
during system initialization and should be saved as
/usr/local/etc/racoon/setkey.conf.flush;
spdflush;
# To the home network
spdadd 10.246.38.0/24 10.0.0.0/24 any -P out ipsec esp/tunnel/172.16.5.4-192.168.1.12/use;
spdadd 10.0.0.0/24 10.246.38.0/24 any -P in ipsec esp/tunnel/192.168.1.12-172.16.5.4/use;Once in place, racoon may be
started on both gateways using the following command:&prompt.root; /usr/local/sbin/racoon -F -f /usr/local/etc/racoon/racoon.conf -l /var/log/racoon.logThe output should be similar to the following:corp-net# /usr/local/sbin/racoon -F -f /usr/local/etc/racoon/racoon.conf
Foreground mode.
2006-01-30 01:35:47: INFO: begin Identity Protection mode.
2006-01-30 01:35:48: INFO: received Vendor ID: KAME/racoon
2006-01-30 01:35:55: INFO: received Vendor ID: KAME/racoon
2006-01-30 01:36:04: INFO: ISAKMP-SA established 172.16.5.4[500]-192.168.1.12[500] spi:623b9b3bd2492452:7deab82d54ff704a
2006-01-30 01:36:05: INFO: initiate new phase 2 negotiation: 172.16.5.4[0]192.168.1.12[0]
2006-01-30 01:36:09: INFO: IPsec-SA established: ESP/Tunnel 192.168.1.12[0]->172.16.5.4[0] spi=28496098(0x1b2d0e2)
2006-01-30 01:36:09: INFO: IPsec-SA established: ESP/Tunnel 172.16.5.4[0]->192.168.1.12[0] spi=47784998(0x2d92426)
2006-01-30 01:36:13: INFO: respond new phase 2 negotiation: 172.16.5.4[0]192.168.1.12[0]
2006-01-30 01:36:18: INFO: IPsec-SA established: ESP/Tunnel 192.168.1.12[0]->172.16.5.4[0] spi=124397467(0x76a279b)
2006-01-30 01:36:18: INFO: IPsec-SA established: ESP/Tunnel 172.16.5.4[0]->192.168.1.12[0] spi=175852902(0xa7b4d66)To ensure the tunnel is working properly, switch to
another console and use &man.tcpdump.1; to view network
traffic using the following command. Replace
em0 with the network interface card as
required:&prompt.root; tcpdump -i em0 host 172.16.5.4 and dst 192.168.1.12Data similar to the following should appear on the
console. If not, there is an issue and debugging the
returned data will be required.01:47:32.021683 IP corporatenetwork.com > 192.168.1.12.privatenetwork.com: ESP(spi=0x02acbf9f,seq=0xa)
01:47:33.022442 IP corporatenetwork.com > 192.168.1.12.privatenetwork.com: ESP(spi=0x02acbf9f,seq=0xb)
01:47:34.024218 IP corporatenetwork.com > 192.168.1.12.privatenetwork.com: ESP(spi=0x02acbf9f,seq=0xc)At this point, both networks should be available and seem
to be part of the same network. Most likely both networks are
protected by a firewall. To allow traffic to flow between
them, rules need to be added to pass packets. For the
&man.ipfw.8; firewall, add the following lines to the firewall
configuration file:ipfw add 00201 allow log esp from any to any
ipfw add 00202 allow log ah from any to any
ipfw add 00203 allow log ipencap from any to any
ipfw add 00204 allow log udp from any 500 to anyThe rule numbers may need to be altered depending on the
current host configuration.For users of &man.pf.4; or &man.ipf.8;, the following
rules should do the trick:pass in quick proto esp from any to any
pass in quick proto ah from any to any
pass in quick proto ipencap from any to any
pass in quick proto udp from any port = 500 to any port = 500
pass in quick on gif0 from any to any
pass out quick proto esp from any to any
pass out quick proto ah from any to any
pass out quick proto ipencap from any to any
pass out quick proto udp from any port = 500 to any port = 500
pass out quick on gif0 from any to anyFinally, to allow the machine to start support for the
VPN during system initialization, add the
following lines to /etc/rc.conf:ipsec_enable="YES"
ipsec_program="/usr/local/sbin/setkey"
ipsec_file="/usr/local/etc/racoon/setkey.conf" # allows setting up spd policies on boot
racoon_enable="yes"OpenSSHChernLeeContributed
by OpenSSHsecurityOpenSSHOpenSSH is a set of network
connectivity tools used to provide secure access to remote
machines. Additionally, TCP/IP connections
can be tunneled or forwarded securely through
SSH connections.
OpenSSH encrypts all traffic to
effectively eliminate eavesdropping, connection hijacking, and
other network-level attacks.OpenSSH is maintained by the
OpenBSD project and is installed by default in &os;. It is
compatible with both SSH version 1 and 2
protocols.When data is sent over the network in an unencrypted form,
network sniffers anywhere in between the client and server can
steal user/password information or data transferred during the
session. OpenSSH offers a variety of
authentication and encryption methods to prevent this from
happening. More information about
OpenSSH is available from http://www.openssh.com/.This section provides an overview of the built-in client
utilities to securely access other systems and securely transfer
files from a &os; system. It then describes how to configure a
SSH server on a &os; system. More
information is available in the man pages mentioned in this
chapter.Using the SSH Client UtilitiesOpenSSHclientTo log into a SSH server, use
ssh and specify a username that exists on
that server and the IP address or hostname
of the server. If this is the first time a connection has
been made to the specified server, the user will be prompted
to first verify the server's fingerprint:&prompt.root; ssh user@example.com
The authenticity of host 'example.com (10.0.0.1)' can't be established.
ECDSA key fingerprint is 25:cc:73:b5:b3:96:75:3d:56:19:49:d2:5c:1f:91:3b.
Are you sure you want to continue connecting (yes/no)? yes
Permanently added 'example.com' (ECDSA) to the list of known hosts.
Password for user@example.com: user_passwordSSH utilizes a key fingerprint system
to verify the authenticity of the server when the client
connects. When the user accepts the key's fingerprint by
typing yes when connecting for the first
time, a copy of the key is saved to
.ssh/known_hosts in the user's home
directory. Future attempts to login are verified against the
saved key and ssh will display an alert if
the server's key does not match the saved key. If this
occurs, the user should first verify why the key has changed
before continuing with the connection.By default, recent versions of
OpenSSH only accept
SSHv2 connections. By default, the client
will use version 2 if possible and will fall back to version 1
if the server does not support version 2. To force
ssh to only use the specified protocol,
include or .
Additional options are described in &man.ssh.1;.OpenSSHsecure copy&man.scp.1;Use &man.scp.1; to securely copy a file to or from a
remote machine. This example copies
COPYRIGHT on the remote system to a file
of the same name in the current directory of the local
system:&prompt.root; scp user@example.com:/COPYRIGHT COPYRIGHT
Password for user@example.com: *******
COPYRIGHT 100% |*****************************| 4735
00:00
&prompt.root;Since the fingerprint was already verified for this host,
the server's key is automatically checked before prompting for
the user's password.The arguments passed to scp are similar
to cp. The file or files to copy is the
first argument and the destination to copy to is the second.
Since the file is fetched over the network, one or more of the
file arguments takes the form
. Be
aware when copying directories recursively that
scp uses , whereas
cp uses .To open an interactive session for copying files, use
sftp. Refer to &man.sftp.1; for a list of
available commands while in an sftp
session.Key-based AuthenticationInstead of using passwords, a client can be configured
to connect to the remote machine using keys. To generate
DSA or RSA
authentication keys, use ssh-keygen. To
generate a public and private key pair, specify the type of
key and follow the prompts. It is recommended to protect
the keys with a memorable, but hard to guess
passphrase.&prompt.user; ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase): type some passphrase here which can contain spaces
Enter same passphrase again: type some passphrase here which can contain spaces
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
bb:48:db:f2:93:57:80:b6:aa:bc:f5:d5:ba:8f:79:17 user@host.example.comDepending upon the specified protocol, the private key
is stored in ~/.ssh/id_dsa (or
~/.ssh/id_rsa), and the public key
is stored in ~/.ssh/id_dsa.pub (or
~/.ssh/id_rsa.pub). The
public key must be first copied to
~/.ssh/authorized_keys on the remote
machine in order for key-based authentication to
work.Many users believe that keys are secure by design and
will use a key without a passphrase. This is
dangerous behavior. An
administrator can verify that a key pair is protected by a
passphrase by viewing the private key manually. If the
private key file contains the word
ENCRYPTED, the key owner is using a
passphrase. In addition, to better secure end users,
from may be placed in the public key
file. For example, adding
from="192.168.10.5" in the front of
ssh-rsa or rsa-dsa
prefix will only allow that specific user to login from
that IP address.The various options and files can be different
according to the OpenSSH version.
To avoid problems, consult &man.ssh-keygen.1;.If a passphrase is used, the user will be prompted for
the passphrase each time a connection is made to the server.
To load SSH keys into memory, without
needing to type the passphrase each time, use
&man.ssh-agent.1; and &man.ssh-add.1;.Authentication is handled by
ssh-agent, using the private key(s) that
are loaded into it. Then, ssh-agent
should be used to launch another application such as a
shell or a window manager.To use ssh-agent in a shell, start it
with a shell as an argument. Next, add the identity by
running ssh-add and providing it the
passphrase for the private key. Once these steps have been
completed, the user will be able to ssh
to any host that has the corresponding public key installed.
For example:&prompt.user; ssh-agent csh
&prompt.user; ssh-add
Enter passphrase for key '/usr/home/user/.ssh/id_dsa': type passphrase here
Identity added: /usr/home/user/.ssh/id_dsa (/usr/home/user/.ssh/id_dsa)
&prompt.user;To use ssh-agent in
&xorg;, add an entry for it in
~/.xinitrc. This provides the
ssh-agent services to all programs
launched in &xorg;. An example
~/.xinitrc might look like this:exec ssh-agent startxfce4This launches ssh-agent, which in
turn launches XFCE, every time
&xorg; starts. Once
&xorg; has been restarted so that
the changes can take effect, run ssh-add
to load all of the SSH keys.SSH TunnelingOpenSSHtunnelingOpenSSH has the ability to
create a tunnel to encapsulate another protocol in an
encrypted session.The following command tells ssh to
create a tunnel for
telnet:&prompt.user; ssh -2 -N -f -L 5023:localhost:23 user@foo.example.com
&prompt.user;This example uses the following options:Forces ssh to use version 2 to
connect to the server.Indicates no command, or tunnel only. If omitted,
ssh initiates a normal
session.Forces ssh to run in the
background.Indicates a local tunnel in
localport:remotehost:remoteport
format.The login name to use on the specified remote
SSH server.An SSH tunnel works by creating a
listen socket on localhost on the
specified localport. It then forwards
any connections received on localport via
the SSH connection to the specified
remotehost:remoteport. In the example,
port 5023 on the client is forwarded to
port 23 on the remote machine. Since
port 23 is used by telnet, this
creates an encrypted telnet
session through an SSH tunnel.This method can be used to wrap any number of insecure
TCP protocols such as
SMTP, POP3, and
FTP, as seen in the following
examples.Create a Secure Tunnel for
SMTP&prompt.user; ssh -2 -N -f -L 5025:localhost:25 user@mailserver.example.com
user@mailserver.example.com's password: *****
&prompt.user; telnet localhost 5025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mailserver.example.com ESMTPThis can be used in conjunction with
ssh-keygen and additional user accounts
to create a more seamless SSH tunneling
environment. Keys can be used in place of typing a
password, and the tunnels can be run as a separate
user.Secure Access of a POP3
ServerIn this example, there is an SSH
server that accepts connections from the outside. On the
same network resides a mail server running a
POP3 server. To check email in a
secure manner, create an SSH connection
to the SSH server and tunnel through to
the mail server:&prompt.user; ssh -2 -N -f -L 2110:mail.example.com:110 user@ssh-server.example.com
user@ssh-server.example.com's password: ******Once the tunnel is up and running, point the email
client to send POP3 requests to
localhost on port 2110. This
connection will be forwarded securely across the tunnel to
mail.example.com.Bypassing a FirewallSome firewalls
filter both incoming and outgoing connections. For
example, a firewall might limit access from remote
machines to ports 22 and 80 to only allow
SSH and web surfing. This prevents
access to any other service which uses a port other than
22 or 80.The solution is to create an SSH
connection to a machine outside of the network's firewall
and use it to tunnel to the desired service:&prompt.user; ssh -2 -N -f -L 8888:music.example.com:8000 user@unfirewalled-system.example.org
user@unfirewalled-system.example.org's password: *******In this example, a streaming Ogg Vorbis client can now
be pointed to localhost port
8888, which will be forwarded over to
music.example.com on port 8000,
successfully bypassing the firewall.Enabling the SSH ServerOpenSSHenablingIn addition to providing built-in SSH
client utilities, a &os; system can be configured as an
SSH server, accepting connections from
other SSH clients.To see if sshd is enabled,
check /etc/rc.conf for this line and add
it if it is missing:sshd_enable="YES"This will start sshd, the
daemon program for OpenSSH, the
next time the system boots. To start it now:&prompt.root; service sshd startThe first time sshd starts on a
&os; system, the system's host keys will be automatically
created and the fingerprint will be displayed on the console.
Provide users with the fingerprint so that they can verify it
the first time they connect to the server.Refer to &man.sshd.8; for the list of available options
when starting sshd and a more
complete discussion about authentication, the login process,
and the various configuration files.It is a good idea to limit which users can log into the
SSH server and from where using the
AllowUsers keyword in the
OpenSSH server configuration file.
For example, to only allow root to log in from
192.168.1.32, add
this line to /etc/ssh/sshd_config:AllowUsers root@192.168.1.32To allow admin
to log in from anywhere, list that user without specifying an
IP address:AllowUsers adminMultiple users should be listed on the same line, like
so:AllowUsers root@192.168.1.32 adminAfter making changes to
/etc/ssh/sshd_config,
tell sshd to reload its
configuration file by running:&prompt.root; service sshd reloadWhen this keyword is used, it is important to list each
user that needs to log into this machine. Any user that is
not specified in that line will be locked out. Also, the
keywords used in the OpenSSH
server configuration file are case-sensitive. If the
keyword is not spelled correctly, including its case, it
will be ignored. Always test changes to this file to make
sure that the edits are working as expected. Refer to
&man.sshd.config.5; to verify the spelling and use of the
available keywords.Do not confuse /etc/ssh/sshd_config
with /etc/ssh/ssh_config (note the
extra d in the first filename). The
first file configures the server and the second file
configures the client. Refer to &man.ssh.config.5; for a
listing of the available client settings,.Access Control ListsTomRhodesContributed
by ACLAccess Control Lists (ACLs) extend the
standard &unix; permission model in a &posix;.1e compatible way.
This permits an administrator to take advantage of a more
fine-grained permissions model.The &os; GENERIC kernel provides
ACL support for UFS file
systems. Users who prefer to compile a custom kernel must
include the following option in their custom kernel
configuration file:options UFS_ACLIf this option is not compiled in, a warning message will be
displayed when attempting to mount a file system with
ACL support. ACLs rely on
extended attributes which are natively supported in
UFS2.This chapter describes how to enable
ACL support and provides some usage
examples.Enabling ACL SupportACLs are enabled by the mount-time
administrative flag, , which may be added
to /etc/fstab. The mount-time flag can
also be automatically set in a persistent manner using
&man.tunefs.8; to modify a superblock ACLs
flag in the file system header. In general, it is preferred
to use the superblock flag for several reasons:The superblock flag cannot be changed by a remount
using as it requires a complete
umount and fresh
mount. This means that
ACLs cannot be enabled on the root file
system after boot. It also means that
ACL support on a file system cannot be
changed while the system is in use.Setting the superblock flag causes the file system to
always be mounted with ACLs enabled,
even if there is not an fstab entry
or if the devices re-order. This prevents accidental
mounting of the file system without ACL
support.It is desirable to discourage accidental mounting
without ACLs enabled because nasty things
can happen if ACLs are enabled, then
disabled, then re-enabled without flushing the extended
attributes. In general, once ACLs are
enabled on a file system, they should not be disabled, as
the resulting file protections may not be compatible with
those intended by the users of the system, and re-enabling
ACLs may re-attach the previous
ACLs to files that have since had their
permissions changed, resulting in unpredictable
behavior.File systems with ACLs enabled will
show a plus (+) sign in their permission
settings:drwx------ 2 robert robert 512 Dec 27 11:54 private
drwxrwx---+ 2 robert robert 512 Dec 23 10:57 directory1
drwxrwx---+ 2 robert robert 512 Dec 22 10:20 directory2
drwxrwx---+ 2 robert robert 512 Dec 27 11:57 directory3
drwxr-xr-x 2 robert robert 512 Nov 10 11:54 public_htmlIn this example, directory1,
directory2, and
directory3 are all taking advantage of
ACLs, whereas
public_html is not.Using ACLsFile system ACLs can be viewed using
getfacl. For instance, to view the
ACL settings on
test:&prompt.user; getfacl test
#file:test
#owner:1001
#group:1001
user::rw-
group::r--
other::r--To change the ACL settings on this
file, use setfacl. To remove all of the
currently defined ACLs from a file or file
system, include . However, the preferred
method is to use as it leaves the basic
fields required for ACLs to work.&prompt.user; setfacl -k testTo modify the default ACL entries, use
:&prompt.user; setfacl -m u:trhodes:rwx,group:web:r--,o::--- testIn this example, there were no pre-defined entries, as
they were removed by the previous command. This command
restores the default options and assigns the options listed.
If a user or group is added which does not exist on the
system, an Invalid argument error will
be displayed.Refer to &man.getfacl.1; and &man.setfacl.1; for more
information about the options available for these
commands.Monitoring Third Party Security IssuesTomRhodesContributed
by portauditIn recent years, the security world has made many
improvements to how vulnerability assessment is handled. The
threat of system intrusion increases as third party utilities
are installed and configured for virtually any operating
system available today.Vulnerability assessment is a key factor in security.
While &os; releases advisories for the base system, doing so
for every third party utility is beyond the &os; Project's
capability. There is a way to mitigate third party
vulnerabilities and warn administrators of known security
issues. A &os; add on utility known as
portaudit exists solely for this
purpose.The
ports-mgmt/portaudit
port polls a database, which is updated and maintained by the
&os; Security Team and ports developers, for known security
issues.To install portaudit from the
Ports Collection:&prompt.root; cd /usr/ports/ports-mgmt/portaudit && make install cleanDuring the installation, the configuration files for
&man.periodic.8; will be updated, permitting
portaudit output in the daily
security runs. Ensure that the daily security run emails, which
are sent to root's
email account, are being read. No other configuration is
required.After installation, an administrator can update the
database and view known vulnerabilities in installed packages
by invoking the following command:&prompt.root; portaudit -FdaThe database is automatically updated during the
&man.periodic.8; run. The above command is optional and can
be used to manually update the database now.To audit the third party utilities installed as part of
the Ports Collection at anytime, an administrator can run the
following command:&prompt.root; portaudit -aportaudit will display messages
for any installed vulnerable packages:Affected package: cups-base-1.1.22.0_1
Type of problem: cups-base -- HPGL buffer overflow vulnerability.
Reference: <http://www.FreeBSD.org/ports/portaudit/40a3bca2-6809-11d9-a9e7-0001020eed82.html>
1 problem(s) in your installed packages found.
You are advised to update or deinstall the affected package(s) immediately.By pointing a web browser to the displayed
URL, an administrator may obtain more
information about the vulnerability. This will include the
versions affected, by &os; port version, along with other web
sites which may contain security advisories.portaudit is a powerful utility
and is extremely useful when coupled with the
portmaster port.&os; Security AdvisoriesTomRhodesContributed
by &os; Security AdvisoriesLike many producers of quality operating systems, the &os;
Project has a security team which is responsible for
determining the End-of-Life (EoL) date for
each &os; release and to provide security updates for supported
releases which have not yet reached their
EoL. More information about the &os;
security team and the supported releases is available on the
&os; security
page.One task of the security team is to respond to reported
security vulnerabilities in the &os; operating system. Once a
vulnerability is confirmed, the security team verifies the steps
necessary to fix the vulnerability and updates the source code
with the fix. It then publishes the details as a
Security Advisory. Security
advisories are published on the &os;
website and mailed to the
&a.security-notifications.name;, &a.security.name;, and
&a.announce.name; mailing lists.This section describes the format of a &os; security
advisory.Format of a Security AdvisoryHere is an example of a &os; security advisory:=============================================================================
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
=============================================================================
FreeBSD-SA-14:04.bind Security Advisory
The FreeBSD Project
Topic: BIND remote denial of service vulnerability
Category: contrib
Module: bind
Announced: 2014-01-14
Credits: ISC
Affects: FreeBSD 8.x and FreeBSD 9.x
Corrected: 2014-01-14 19:38:37 UTC (stable/9, 9.2-STABLE)
2014-01-14 19:42:28 UTC (releng/9.2, 9.2-RELEASE-p3)
2014-01-14 19:42:28 UTC (releng/9.1, 9.1-RELEASE-p10)
2014-01-14 19:38:37 UTC (stable/8, 8.4-STABLE)
2014-01-14 19:42:28 UTC (releng/8.4, 8.4-RELEASE-p7)
2014-01-14 19:42:28 UTC (releng/8.3, 8.3-RELEASE-p14)
CVE Name: CVE-2014-0591
For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:http://security.FreeBSD.org/>.
I. Background
BIND 9 is an implementation of the Domain Name System (DNS) protocols.
The named(8) daemon is an Internet Domain Name Server.
II. Problem Description
Because of a defect in handling queries for NSEC3-signed zones, BIND can
crash with an "INSIST" failure in name.c when processing queries possessing
certain properties. This issue only affects authoritative nameservers with
at least one NSEC3-signed zone. Recursive-only servers are not at risk.
III. Impact
An attacker who can send a specially crafted query could cause named(8)
to crash, resulting in a denial of service.
IV. Workaround
No workaround is available, but systems not running authoritative DNS service
with at least one NSEC3-signed zone using named(8) are not vulnerable.
V. Solution
Perform one of the following:
1) Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date.
2) To update your vulnerable system via a source code patch:
The following patches have been verified to apply to the applicable
FreeBSD release branches.
a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.
[FreeBSD 8.3, 8.4, 9.1, 9.2-RELEASE and 8.4-STABLE]
# fetch http://security.FreeBSD.org/patches/SA-14:04/bind-release.patch
# fetch http://security.FreeBSD.org/patches/SA-14:04/bind-release.patch.asc
# gpg --verify bind-release.patch.asc
[FreeBSD 9.2-STABLE]
# fetch http://security.FreeBSD.org/patches/SA-14:04/bind-stable-9.patch
# fetch http://security.FreeBSD.org/patches/SA-14:04/bind-stable-9.patch.asc
# gpg --verify bind-stable-9.patch.asc
b) Execute the following commands as root:
# cd /usr/src
# patch < /path/to/patch
Recompile the operating system using buildworld and installworld as
described in <URL:http://www.FreeBSD.org/handbook/makeworld.html>.
Restart the applicable daemons, or reboot the system.
3) To update your vulnerable system via a binary patch:
Systems running a RELEASE version of FreeBSD on the i386 or amd64
platforms can be updated via the freebsd-update(8) utility:
# freebsd-update fetch
# freebsd-update install
VI. Correction details
The following list contains the correction revision numbers for each
affected branch.
Branch/path Revision
- -------------------------------------------------------------------------
stable/8/ r260646
releng/8.3/ r260647
releng/8.4/ r260647
stable/9/ r260646
releng/9.1/ r260647
releng/9.2/ r260647
- -------------------------------------------------------------------------
To see which files were modified by a particular revision, run the
following command, replacing NNNNNN with the revision number, on a
machine with Subversion installed:
# svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base
Or visit the following URL, replacing NNNNNN with the revision number:
<URL:http://svnweb.freebsd.org/base?view=revision&revision=NNNNNN>
VII. References
<URL:https://kb.isc.org/article/AA-01078>
<URL:http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0591>
The latest revision of this advisory is available at
<URL:http://security.FreeBSD.org/advisories/FreeBSD-SA-14:04.bind.asc>
-----BEGIN PGP SIGNATURE-----
iQIcBAEBCgAGBQJS1ZTYAAoJEO1n7NZdz2rnOvQP/2/68/s9Cu35PmqNtSZVVxVG
ZSQP5EGWx/lramNf9566iKxOrLRMq/h3XWcC4goVd+gZFrvITJSVOWSa7ntDQ7TO
XcinfRZ/iyiJbs/Rg2wLHc/t5oVSyeouyccqODYFbOwOlk35JjOTMUG1YcX+Zasg
ax8RV+7Zt1QSBkMlOz/myBLXUjlTZ3Xg2FXVsfFQW5/g2CjuHpRSFx1bVNX6ysoG
9DT58EQcYxIS8WfkHRbbXKh9I1nSfZ7/Hky/kTafRdRMrjAgbqFgHkYTYsBZeav5
fYWKGQRJulYfeZQ90yMTvlpF42DjCC3uJYamJnwDIu8OhS1WRBI8fQfr9DRzmRua
OK3BK9hUiScDZOJB6OqeVzUTfe7MAA4/UwrDtTYQ+PqAenv1PK8DZqwXyxA9ThHb
zKO3OwuKOVHJnKvpOcr+eNwo7jbnHlis0oBksj/mrq2P9m2ueF9gzCiq5Ri5Syag
Wssb1HUoMGwqU0roS8+pRpNC8YgsWpsttvUWSZ8u6Vj/FLeHpiV3mYXPVMaKRhVm
067BA2uj4Th1JKtGleox+Em0R7OFbCc/9aWC67wiqI6KRyit9pYiF3npph+7D5Eq
7zPsUdDd+qc+UTiLp3liCRp5w6484wWdhZO6wRtmUgxGjNkxFoNnX8CitzF8AaqO
UWWemqWuz3lAZuORQ9KX
=OQzQ
-----END PGP SIGNATURE-----Every security advisory uses the following format:Each security advisory is signed by the
PGP key of the Security Officer. The
public key for the Security Officer can be verified at
.The name of the security advisory always begins with
FreeBSD-SA- (for FreeBSD Security
Advisory), followed by the year in two digit format
(14:), followed by the advisory number
for that year (04.), followed by the
name of the affected application or subsystem
(bind). The advisory shown here is the
fourth advisory for 2014 and it affects
BIND.The Topic field summarizes the
vulnerability.The Category refers to the
affected part of the system which may be one of
core, contrib, or
ports. The core
category means that the vulnerability affects a core
component of the &os; operating system. The
contrib category means that the
vulnerability affects software included with &os;,
such as BIND. The
ports category indicates that the
vulnerability affects software available through the Ports
Collection.The Module field refers to the
component location. In this example, the
bind module is affected; therefore,
this vulnerability affects an application installed with
the operating system.The Announced field reflects the
date the security advisory was published. This means
that the security team has verified that the problem
exists and that a patch has been committed to the &os;
source code repository.The Credits field gives credit to
the individual or organization who noticed the
vulnerability and reported it.The Affects field explains which
releases of &os; are affected by this
vulnerability.The Corrected field indicates the
date, time, time offset, and releases that were
corrected. The section in parentheses shows each branch
for which the fix has been merged, and the version number
of the corresponding release from that branch. The
release identifier itself includes the version number
and, if appropriate, the patch level. The patch level is
the letter p followed by a number,
indicating the sequence number of the patch, allowing
users to track which patches have already been applied to
the system.The CVE Name field lists the
advisory number, if one exists, in the public cve.mitre.org
security vulnerabilities database.The Background field provides a
description of the affected module.The Problem Description field
explains the vulnerability. This can include
information about the flawed code and how the utility
could be maliciously used.The Impact field describes what
type of impact the problem could have on a system.The Workaround field indicates if
a workaround is available to system administrators who
cannot immediately patch the system .The Solution field provides the
instructions for patching the affected system. This is a
step by step tested and verified method for getting a
system patched and working securely.The Correction Details field
displays each affected Subversion branch with the revision
number that contains the corrected code.The References field offers sources
of additional information regarding the
vulnerability.Process AccountingTomRhodesContributed
by Process AccountingProcess accounting is a security method in which an
administrator may keep track of system resources used and
their allocation among users, provide for system monitoring,
and minimally track a user's commands.Process accounting has both positive and negative points.
One of the positives is that an intrusion may be narrowed down
to the point of entry. A negative is the amount of logs
generated by process accounting, and the disk space they may
require. This section walks an administrator through the basics
of process accounting.If more fine-grained accounting is needed, refer to
.Enabling and Utilizing Process AccountingBefore using process accounting, it must be enabled using
the following commands:&prompt.root; touch /var/account/acct
&prompt.root; chmod 600 /var/account/acct
&prompt.root; accton /var/account/acct
&prompt.root; echo 'accounting_enable="YES"' >> /etc/rc.confOnce enabled, accounting will begin to track information
such as CPU statistics and executed
commands. All accounting logs are in a non-human readable
format which can be viewed using sa. If
issued without any options, sa prints
information relating to the number of per-user calls, the
total elapsed time in minutes, total CPU
and user time in minutes, and the average number of
I/O operations. Refer to &man.sa.8; for
the list of available options which control the output.To display the commands issued by users, use
lastcomm. For example, this command
prints out all usage of ls by trhodes on the
ttyp1 terminal:&prompt.root; lastcomm ls trhodes ttyp1Many other useful options exist and are explained in
&man.lastcomm.1;, &man.acct.5;, and &man.sa.8;.Resource LimitsTomRhodesContributed
by Resource limits&os; provides several methods for an administrator to
limit the amount of system resources an individual may use.
Disk quotas limit the amount of disk space available to users.
Quotas are discussed in .quotaslimiting usersquotasdisk quotasLimits to other resources, such as CPU
and memory, can be set using either a flat file or a command to
configure a resource limits database. The traditional method
defines login classes by editing
/etc/login.conf. While this method is
still supported, any changes require a multi-step process of
editing this file, rebuilding the resource database, making
necessary changes to /etc/master.passwd,
and rebuilding the password database. This can become time
consuming, depending upon the number of users to
configure.Beginning with &os; 9.0-RELEASE,
rctl can be used to provide a more
fine-grained method for controlling resource limits. This
command supports more than user limits as it can also be used to
set resource constraints on processes and jails.This section demonstrates both methods for controlling
resources, beginning with the traditional method.Configuring Login Classeslimiting usersaccountslimiting/etc/login.confIn the traditional method, login classes and the resource
limits to apply to a login class are defined in
/etc/login.conf. Each user account can
be assigned to a login class, where default
is the default login class. Each login class has a set of
login capabilities associated with it. A login capability is
a
name=value
pair, where name is a well-known
identifier and value is an
arbitrary string which is processed accordingly depending on
the name.Whenever /etc/login.conf is edited,
the /etc/login.conf.db must be updated
by executing the following command:&prompt.root; cap_mkdb /etc/login.confResource limits differ from the default login capabilities
in two ways. First, for every limit, there is a
soft and hard
limit. A soft limit may be adjusted by the user or
application, but may not be set higher than the hard limit.
The hard limit may be lowered by the user, but can only be
raised by the superuser. Second, most resource limits apply
per process to a specific user. lists the most commonly
used resource limits. All of the available resource limits
and capabilities are described in detail in
&man.login.conf.5;.limiting userscoredumpsizelimiting userscputimelimiting usersfilesizelimiting usersmaxproclimiting usersmemorylockedlimiting usersmemoryuselimiting usersopenfileslimiting userssbsizelimiting usersstacksize
Login Class Resource LimitsResource LimitDescriptioncoredumpsizeThe limit on the size of a core file generated by
a program is subordinate to other limits on disk
usage, such as filesize or disk
quotas. This limit is often used as a less severe
method of controlling disk space consumption. Since
users do not generate core files and often do not
delete them, this setting may save them from running
out of disk space should a large program
crash.cputimeThe maximum amount of CPU time
a user's process may consume. Offending processes
will be killed by the kernel. This is a limit on
CPU time
consumed, not the percentage of the
CPU as displayed in some of the
fields generated by top and
ps.filesizeThe maximum size of a file the user may own.
Unlike disk quotas (), this
limit is enforced on individual files, not the set of
all files a user owns.maxprocThe maximum number of foreground and background
processes a user can run. This limit may not be
larger than the system limit specified by
kern.maxproc. Setting this limit
too small may hinder a user's productivity as some
tasks, such as compiling a large program, start lots
of processes.memorylockedThe maximum amount of memory a process may
request to be locked into main memory using
&man.mlock.2;. Some system-critical programs, such as
&man.amd.8;, lock into main memory so that if the
system begins to swap, they do not contribute to disk
thrashing.memoryuseThe maximum amount of memory a process may
consume at any given time. It includes both core
memory and swap usage. This is not a catch-all limit
for restricting memory consumption, but is a good
start.openfilesThe maximum number of files a process may have
open. In &os;, files are used to represent sockets
and IPC channels, so be careful not
to set this too low. The system-wide limit for this
is defined by
kern.maxfiles.sbsizeThe limit on the amount of network memory a user
may consume. This can be generally used to limit
network communications.stacksizeThe maximum size of a process stack. This alone
is not sufficient to limit the amount of memory a
program may use, so it should be used in conjunction
with other limits.
There are a few other things to remember when setting
resource limits:Processes started at system startup by
/etc/rc are assigned to the
daemon login class.Although the default
/etc/login.conf is a good source of
reasonable values for most limits, they may not be
appropriate for every system. Setting a limit too high
may open the system up to abuse, while setting it too low
may put a strain on productivity.&xorg; takes a lot of
resources and encourages users to run more programs
simultaneously.Many limits apply to individual processes, not the
user as a whole. For example, setting
openfiles to 50
means that each process the user runs may open up to
50 files. The total amount of files a
user may open is the value of openfiles
multiplied by the value of maxproc.
This also applies to memory consumption.For further information on resource limits and login
classes and capabilities in general, refer to
&man.cap.mkdb.1;, &man.getrlimit.2;, and
&man.login.conf.5;.Enabling and Configuring Resource LimitsBy default, kernel support for rctl is
not built-in, meaning that the kernel will first need to be
recompiled using the instructions in . Add these lines to either
GENERIC or a custom kernel configuration
file, then rebuild the kernel:options RACCT
options RCTLOnce the system has rebooted into the new kernel,
rctl may be used to set rules for the
system.Rule syntax is controlled through the use of a subject,
subject-id, resource, and action, as seen in this example
rule:user:trhodes:maxproc:deny=10/userIn this rule, the subject is user, the
subject-id is trhodes, the resource,
maxproc, is the maximum number of
processes, and the action is deny, which
blocks any new processes from being created. This means that
the user, trhodes, will be constrained to
no greater than 10 processes. Other
possible actions include logging to the console, passing a
notification to &man.devd.8;, or sending a sigterm to the
process.Some care must be taken when adding rules. Since this
user is constrained to 10 processes, this
example will prevent the user from performing other tasks
after logging in and executing a
screen session. Once a resource limit has
been hit, an error will be printed, as in this example:&prompt.user; man test
/usr/bin/man: Cannot fork: Resource temporarily unavailable
eval: Cannot fork: Resource temporarily unavailableAs another example, a jail can be prevented from exceeding
a memory limit. This rule could be written as:&prompt.root; rctl -a jail:httpd:memoryuse:deny=2G/jailRules will persist across reboots if they have been added
to /etc/rctl.conf. The format is a rule,
without the preceding command. For example, the previous rule
could be added as:# Block jail from using more than 2G memory:
jail:httpd:memoryuse:deny=2G/jailTo remove a rule, use rctl to remove it
from the list:&prompt.root; rctl -r user:trhodes:maxproc:deny=10/userA method for removing all rules is documented in
&man.rctl.8;. However, if removing all rules for a single
user is required, this command may be issued:&prompt.root; rctl -r user:trhodesMany other resources exist which can be used to exert
additional control over various subjects.
See &man.rctl.8; to learn about them.