2Apr il 2003, 17:00:47 The Complete FreeBSD (netsetup.mm), page 297
17
Configuring the local
network
In this chapter:
• Networ k
configuration with
sysinstall
• Manual networ k
configuration
• Automatic
configuration with
DHCP
• Configur ing PC Card
networ king cards
• Setting up wireless
networ king
• Routing
• ISP’sroute setup
• Looking at the
routing tables
• Packetforwarding
• Configuration
summar y
In this chapter:
• Networ k
configuration with
sysinstall
• Manual networ k
configuration
• Automatic
list is xl0,the Ethernet board. The others are standard hardware that can also be used as
network interfaces.
netsetup.mm,v v4.15 (2003/04/02 06:50:16) 297
Networ k configuration with sysinstall 298
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 298
Figure17-1: Network setup menu
Choose the Ethernet board, xl0 Youget a question about whether you want to use IPv6
configuration. This book we doesn’tdiscuss IPv6, so answer No.Nextyou get a question
about DHCP configuration. We discuss DHCP configuration on page 302. If you already
have a DHCP server set up, you may prefer to answer Yes to this question, which is all
you need to do. If you answer No,the next menu asks us to set the internet parameters.
Figure 17-2 shows the network configuration menu after filling in the values.
Figure17-2: Network configuration menu
netsetup.mm,v v4.15 (2003/04/02 06:50:16)
299 Chapter 17: Configuring the local networ k
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 299
Specify the fully qualified local host name. When you tab to the Domain: field, the
domain is filled in automatically.Wehav e chosen to call this machine presto,and the
domain is example.org.Inother words, the full name of the machine is presto.exam-
ple.org.Its IP address is 223.147.37.2.Inthis configuration, all access to the outside
world goes via gw.example.org,which has the IP address 223.147.37.5.The name
server is located on the same host, presto.example.org.Ifthe name server isn’trunning
when this information is needed, we must specify all addresses in numeric form, as
shown.
What happens if you don’thav e adomain name? If you’re connecting to the global
Internet, you should go out and get one—see page 318. But in the meantime, don’tfake
it. Just leave the fields empty.Ifyou’re not connecting to the Internet, of course, it
doesn’tmakemuch difference what name you choose.
As is usual for a class C network, the net mask is 255.255.255.0.You don’tneed to fill
in this information—if you leave this field without filling it in, sysinstall inserts it for
is a broadcast network, such as an Ethernet, you need to specify a range of addresses that
can be reached directly on that network. As we sawonpage 290, we perform this
selection with the network mask.
Ethernet interfaces
Once we have understood these concepts, it’srelatively simple to use the ifconfig
program to set them. Forexample, for the Ethernet interface on system gw,with IP
address 223.147.37.5,weneed to configure interface dc0.The network mask is the
standard value for a class C network, 255.255.255.0.That’sall we need to know:
# ifconfig dc0 inet 223.147.37.5 netmask 255.255.255.0 up
In fact, this is more than you usually need. The inet tells the interface to use Internet
protocol Version 4 (the default), and up tells it to bring it up (which it does anyway). In
addition, this is a class C network address, so the net mask defaults to 255.255.255.0.
As a result, you can abbreviate this to:
# ifconfig dc0 223.147.37.5
Note that this is different from what Linux requires. With Linux you must supply explicit
netmask and broadcast address specifications.
As we sawonpage 290, it has become typical to abbreviate net masks to the character /
followed by the number of 1 bits set in the network mask. ifconfig understands this
usage, so if you wanted to set a non-standard network mask of, say, 255.255.255.240,
which has 28 bits set, you could write:
# ifconfig dc0 223.147.37.5/28
Point-to-point interfaces
With a point-to-point interface, the software currently requires you to specify the IP
address of the other end of the link as well. As we shall see in Chapter 20, there is no
good reason to do this, but ifconfig insists on it. In addition, we need the network mask
for a non-broadcast medium. The value is obvious:
1
you can reach exactly one address at
the other end, so it must be 255.255.255.255.With this information, we could
configure the PPP interface on gw:
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
inet 139.130.136.133 --> 139.130.136.129 netmask 0xffffffff
Other BSD systems require you to write ifconfig -a.tolist the configuration of all interfaces, and
FreeBSD still accepts it. Some other UNIX systems, particularly System V,don’tunderstand even
this flag.
There are a number of things to note here:
• The dc0 interface has both an IPv4 address (inet)and a corresponding IPv6 address
(inet6). It also specifies the Ethernet address (ether 00:80:c6:f9:d3:fa). It is
capable of negotiating 10 Mb/s, 100 Mb/s half duplexand 100 Mb/s full duplex. It’s
connected to a switch, so it’scurrently running 100 Mb/s full duplex.
• The interface lp0 is the the PLIP interface for connections via the parallel port. It is
not configured (in other words, it has not been set up for operation).
netsetup.mm,v v4.15 (2003/04/02 06:50:16)
Manual networ k configuration 302
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 302
• We’v e already seen the loopback interface lo0.
• There is also a tun0 interface for PPP.
The configuration files
The system startup scripts summarize this configuration information in a number of
configuration variables.See Chapter 29 for more details. At the moment, the following
variables are of interest to us:
• hostname is the name of the host. Youshould have set it when you installed the
system (see page 87). Youcan also set it manually with the hostname command:
# hostname -s gw.example.org
• Foreach interface, a variable of the form ifconfig_interface contains the
parameters to be passed to ifconfig to configure that interface.
Previously,FreeBSD also required you to set a variable network_interfaces,alist of
the names of the interfaces to be configured. This variable nowdefaults to the value
install the net/isc-dhcp3 port:
# cd /usr/ports/net/isc-dhcp3
# make install
To configure dhcpd,edit the configuration file /usr/local/etc/isc-dhcpd.conf.Here’san
example:
ddns-update-style ad-hoc;
#100 Mb/s Ethernet
subnet 223.147.37.0 netmask 255.255.255.0 {
range 223.147.37.90 223.147.37.110;
option domain-name-servers freebie.example.com, presto.example.com;
option domain-name "example.com";
option routers gw.example.com;
option subnet-mask 255.255.255.0;
option broadcast-address 223.147.37.255;
default-lease-time 86400;
max-lease-time 259200;
use-host-decl-names on; use the specified name as host name
host andante {
hardware ethernet 0:50:da:cf:7:35;
}
}
This configuration file tells dhcpd:
• To dynamically allocate IP addresses in the range 223.147.37.90 to
223.147.37.110 (range keyword).
• That the domain name servers are freebie.example.com and andante.example.com.
We’lllook at domain name servers in Chapter 21.
• The net mask and the broadcast address.
The variables default-lease-time and max-lease-time,which are specified in
seconds, determine howlong it will be before a system checks its configuration. The
values here represent one day and three days respectively.