Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [199]

By Root 2678 0
shell scripts that are executed to establish a context for the execution of other startup scripts. The format of their contents is the same, but they are three in number just to keep different classes of configuration data separate. The /etc/defaults/rc.conf file provides reasonable starting values for most parameters, the /etc/rc.conf file contains parameters that are local but perhaps common to several FreeBSD machines, and the rc.conf.local file holds settings that apply only to the local machine. For simplicity, we will assume in this section that you are using only the rc.conf file.

You should not modify the contents of /etc/defaults/rc.conf. However, it’s often useful to look at this file because it contains a near-complete list of the variables you can set, along with comments that describe their functions.

The only noticeable differences between FreeBSD 3.4 and 4.0 from a sysadmin’s point of view are that the default kernel contains many more network device drivers (13 total) and that IPv6 support is built in. Our ifconfig examples section includes both.

Basic network configuration for FreeBSD


You should set the following variables in rc.conf to override the empty values set in /etc/defaults/rc.conf:

hostname="hostname" # Set this!

ifconfig_xxx="inet IP-address" # Network device config

defaultrouter="gateway" # Set to default gateway

The variable network_interfaces is set to auto by default, which makes the system find its network interfaces at boot time. It can also be set to a list of interfaces on the machine. If you choose to go this route, don’t forget to include the loopback interface.

Here’s an example:

network_interfaces="lo0 xl0"

To establish static routes, use the static_routes variable:

static_routes="backlan 212" # Set to static route list

route_backlan="-net 10.0.1.0 132.236.212.2"

route_212="-net 132.236.212.64 -netmask 255.255.255.192 132.236.212.6"

The static_routes clause takes a space-separated list of route names. A route name is an arbitrary string that is used in a route_name clause to define the arguments that should be passed to the route add command.

Routing is completely disabled by default. To get reasonable behavior at most sites, you must either set a default route, set static routes, enable routed, or enable gated. (NIS is also disabled by default.)

Configuration examples for FreeBSD


To manually configure an Ethernet interface and set a default route, you’d use commands such as these:

# ifconfig xl0 inet 192.108.21.11 netmask 0xffffff00

# route add default 192.108.21.254

The second of these commands is equivalent to the command

# route add -net 0.0.0.0 192.108.21.254

Unlike most versions of route, FreeBSD’s route requires a dash in front of the route type (-net or -host), and it does not accept a hop count parameter.

The output of ifconfig and netstat -nr show the results of the commands above:

% ifconfig xl0

xl0: flags=8843 mtu 1500

inet 192.108.21.11 netmask 0xffffff00 broadcast 192.108.21.255

ether 00:60:97:9b:69:9a

media: 10baseT/UTP

supported media: autoselect 100baseTX 100baseTX

100baseTX 10baseT/UTP

10baseT/UTP 10baseT/UTP

% netstat -nr

Routing tables

Internet:

Destination Gateway Flags Refs Use Netif Exp

default 192.108.21.254 UGSc 0 18 xl0

127.0.0.1 127.0.0.1 UH 0 3 lo0

192.108.21 link#1 UC 0 0 xl0

192.108.21.1 8:0:20:77:5e:a0 UHLW 2 2586 xl0 1160

192.108.21.246 0:30:f2:f:48:0 UHLW 0 0 xl0 303

192.108.21.254 0:0:c:14:82:81 UHLW 1 0 xl0 1126

The flag values c and C in netstat -nr’s output specify that new host routes should be automatically generated and installed in the routing table as the local network route and default route are used. This feature caused the addition of the host routes shown in the last three lines of the routing table; note that they all have expiration times.

There are two reasons for this proliferation of routing table entries. The first reason is that for routes

Return Main Page Previous Page Next Page

®Online Book Reader