|
Lines 1-6773
Link Here
|
| 1 |
<!-- |
|
|
| 2 |
The FreeBSD Documentation Project |
| 3 |
|
| 4 |
$FreeBSD: doc/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.sgml,v 1.234 2003/07/21 13:35:50 blackend Exp $ |
| 5 |
--> |
| 6 |
|
| 7 |
<chapter id="advanced-networking"> |
| 8 |
<title>Advanced Networking</title> |
| 9 |
|
| 10 |
<sect1 id="advanced-networking-synopsis"> |
| 11 |
<title>Synopsis</title> |
| 12 |
|
| 13 |
<para>This chapter will cover some of the more frequently used network |
| 14 |
services on Unix systems. We will cover how to define, setup, test and |
| 15 |
maintain all of the network services that FreeBSD utilizes. In addition, |
| 16 |
there have been example configuration files included throughout this |
| 17 |
chapter for you to benefit from.</para> |
| 18 |
|
| 19 |
<para>After reading this chapter, you will know:</para> |
| 20 |
|
| 21 |
<itemizedlist> |
| 22 |
<listitem> |
| 23 |
<para>The basics of gateways and routes.</para> |
| 24 |
</listitem> |
| 25 |
|
| 26 |
<listitem> |
| 27 |
<para>How to make FreeBSD act as a bridge.</para> |
| 28 |
</listitem> |
| 29 |
|
| 30 |
<listitem> |
| 31 |
<para>How to setup a network filesystem.</para> |
| 32 |
</listitem> |
| 33 |
|
| 34 |
<listitem> |
| 35 |
<para>How to setup network booting on a diskless machine.</para> |
| 36 |
</listitem> |
| 37 |
|
| 38 |
<listitem> |
| 39 |
<para>How to setup a network information server for sharing user |
| 40 |
accounts.</para> |
| 41 |
</listitem> |
| 42 |
|
| 43 |
<listitem> |
| 44 |
<para>How to setup automatic network settings using DHCP.</para> |
| 45 |
</listitem> |
| 46 |
|
| 47 |
<listitem> |
| 48 |
<para>How to setup a domain name server.</para> |
| 49 |
</listitem> |
| 50 |
|
| 51 |
<listitem> |
| 52 |
<para>How to synchronize the time and date, and setup a |
| 53 |
time server, with the NTP protocol.</para> |
| 54 |
</listitem> |
| 55 |
|
| 56 |
<listitem> |
| 57 |
<para>How to setup network address translation.</para> |
| 58 |
</listitem> |
| 59 |
|
| 60 |
<listitem> |
| 61 |
<para>How to manage the <command>inetd</command> daemon.</para> |
| 62 |
</listitem> |
| 63 |
|
| 64 |
<listitem> |
| 65 |
<para>How to connect two computers via PLIP.</para> |
| 66 |
</listitem> |
| 67 |
|
| 68 |
<listitem> |
| 69 |
<para>How to setup IPv6 on a FreeBSD machine.</para> |
| 70 |
</listitem> |
| 71 |
</itemizedlist> |
| 72 |
|
| 73 |
<para>Before reading this chapter, you should:</para> |
| 74 |
|
| 75 |
<itemizedlist> |
| 76 |
<listitem> |
| 77 |
<para>Understand the basics of the <filename>/etc/rc</filename> scripts.</para> |
| 78 |
</listitem> |
| 79 |
|
| 80 |
<listitem> |
| 81 |
<para>Be familiar with basic network terminology.</para> |
| 82 |
</listitem> |
| 83 |
</itemizedlist> |
| 84 |
</sect1> |
| 85 |
|
| 86 |
<sect1 id="network-routing"> |
| 87 |
<sect1info> |
| 88 |
<authorgroup> |
| 89 |
<author> |
| 90 |
<firstname>Coranth</firstname> |
| 91 |
<surname>Gryphon</surname> |
| 92 |
<contrib>Contributed by </contrib> |
| 93 |
</author> |
| 94 |
</authorgroup> |
| 95 |
</sect1info> |
| 96 |
<title>Gateways and Routes</title> |
| 97 |
|
| 98 |
<indexterm><primary>routing</primary></indexterm> |
| 99 |
<indexterm><primary>gateway</primary></indexterm> |
| 100 |
<indexterm><primary>subnet</primary></indexterm> |
| 101 |
<para>For one machine to be able to find another over a network, |
| 102 |
there must be a mechanism in place to describe how to get from |
| 103 |
one to the other. This is called |
| 104 |
<firstterm>routing</firstterm>. A <quote>route</quote> is a |
| 105 |
defined pair of addresses: a <quote>destination</quote> and a |
| 106 |
<quote>gateway</quote>. The pair indicates that if you are |
| 107 |
trying to get to this <emphasis>destination</emphasis>, |
| 108 |
communicate through this <emphasis>gateway</emphasis>. There |
| 109 |
are three types of destinations: individual hosts, subnets, and |
| 110 |
<quote>default</quote>. The <quote>default route</quote> is |
| 111 |
used if none of the other routes apply. We will talk a little |
| 112 |
bit more about default routes later on. There are also three |
| 113 |
types of gateways: individual hosts, interfaces (also called |
| 114 |
<quote>links</quote>), and Ethernet hardware addresses (MAC |
| 115 |
addresses). |
| 116 |
</para> |
| 117 |
|
| 118 |
<sect2> |
| 119 |
<title>An Example</title> |
| 120 |
|
| 121 |
<para>To illustrate different aspects of routing, we will use the |
| 122 |
following example from <command>netstat</command>:</para> |
| 123 |
|
| 124 |
<screen>&prompt.user; <userinput>netstat -r</userinput> |
| 125 |
Routing tables |
| 126 |
|
| 127 |
Destination Gateway Flags Refs Use Netif Expire |
| 128 |
|
| 129 |
default outside-gw UGSc 37 418 ppp0 |
| 130 |
localhost localhost UH 0 181 lo0 |
| 131 |
test0 0:e0:b5:36:cf:4f UHLW 5 63288 ed0 77 |
| 132 |
10.20.30.255 link#1 UHLW 1 2421 |
| 133 |
example.com link#1 UC 0 0 |
| 134 |
host1 0:e0:a8:37:8:1e UHLW 3 4601 lo0 |
| 135 |
host2 0:e0:a8:37:8:1e UHLW 0 5 lo0 => |
| 136 |
host2.example.com link#1 UC 0 0 |
| 137 |
224 link#1 UC 0 0</screen> |
| 138 |
|
| 139 |
<indexterm><primary>default route</primary></indexterm> |
| 140 |
<para>The first two lines specify the default route (which we |
| 141 |
will cover in the <link linkend="network-routing-default">next |
| 142 |
section</link>) and the <hostid>localhost</hostid> route.</para> |
| 143 |
|
| 144 |
<indexterm><primary>loopback device</primary></indexterm> |
| 145 |
<para>The interface (<literal>Netif</literal> column) that this |
| 146 |
routing table specifies to use for |
| 147 |
<literal>localhost</literal> is <devicename>lo0</devicename>, |
| 148 |
also known as the loopback device. This says to keep all |
| 149 |
traffic for this destination internal, rather than sending it |
| 150 |
out over the LAN, since it will only end up back where it |
| 151 |
started.</para> |
| 152 |
|
| 153 |
<indexterm> |
| 154 |
<primary>Ethernet</primary> |
| 155 |
<secondary>MAC address</secondary> |
| 156 |
</indexterm> |
| 157 |
<para>The next thing that stands out are the addresses beginning |
| 158 |
with <hostid role="mac">0:e0:</hostid>. These are Ethernet |
| 159 |
hardware addresses, which are also known as MAC addresses. |
| 160 |
FreeBSD will automatically identify any hosts |
| 161 |
(<hostid>test0</hostid> in the example) on the local Ethernet |
| 162 |
and add a route for that host, directly to it over the |
| 163 |
Ethernet interface, <devicename>ed0</devicename>. There is |
| 164 |
also a timeout (<literal>Expire</literal> column) associated |
| 165 |
with this type of route, which is used if we fail to hear from |
| 166 |
the host in a specific amount of time. When this happens, the |
| 167 |
route to this host will be automatically deleted. These hosts |
| 168 |
are identified using a mechanism known as RIP (Routing |
| 169 |
Information Protocol), which figures out routes to local hosts |
| 170 |
based upon a shortest path determination.</para> |
| 171 |
|
| 172 |
<indexterm><primary>subnet</primary></indexterm> |
| 173 |
<para>FreeBSD will also add subnet routes for the local subnet (<hostid |
| 174 |
role="ipaddr">10.20.30.255</hostid> is the broadcast address for the |
| 175 |
subnet <hostid role="ipaddr">10.20.30</hostid>, and <hostid |
| 176 |
role="domainname">example.com</hostid> is the domain name associated |
| 177 |
with that subnet). The designation <literal>link#1</literal> refers |
| 178 |
to the first Ethernet card in the machine. You will notice no |
| 179 |
additional interface is specified for those.</para> |
| 180 |
|
| 181 |
<para>Both of these groups (local network hosts and local subnets) have |
| 182 |
their routes automatically configured by a daemon called |
| 183 |
<application>routed</application>. If this is not run, then only |
| 184 |
routes which are statically defined (i.e. entered explicitly) will |
| 185 |
exist.</para> |
| 186 |
|
| 187 |
<para>The <literal>host1</literal> line refers to our host, which it |
| 188 |
knows by Ethernet address. Since we are the sending host, FreeBSD |
| 189 |
knows to use the loopback interface (<devicename>lo0</devicename>) |
| 190 |
rather than sending it out over the Ethernet interface.</para> |
| 191 |
|
| 192 |
<para>The two <literal>host2</literal> lines are an example of |
| 193 |
what happens when we use an &man.ifconfig.8; alias (see the |
| 194 |
section on Ethernet for reasons why we would do this). The |
| 195 |
<literal>=></literal> symbol after the |
| 196 |
<devicename>lo0</devicename> interface says that not only are |
| 197 |
we using the loopback (since this address also refers to the |
| 198 |
local host), but specifically it is an alias. Such routes |
| 199 |
only show up on the host that supports the alias; all other |
| 200 |
hosts on the local network will simply have a |
| 201 |
<literal>link#1</literal> line for such routes.</para> |
| 202 |
|
| 203 |
<para>The final line (destination subnet <literal>224</literal>) deals |
| 204 |
with multicasting, which will be covered in another section.</para> |
| 205 |
|
| 206 |
<para>Finally, various attributes of each route can be seen in |
| 207 |
the <literal>Flags</literal> column. Below is a short table |
| 208 |
of some of these flags and their meanings:</para> |
| 209 |
|
| 210 |
<informaltable frame="none"> |
| 211 |
<tgroup cols="2"> |
| 212 |
<tbody> |
| 213 |
<row> |
| 214 |
<entry>U</entry> |
| 215 |
<entry>Up: The route is active.</entry> |
| 216 |
</row> |
| 217 |
|
| 218 |
<row> |
| 219 |
<entry>H</entry> |
| 220 |
<entry>Host: The route destination is a single host.</entry> |
| 221 |
</row> |
| 222 |
|
| 223 |
<row> |
| 224 |
<entry>G</entry> |
| 225 |
<entry>Gateway: Send anything for this destination on to this |
| 226 |
remote system, which will figure out from there where to send |
| 227 |
it.</entry> |
| 228 |
</row> |
| 229 |
|
| 230 |
<row> |
| 231 |
<entry>S</entry> |
| 232 |
<entry>Static: This route was configured manually, not |
| 233 |
automatically generated by the system.</entry> |
| 234 |
</row> |
| 235 |
|
| 236 |
<row> |
| 237 |
<entry>C</entry> |
| 238 |
<entry>Clone: Generates a new route based upon this route for |
| 239 |
machines we connect to. This type of route is normally used |
| 240 |
for local networks.</entry> |
| 241 |
</row> |
| 242 |
|
| 243 |
<row> |
| 244 |
<entry>W</entry> |
| 245 |
<entry>WasCloned: Indicated a route that was auto-configured |
| 246 |
based upon a local area network (Clone) route.</entry> |
| 247 |
</row> |
| 248 |
|
| 249 |
<row> |
| 250 |
<entry>L</entry> |
| 251 |
<entry>Link: Route involves references to Ethernet |
| 252 |
hardware.</entry> |
| 253 |
</row> |
| 254 |
</tbody> |
| 255 |
</tgroup> |
| 256 |
</informaltable> |
| 257 |
</sect2> |
| 258 |
|
| 259 |
<sect2 id="network-routing-default"> |
| 260 |
<title>Default Routes</title> |
| 261 |
|
| 262 |
<indexterm><primary>default route</primary></indexterm> |
| 263 |
<para>When the local system needs to make a connection to a remote host, |
| 264 |
it checks the routing table to determine if a known path exists. If |
| 265 |
the remote host falls into a subnet that we know how to reach (Cloned |
| 266 |
routes), then the system checks to see if it can connect along that |
| 267 |
interface.</para> |
| 268 |
|
| 269 |
<para>If all known paths fail, the system has one last option: the |
| 270 |
<quote>default</quote> route. This route is a special type of gateway |
| 271 |
route (usually the only one present in the system), and is always |
| 272 |
marked with a <literal>c</literal> in the flags field. For hosts on a |
| 273 |
local area network, this gateway is set to whatever machine has a |
| 274 |
direct connection to the outside world (whether via PPP link, |
| 275 |
DSL, cable modem, T1, or another network interface).</para> |
| 276 |
|
| 277 |
<para>If you are configuring the default route for a machine which |
| 278 |
itself is functioning as the gateway to the outside world, then the |
| 279 |
default route will be the gateway machine at your Internet Service |
| 280 |
Provider's (ISP) site.</para> |
| 281 |
|
| 282 |
<para>Let us look at an example of default routes. This is a common |
| 283 |
configuration:</para> |
| 284 |
|
| 285 |
<literallayout> |
| 286 |
[Local2] <--ether--> [Local1] <--PPP--> [ISP-Serv] <--ether--> [T1-GW] |
| 287 |
</literallayout> |
| 288 |
|
| 289 |
<para>The hosts <hostid>Local1</hostid> and |
| 290 |
<hostid>Local2</hostid> are at your site. |
| 291 |
<hostid>Local1</hostid> is connected to an ISP via a dial up |
| 292 |
PPP connection. This PPP server computer is connected through |
| 293 |
a local area network to another gateway computer through an |
| 294 |
external interface to the ISPs Internet feed.</para> |
| 295 |
|
| 296 |
<para>The default routes for each of your machines will be:</para> |
| 297 |
|
| 298 |
<informaltable frame="none"> |
| 299 |
<tgroup cols="3"> |
| 300 |
<thead> |
| 301 |
<row> |
| 302 |
<entry>Host</entry> |
| 303 |
<entry>Default Gateway</entry> |
| 304 |
<entry>Interface</entry> |
| 305 |
</row> |
| 306 |
</thead> |
| 307 |
|
| 308 |
<tbody> |
| 309 |
<row> |
| 310 |
<entry>Local2</entry> |
| 311 |
<entry>Local1</entry> |
| 312 |
<entry>Ethernet</entry> |
| 313 |
</row> |
| 314 |
|
| 315 |
<row> |
| 316 |
<entry>Local1</entry> |
| 317 |
<entry>T1-GW</entry> |
| 318 |
<entry>PPP</entry> |
| 319 |
</row> |
| 320 |
</tbody> |
| 321 |
</tgroup> |
| 322 |
</informaltable> |
| 323 |
|
| 324 |
<para>A common question is <quote>Why (or how) would we set |
| 325 |
the <hostid>T1-GW</hostid> to be the default gateway for |
| 326 |
<hostid>Local1</hostid>, rather than the ISP server it is |
| 327 |
connected to?</quote>.</para> |
| 328 |
|
| 329 |
<para>Remember, since the PPP interface is using an address on the ISP's |
| 330 |
local network for your side of the connection, routes for any other |
| 331 |
machines on the ISP's local network will be automatically generated. |
| 332 |
Hence, you will already know how to reach the <hostid>T1-GW</hostid> |
| 333 |
machine, so there is no need for the intermediate step |
| 334 |
of sending traffic to the ISP server.</para> |
| 335 |
|
| 336 |
<para>As a final note, it is common to use the address <hostid |
| 337 |
role="ipaddr">X.X.X.1</hostid> as the gateway address for your local |
| 338 |
network. So (using the same example), if your local class-C address |
| 339 |
space was <hostid role="ipaddr">10.20.30</hostid> and your ISP was |
| 340 |
using <hostid role="ipaddr">10.9.9</hostid> then the default routes |
| 341 |
would be:</para> |
| 342 |
|
| 343 |
<informaltable frame="none"> |
| 344 |
<tgroup cols="2"> |
| 345 |
<thead> |
| 346 |
<row> |
| 347 |
<entry>Host</entry> |
| 348 |
<entry>Default Route</entry> |
| 349 |
</row> |
| 350 |
</thead> |
| 351 |
<tbody> |
| 352 |
<row> |
| 353 |
<entry>Local2 (10.20.30.2)</entry> |
| 354 |
<entry>Local1 (10.20.30.1)</entry> |
| 355 |
</row> |
| 356 |
<row> |
| 357 |
<entry>Local1 (10.20.30.1, 10.9.9.30)</entry> |
| 358 |
<entry>T1-GW (10.9.9.1)</entry> |
| 359 |
</row> |
| 360 |
</tbody> |
| 361 |
</tgroup> |
| 362 |
</informaltable> |
| 363 |
</sect2> |
| 364 |
|
| 365 |
<sect2> |
| 366 |
<title>Dual Homed Hosts</title> |
| 367 |
<indexterm><primary>dual homed hosts</primary></indexterm> |
| 368 |
<para>There is one other type of configuration that we should cover, and |
| 369 |
that is a host that sits on two different networks. Technically, any |
| 370 |
machine functioning as a gateway (in the example above, using a PPP |
| 371 |
connection) counts as a dual-homed host. But the term is really only |
| 372 |
used to refer to a machine that sits on two local-area |
| 373 |
networks.</para> |
| 374 |
|
| 375 |
<para>In one case, the machine has two Ethernet cards, each |
| 376 |
having an address on the separate subnets. Alternately, the |
| 377 |
machine may only have one Ethernet card, and be using |
| 378 |
&man.ifconfig.8; aliasing. The former is used if two |
| 379 |
physically separate Ethernet networks are in use, the latter |
| 380 |
if there is one physical network segment, but two logically |
| 381 |
separate subnets.</para> |
| 382 |
|
| 383 |
<para>Either way, routing tables are set up so that each subnet knows |
| 384 |
that this machine is the defined gateway (inbound route) to the other |
| 385 |
subnet. This configuration, with the machine acting as a router |
| 386 |
between the two subnets, is often used when we need to implement |
| 387 |
packet filtering or firewall security in either or both |
| 388 |
directions.</para> |
| 389 |
|
| 390 |
<para>If you want this machine to actually forward packets |
| 391 |
between the two interfaces, you need to tell FreeBSD to enable |
| 392 |
this ability.</para> |
| 393 |
</sect2> |
| 394 |
|
| 395 |
<sect2 id="network-dedicated-router"> |
| 396 |
<title>Building a Router</title> |
| 397 |
|
| 398 |
<indexterm><primary>router</primary></indexterm> |
| 399 |
|
| 400 |
<para>A network router is simply a system that forwards packets |
| 401 |
from one interface to another. Internet standards and good |
| 402 |
engineering practice prevent the FreeBSD Project from enabling |
| 403 |
this by default in FreeBSD. You can enable this feature by |
| 404 |
changing the following variable to <literal>YES</literal> in |
| 405 |
&man.rc.conf.5;:</para> |
| 406 |
|
| 407 |
<programlisting>gateway_enable=YES # Set to YES if this host will be a gateway</programlisting> |
| 408 |
|
| 409 |
<para>This option will set the &man.sysctl.8; variable |
| 410 |
<varname>net.inet.ip.forwarding</varname> to |
| 411 |
<literal>1</literal>. If you should need to stop routing |
| 412 |
temporarily, you can reset this to <literal>0</literal> temporarily.</para> |
| 413 |
|
| 414 |
<para>Your new router will need routes to know where to send the |
| 415 |
traffic. If your network is simple enough you can use static |
| 416 |
routes. FreeBSD also comes with the standard BSD routing |
| 417 |
daemon &man.routed.8;, which speaks RIP (both version 1 and |
| 418 |
version 2) and IRDP. Support for BGP v4, OSPF v2, and other |
| 419 |
sophisticated routing protocols is available with the |
| 420 |
<filename role="package">net/zebra</filename> package. |
| 421 |
Commercial products such as gated are also available for more |
| 422 |
complex network routing solutions.</para> |
| 423 |
|
| 424 |
<indexterm><primary>BGP</primary></indexterm> |
| 425 |
<indexterm><primary>RIP</primary></indexterm> |
| 426 |
<indexterm><primary>OSPF</primary></indexterm> |
| 427 |
|
| 428 |
<para>Even when FreeBSD is configured in this way, it does not |
| 429 |
completely comply with the Internet standard requirements for |
| 430 |
routers. It comes close enough for ordinary use, |
| 431 |
however.</para> |
| 432 |
</sect2> |
| 433 |
|
| 434 |
<sect2> |
| 435 |
<title>Routing Propagation</title> |
| 436 |
<indexterm><primary>routing propagation</primary></indexterm> |
| 437 |
<para>We have already talked about how we define our routes to the |
| 438 |
outside world, but not about how the outside world finds us.</para> |
| 439 |
|
| 440 |
<para>We already know that routing tables can be set up so that all |
| 441 |
traffic for a particular address space (in our examples, a class-C |
| 442 |
subnet) can be sent to a particular host on that network, which will |
| 443 |
forward the packets inbound.</para> |
| 444 |
|
| 445 |
<para>When you get an address space assigned to your site, your service |
| 446 |
provider will set up their routing tables so that all traffic for your |
| 447 |
subnet will be sent down your PPP link to your site. But how do sites |
| 448 |
across the country know to send to your ISP?</para> |
| 449 |
|
| 450 |
<para>There is a system (much like the distributed DNS information) that |
| 451 |
keeps track of all assigned address-spaces, and defines their point of |
| 452 |
connection to the Internet Backbone. The <quote>Backbone</quote> are |
| 453 |
the main trunk lines that carry Internet traffic across the country, |
| 454 |
and around the world. Each backbone machine has a copy of a master |
| 455 |
set of tables, which direct traffic for a particular network to a |
| 456 |
specific backbone carrier, and from there down the chain of service |
| 457 |
providers until it reaches your network.</para> |
| 458 |
|
| 459 |
<para>It is the task of your service provider to advertise to the |
| 460 |
backbone sites that they are the point of connection (and thus the |
| 461 |
path inward) for your site. This is known as route |
| 462 |
propagation.</para> |
| 463 |
</sect2> |
| 464 |
|
| 465 |
<sect2> |
| 466 |
<title>Troubleshooting</title> |
| 467 |
<indexterm> |
| 468 |
<primary><command>traceroute</command></primary> |
| 469 |
</indexterm> |
| 470 |
<para>Sometimes, there is a problem with routing propagation, and some |
| 471 |
sites are unable to connect to you. Perhaps the most useful command |
| 472 |
for trying to figure out where routing is breaking down is the |
| 473 |
&man.traceroute.8; command. It is equally useful if you cannot seem |
| 474 |
to make a connection to a remote machine (i.e. &man.ping.8; |
| 475 |
fails).</para> |
| 476 |
|
| 477 |
<para>The &man.traceroute.8; command is run with the name of the remote |
| 478 |
host you are trying to connect to. It will show the gateway hosts |
| 479 |
along the path of the attempt, eventually either reaching the target |
| 480 |
host, or terminating because of a lack of connection.</para> |
| 481 |
|
| 482 |
<para>For more information, see the manual page for |
| 483 |
&man.traceroute.8;.</para> |
| 484 |
</sect2> |
| 485 |
|
| 486 |
<sect2> |
| 487 |
<title>Multicast Routing</title> |
| 488 |
<indexterm> |
| 489 |
<primary>multicast</primary> |
| 490 |
<secondary>options MROUTING</secondary> |
| 491 |
</indexterm> |
| 492 |
<para>FreeBSD supports both multicast applications and multicast |
| 493 |
routing natively. Multicast applications do not require any |
| 494 |
special configuration of FreeBSD; applications will generally |
| 495 |
run out of the box. Multicast routing |
| 496 |
requires that support be compiled into the kernel:</para> |
| 497 |
|
| 498 |
<programlisting>options MROUTING</programlisting> |
| 499 |
|
| 500 |
<para>In addition, the multicast routing daemon, &man.mrouted.8; |
| 501 |
must be configured to set up tunnels and DVMRP via |
| 502 |
<filename>/etc/mrouted.conf</filename>. More details on |
| 503 |
multicast configuration may be found in the man pages for |
| 504 |
mrouted.</para> |
| 505 |
</sect2> |
| 506 |
</sect1> |
| 507 |
|
| 508 |
<sect1 id="network-wireless"> |
| 509 |
<sect1info> |
| 510 |
<authorgroup> |
| 511 |
<author> |
| 512 |
<firstname>Eric</firstname> |
| 513 |
<surname>Anderson</surname> |
| 514 |
<contrib>Written by </contrib> |
| 515 |
</author> |
| 516 |
</authorgroup> |
| 517 |
</sect1info> |
| 518 |
<title>Wireless Networking</title> |
| 519 |
|
| 520 |
<indexterm><primary>wireless networking</primary></indexterm> |
| 521 |
<indexterm> |
| 522 |
<primary>802.11</primary> |
| 523 |
<see>wireless networking</see> |
| 524 |
</indexterm> |
| 525 |
|
| 526 |
<sect2> |
| 527 |
<title>Introduction</title> |
| 528 |
<para>It can be very useful to be able to use a computer without the |
| 529 |
annoyance of having a network cable attached at all times. FreeBSD can |
| 530 |
be used as a wireless client, and even as a wireless <quote>access |
| 531 |
point</quote>.</para> |
| 532 |
</sect2> |
| 533 |
|
| 534 |
<sect2> |
| 535 |
<title>Wireless Modes of Operation</title> |
| 536 |
<para>There are two different ways to configure 802.11 wireless devices: |
| 537 |
BSS and IBSS.</para> |
| 538 |
|
| 539 |
<sect3> |
| 540 |
<title>BSS Mode</title> |
| 541 |
<para>BSS mode is the mode that typically is used. BSS mode is |
| 542 |
also called infrastructure mode. In this mode, a number of |
| 543 |
wireless access points are connected to a wired network. Each |
| 544 |
wireless network has its own name. This name is called the |
| 545 |
SSID of the network.</para> |
| 546 |
|
| 547 |
<para>Wireless clients connect to these wireless access |
| 548 |
points. The IEEE 802.11 standard defines the protocol that |
| 549 |
wireless networks use to connect. A wireless client can be |
| 550 |
tied to a specific network, when a SSID is set. A wireless |
| 551 |
client can also attach to any network by not explicitly |
| 552 |
setting a SSID.</para> |
| 553 |
</sect3> |
| 554 |
|
| 555 |
<sect3> |
| 556 |
<title>IBSS Mode</title> |
| 557 |
<para>IBSS mode, also called ad-hoc mode, is designed for point |
| 558 |
to point connections. There are actually two types of ad-hoc |
| 559 |
mode. One is IBSS mode, also called ad-hoc or IEEE ad-hoc |
| 560 |
mode. This mode is defined by the IEEE 802.11 standards. |
| 561 |
The second is called demo ad-hoc mode or Lucent ad-hoc mode |
| 562 |
(and sometimes, confusingly, ad-hoc mode). This is the old, |
| 563 |
pre-802.11 ad-hoc mode and should only be used for legacy |
| 564 |
installations. We will not cover either of the ad-hoc modes |
| 565 |
further.</para> |
| 566 |
</sect3> |
| 567 |
</sect2> |
| 568 |
|
| 569 |
<sect2> |
| 570 |
<title>Infrastructure Mode</title> |
| 571 |
<sect3> |
| 572 |
<title>Access Points</title> |
| 573 |
|
| 574 |
<para>Access points are wireless networking devices that allow |
| 575 |
one or more wireless clients to use the device as a central |
| 576 |
hub. When using an access point, all clients communicate |
| 577 |
through the access point. Multiple access points are often |
| 578 |
used to cover a complete area such as a house, business, or |
| 579 |
park with a wireless network.</para> |
| 580 |
|
| 581 |
<para>Access points typically have multiple network |
| 582 |
connections: the wireless card, and one or more wired Ethernet |
| 583 |
adapters for connection to the rest of the network. |
| 584 |
</para> |
| 585 |
|
| 586 |
<para>Access points can either be purchased prebuilt, or you |
| 587 |
can build your own with FreeBSD and a supported wireless card. |
| 588 |
Several vendors make wireless access points and wireless cards |
| 589 |
with various features.</para> |
| 590 |
</sect3> |
| 591 |
|
| 592 |
<sect3> |
| 593 |
<title>Building a FreeBSD Access Point</title> |
| 594 |
<indexterm><primary>wireless networking</primary> |
| 595 |
<secondary>access point</secondary> |
| 596 |
</indexterm> |
| 597 |
|
| 598 |
<sect4><title>Requirements</title> |
| 599 |
|
| 600 |
<para>In order to set up a wireless access point with |
| 601 |
FreeBSD, you need to have a compatible wireless card. |
| 602 |
Currently, only cards with the Prism chipset are |
| 603 |
supported. You will also need a wired network card that is |
| 604 |
supported by FreeBSD (this should not be difficult to find, |
| 605 |
FreeBSD supports a lot of different devices). For this |
| 606 |
guide, we will assume you want to &man.bridge.4; all traffic |
| 607 |
between the wireless device and the network attached to the |
| 608 |
wired network card.</para> |
| 609 |
|
| 610 |
<para>The hostap functionality that FreeBSD uses to implement |
| 611 |
the access point works best with certain versions of |
| 612 |
firmware. Prism 2 cards should use firmware version 1.3.4 |
| 613 |
or newer. Prism 2.5 and Prism 3 cards should use firmware |
| 614 |
1.4.9. Older versions of the firmware way or may not |
| 615 |
function correctly. At this time, the only way to update |
| 616 |
cards is with windows firmware update utilities available |
| 617 |
from your card's manufacturer.</para> |
| 618 |
</sect4> |
| 619 |
|
| 620 |
<sect4> |
| 621 |
<title>Setting It Up</title> |
| 622 |
<para>First, make sure your system can see the wireless card:</para> |
| 623 |
<screen>&prompt.root; <userinput>ifconfig -a</userinput> |
| 624 |
wi0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 |
| 625 |
inet6 fe80::202:2dff:fe2d:c938%wi0 prefixlen 64 scopeid 0x7 |
| 626 |
inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255 |
| 627 |
ether 00:09:2d:2d:c9:50 |
| 628 |
media: IEEE 802.11 Wireless Ethernet autoselect (DS/2Mbps) |
| 629 |
status: no carrier |
| 630 |
ssid "" |
| 631 |
stationname "FreeBSD Wireless node" |
| 632 |
channel 10 authmode OPEN powersavemode OFF powersavesleep 100 |
| 633 |
wepmode OFF weptxkey 1</screen> |
| 634 |
|
| 635 |
<para>Do not worry about the details now, just make sure it shows you |
| 636 |
something to indicate you have a wireless card installed. |
| 637 |
If you have trouble seeing the wireless interface, and you |
| 638 |
are using a PC Card, you may want to check out |
| 639 |
&man.pccardc.8; and &man.pccardd.8; manual pages for more |
| 640 |
information.</para> |
| 641 |
|
| 642 |
<para>Next, you will need to load a module in order to get |
| 643 |
the bridging part of FreeBSD ready for the access point. In |
| 644 |
order to load the &man.bridge.4; module, simply run the |
| 645 |
following command:</para> |
| 646 |
|
| 647 |
<screen>&prompt.root; <userinput>kldload bridge</userinput></screen> |
| 648 |
|
| 649 |
<para>It should not have produced any errors when loading the |
| 650 |
module. If it did, you may need to compile the |
| 651 |
&man.bridge.4; code into your kernel. The <link |
| 652 |
linkend="network-bridging">Bridging</link> section of the handbook |
| 653 |
should be able to help you accomplish that task.</para> |
| 654 |
|
| 655 |
<para>Now that you have the bridging stuff done, we need to |
| 656 |
tell the FreeBSD kernel which interfaces to bridge together. |
| 657 |
We do that by using &man.sysctl.8;:</para> |
| 658 |
|
| 659 |
<screen>&prompt.root; <userinput>sysctl net.link.ether.bridge=1</userinput> |
| 660 |
&prompt.root; <userinput>sysctl net.link.ether.bridge_cfg="wi0 xl0"</userinput> |
| 661 |
&prompt.root; <userinput>sysctl net.inet.ip.forwarding=1</userinput></screen> |
| 662 |
|
| 663 |
<para>Now it is time for the wireless card setup.</para> |
| 664 |
<para>The following command will set the card into an access point:</para> |
| 665 |
|
| 666 |
<screen> |
| 667 |
&prompt.root; <userinput>ifconfig wi0 ssid my_net channel 11 media DS/11Mbps mediaopt hostap up stationname "FreeBSD AP"</userinput> |
| 668 |
</screen> |
| 669 |
|
| 670 |
<para>The &man.ifconfig.8; line brings the |
| 671 |
<devicename>wi0</devicename> interface up, sets its SSID to |
| 672 |
<literal>my_net</literal>, and sets the station name to |
| 673 |
<literal>FreeBSD AP</literal>. The <option>media |
| 674 |
DS/11Mbps</option> sets the card into 11Mbps mode and is |
| 675 |
needed for any <option>mediaopt</option> to take effect. |
| 676 |
The <option>mediaopt hostap</option> option places the |
| 677 |
interface into access point mode. The <option>channel |
| 678 |
11</option> option sets the 802.11b channel to use. The |
| 679 |
&man.wicontrol.8; man page has valid channel options for |
| 680 |
your regulatory domain. |
| 681 |
</para> |
| 682 |
|
| 683 |
<para>Now you should have a complete functioning access point |
| 684 |
up and running. You are encouraged to read |
| 685 |
&man.wicontrol.8;, &man.ifconfig.8;, and &man.wi.4; for |
| 686 |
further information. |
| 687 |
</para> |
| 688 |
|
| 689 |
<para>It is also suggested that you read the section on encryption that follows.</para> |
| 690 |
</sect4> |
| 691 |
|
| 692 |
<sect4> |
| 693 |
<title>Status Information</title> |
| 694 |
<para>Once the access point is configured and operational, |
| 695 |
operators will want to see the clients that are associated |
| 696 |
with the access point. At any time, the operator may type:</para> |
| 697 |
|
| 698 |
<screen>&prompt.root; <userinput>wicontrol -l</userinput> |
| 699 |
1 station: |
| 700 |
00:09:b7:7b:9d:16 asid=04c0, flags=3<ASSOC,AUTH>, caps=1<ESS>, rates=f<1M,2M,5.5M,11M>, sig=38/15 |
| 701 |
</screen> |
| 702 |
|
| 703 |
<para>This shows that there's one station associated, along |
| 704 |
with its parameters. The signal indicated should be used |
| 705 |
as a relative indication of strength only. Its |
| 706 |
translation to dBm or other units varies between different |
| 707 |
firmware revisions.</para> |
| 708 |
</sect4> |
| 709 |
</sect3> |
| 710 |
|
| 711 |
<sect3> |
| 712 |
<title>Clients</title> |
| 713 |
|
| 714 |
<para>A wireless client is a system that accesses an access |
| 715 |
point or another client directly. </para> |
| 716 |
|
| 717 |
<para>Typically, wireless clients only have one network device, |
| 718 |
the wireless networking card.<para> |
| 719 |
|
| 720 |
<para>There are a few different ways to configure a wireless |
| 721 |
client. These are based on the different wireless modes, |
| 722 |
generally BSS (infrastructure mode, which requires an access |
| 723 |
point), and IBSS (ad-hoc, or peer-to-peer mode). In our |
| 724 |
example, we will use the most popular of the two, BSS mode, to |
| 725 |
talk to an access point.</para> |
| 726 |
|
| 727 |
<sect4> |
| 728 |
<title>Requirements</title> |
| 729 |
<para>There is only one real requirement for setting up FreeBSD as a wireless client. |
| 730 |
You will need a wireless card that is supported by FreeBSD.</para> |
| 731 |
</sect4> |
| 732 |
|
| 733 |
<sect4> |
| 734 |
<title>Setting Up a Wireless FreeBSD Client</title> |
| 735 |
|
| 736 |
<para>You will need to know a few things about the wireless |
| 737 |
network you are joining before you start. In this example, we |
| 738 |
are joining a network that has a name of |
| 739 |
<literal>my_net</literal>, and encryption turned off.</para> |
| 740 |
|
| 741 |
<para>Note: In this example, we are not using encryption, which |
| 742 |
is a dangerous situation. In the next section, you will learn |
| 743 |
how to turn on encryption, and why it is important to do so, |
| 744 |
and why some encryption technologies still do not completely |
| 745 |
protect you.</para> |
| 746 |
|
| 747 |
<para>Make sure your card is recognized by FreeBSD:</para> |
| 748 |
|
| 749 |
<screen>&prompt.root; <userinput>ifconfig -a</userinput> |
| 750 |
wi0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 |
| 751 |
inet6 fe80::202:2dff:fe2d:c938%wi0 prefixlen 64 scopeid 0x7 |
| 752 |
inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255 |
| 753 |
ether 00:09:2d:2d:c9:50 |
| 754 |
media: IEEE 802.11 Wireless Ethernet autoselect (DS/2Mbps) |
| 755 |
status: no carrier |
| 756 |
ssid "" |
| 757 |
stationname "FreeBSD Wireless node" |
| 758 |
channel 10 authmode OPEN powersavemode OFF powersavesleep 100 |
| 759 |
wepmode OFF weptxkey 1</screen> |
| 760 |
|
| 761 |
<para>Now, we will set the card to the correct settings for our |
| 762 |
network:</para> |
| 763 |
|
| 764 |
<screen>&prompt.root; <userinput>ifconfig wi0 inet 192.168.0.20 netmask 255.255.255.0 ssid my_net</userinput></screen> |
| 765 |
|
| 766 |
<para>Replace <hostid role="IPAddr">192.168.0.20</hostid> and |
| 767 |
<hostid role="Netmask">255.255.255.0</hostid> with a valid IP |
| 768 |
address and netmask on your wired network. Remember, our |
| 769 |
access point is bridging the data between the wireless |
| 770 |
network, and the wired network, so it will appear to the other |
| 771 |
devices on your network that you are on the wired network just |
| 772 |
as they are.</para> |
| 773 |
|
| 774 |
<para>Once you have done that, you should be able to ping hosts |
| 775 |
on the wired network just as if you were connected using a |
| 776 |
standard wired connection.</para> |
| 777 |
|
| 778 |
<para>If you are experiencing problems with your wireless |
| 779 |
connection, check to make sure that your are associated |
| 780 |
(connected) to the access point:</para> |
| 781 |
|
| 782 |
<screen>&prompt.root; <userinput>ifconfig wi0</userinput></screen> |
| 783 |
|
| 784 |
<para>should return some information, and you should see:</para> |
| 785 |
<screen>status: associated</screen> |
| 786 |
|
| 787 |
<para>If it does not show associated, then you may be out of |
| 788 |
range of the access point, do not have encryption on, or |
| 789 |
possibly have a configuration problem.</para> |
| 790 |
|
| 791 |
</sect4> |
| 792 |
</sect3> |
| 793 |
|
| 794 |
<sect3> |
| 795 |
<title>Encryption</title> |
| 796 |
<indexterm> |
| 797 |
<primary>wireless networking</primary> |
| 798 |
<secondary>encryption</secondary> |
| 799 |
</indexterm> |
| 800 |
|
| 801 |
<para>Encryption on a wireless network is important because you |
| 802 |
no longer have the ability to keep the network contained in a |
| 803 |
well protected area. Your wireless data will be broadcast |
| 804 |
across your entire neighborhood, so anyone who cares to read it |
| 805 |
can. This is where encryption comes in. By encrypting the |
| 806 |
data that is sent over the airwaves, you make it much more |
| 807 |
difficult for any interested party to grab your data right out |
| 808 |
of the air. </para> |
| 809 |
|
| 810 |
<para>The two most common ways to encrypt the data between your |
| 811 |
client and the access point, are WEP, and &man.ipsec.4;.</para> |
| 812 |
|
| 813 |
<sect4> |
| 814 |
<title>WEP</title> |
| 815 |
<indexterm><primary>WEP</primary></indexterm> |
| 816 |
|
| 817 |
<para>WEP is an abbreviation for Wired Equivalency Protocol. |
| 818 |
WEP is an attempt to make wireless networks as safe and secure |
| 819 |
as a wired network. Unfortunately, it has been cracked, and is |
| 820 |
fairly trivial to break. This also means it is not something |
| 821 |
to rely on when it comes to encrypting sensitive data. </para> |
| 822 |
|
| 823 |
<para>It is better than nothing, so use the following to turn on |
| 824 |
WEP on your new FreeBSD access point:</para> |
| 825 |
|
| 826 |
<screen>&prompt.root; <userinput>ifconfig wi0 inet up ssid my_net wepmode on wepkey 0x1234567890 media DS/11Mbps mediaopt hostap</userinput></screen> |
| 827 |
|
| 828 |
<para>And you can turn on WEP on a client with this command:</para> |
| 829 |
|
| 830 |
<screen>&prompt.root; <userinput>ifconfig wi0 inet 192.168.0.20 netmask 255.255.255.0 ssid my_net wepmode on wepkey 0x1234567890</userinput></screen> |
| 831 |
|
| 832 |
<para>Note that you should replace the <literal>0x1234567890</literal> with a more unique key.</para> |
| 833 |
|
| 834 |
</sect4> |
| 835 |
|
| 836 |
<sect4> |
| 837 |
<title>IPsec</title> |
| 838 |
|
| 839 |
<para>&man.ipsec.4; is a much more robust and powerful tool for |
| 840 |
encrypting data across a network. This is definitely the |
| 841 |
preferred way to encrypt wireless data over a network. You can |
| 842 |
read more about &man.ipsec.4; security and how to implement it |
| 843 |
in the <link linkend="ipsec">IPsec</link> section of the |
| 844 |
handbook.</para> |
| 845 |
</sect4> |
| 846 |
</sect3> |
| 847 |
|
| 848 |
<sect3> |
| 849 |
<title>Tools</title> |
| 850 |
|
| 851 |
<para>There are a small number of tools available for use in |
| 852 |
debugging and setting up your wireless network, and here we will |
| 853 |
attempt to describe some of them and what they do.</para> |
| 854 |
|
| 855 |
<sect4> |
| 856 |
<title>The <application>bsd-airtools</application> Package</title> |
| 857 |
|
| 858 |
<para>The <application>bsd-airtools</application> package is a |
| 859 |
complete toolset that includes wireless auditing tools for WEP |
| 860 |
key cracking, access point detection, etc.</para> |
| 861 |
|
| 862 |
<para>The <application>bsd-airtools</application> utilities can be |
| 863 |
installed from the <filename |
| 864 |
role="package">net/bsd-airtools</filename> port. Information on |
| 865 |
installing ports can be found in <xref linkend="ports"> of the |
| 866 |
handbook.</para> |
| 867 |
|
| 868 |
<para>The program <command>dstumbler</command> is the packaged |
| 869 |
tool that allows for access point discovery and signal to noise |
| 870 |
ratio graphing. If you are having a hard time getting your |
| 871 |
access point up and running, <command>dstumbler</command> may |
| 872 |
help you get started.</para> |
| 873 |
|
| 874 |
<para>To test your wireless network security, you may choose to |
| 875 |
use <quote>dweputils</quote> (<command>dwepcrack</command>, |
| 876 |
<command>dwepdump</command> and <command>dwepkeygen</command>) |
| 877 |
to help you determine if WEP is the right solution to your |
| 878 |
wireless security needs.</para> |
| 879 |
|
| 880 |
</sect4> |
| 881 |
|
| 882 |
<sect4> |
| 883 |
<title>The <application>wicontrol</application>, <application>ancontrol</application> and <application>raycontrol</application> Utilities</title> |
| 884 |
|
| 885 |
<para>These are the tools you use to control how your wireless |
| 886 |
card behaves on the wireless network. In the examples above, we |
| 887 |
have chosen to use &man.wicontrol.8;, since our wireless card is |
| 888 |
a <devicename>wi0</devicename> interface. If you had a Cisco |
| 889 |
wireless device, it would come up as |
| 890 |
<devicename>an0</devicename>, and therefore you would use |
| 891 |
&man.ancontrol.8;.<para> |
| 892 |
|
| 893 |
</sect4> |
| 894 |
|
| 895 |
<sect4> |
| 896 |
<title>The <application>ifconfig</application> Command</title> |
| 897 |
<indexterm><primary>ifconfig</primary></indexterm> |
| 898 |
|
| 899 |
<para>&man.ifconfig.8; can be used to do many of the same options |
| 900 |
as &man.wicontrol.8;, however it does lack a few options. Check |
| 901 |
&man.ifconfig.8; for command line parameters and options.</para> |
| 902 |
|
| 903 |
</sect4> |
| 904 |
|
| 905 |
</sect3> |
| 906 |
|
| 907 |
<sect3> |
| 908 |
<title>Supported Cards</title> |
| 909 |
<sect4> |
| 910 |
<title>Access Points</title> |
| 911 |
|
| 912 |
<para>The only cards that are currently supported for BSS (as an |
| 913 |
access point) mode are devices based on the Prism 2, 2.5, or 3 |
| 914 |
chipsets. For a complete list, look at &man.wi.4;.</para> |
| 915 |
|
| 916 |
</sect4> |
| 917 |
|
| 918 |
<sect4> |
| 919 |
<title>Clients</title> |
| 920 |
|
| 921 |
<para>Almost all 802.11b wireless cards are currently supported |
| 922 |
under FreeBSD. Most cards based on Prism, Spectrum24, Hermes, |
| 923 |
Aironet, and Raylink will work as a wireless network card in |
| 924 |
IBSS (ad-hoc, peer-to-peer, and BSS) mode.</para> |
| 925 |
|
| 926 |
</sect4> |
| 927 |
</sect3> |
| 928 |
|
| 929 |
</sect2> |
| 930 |
</sect1> |
| 931 |
|
| 932 |
|
| 933 |
<sect1 id="network-bridging"> |
| 934 |
<sect1info> |
| 935 |
<authorgroup> |
| 936 |
<author> |
| 937 |
<firstname>Steve</firstname> |
| 938 |
<surname>Peterson</surname> |
| 939 |
<contrib>Written by </contrib> |
| 940 |
</author> |
| 941 |
</authorgroup> |
| 942 |
</sect1info> |
| 943 |
<title>Bridging</title> |
| 944 |
|
| 945 |
<sect2> |
| 946 |
<title>Introduction</title> |
| 947 |
<indexterm><primary>IP subnet</primary></indexterm> |
| 948 |
<indexterm><primary>bridge</primary></indexterm> |
| 949 |
<para>It is sometimes useful to divide one physical network |
| 950 |
(such as an Ethernet segment) into two separate network |
| 951 |
segments without having to create IP subnets and use a router |
| 952 |
to connect the segments together. A device that connects two |
| 953 |
networks together in this fashion is called a |
| 954 |
<quote>bridge</quote>. A FreeBSD system with two network |
| 955 |
interface cards can act as a bridge.</para> |
| 956 |
|
| 957 |
<para>The bridge works by learning the MAC layer addresses |
| 958 |
(Ethernet addresses) of the devices on each of its network interfaces. |
| 959 |
It forwards traffic between two networks only when its source and |
| 960 |
destination are on different networks.</para> |
| 961 |
|
| 962 |
<para>In many respects, a bridge is like an Ethernet switch with very |
| 963 |
few ports.</para> |
| 964 |
</sect2> |
| 965 |
|
| 966 |
<sect2> |
| 967 |
<title>Situations Where Bridging Is Appropriate</title> |
| 968 |
|
| 969 |
<para>There are two common situations in which a bridge is used |
| 970 |
today.</para> |
| 971 |
|
| 972 |
<sect3> |
| 973 |
<title>High Traffic on a Segment</title> |
| 974 |
|
| 975 |
<para>Situation one is where your physical network segment is |
| 976 |
overloaded with traffic, but you do not want for whatever reason to |
| 977 |
subnet the network and interconnect the subnets with a |
| 978 |
router.</para> |
| 979 |
|
| 980 |
<para>Let us consider an example of a newspaper where the Editorial and |
| 981 |
Production departments are on the same subnetwork. The Editorial |
| 982 |
users all use server A for file service, and the Production users |
| 983 |
are on server B. An Ethernet is used to connect all users together, |
| 984 |
and high loads on the network are slowing things down.</para> |
| 985 |
|
| 986 |
<para>If the Editorial users could be segregated on one |
| 987 |
network segment and the Production users on another, the two |
| 988 |
network segments could be connected with a bridge. Only the |
| 989 |
network traffic destined for interfaces on the |
| 990 |
<quote>other</quote> side of the bridge would be sent to the |
| 991 |
other network, reducing congestion on each network |
| 992 |
segment.</para> |
| 993 |
</sect3> |
| 994 |
|
| 995 |
<sect3> |
| 996 |
<title>Filtering/Traffic Shaping Firewall</title> |
| 997 |
<indexterm><primary>firewall</primary></indexterm> |
| 998 |
<indexterm><primary>IP Masquerading</primary></indexterm> |
| 999 |
|
| 1000 |
<para>The second common situation is where firewall functionality is |
| 1001 |
needed without IP Masquerading (NAT).</para> |
| 1002 |
|
| 1003 |
<para>An example is a small company that is connected via DSL |
| 1004 |
or ISDN to their ISP. They have a 13 globally-accessible IP |
| 1005 |
addresses from their ISP and have 10 PCs on their network. |
| 1006 |
In this situation, using a router-based firewall is |
| 1007 |
difficult because of subnetting issues.</para> |
| 1008 |
|
| 1009 |
<indexterm><primary>router</primary></indexterm> |
| 1010 |
<indexterm><primary>DSL</primary></indexterm> |
| 1011 |
<indexterm><primary>ISDN</primary></indexterm> |
| 1012 |
<para>A bridge-based firewall can be configured and dropped into the |
| 1013 |
path just downstream of their DSL/ISDN router without any IP |
| 1014 |
numbering issues.</para> |
| 1015 |
</sect3> |
| 1016 |
</sect2> |
| 1017 |
|
| 1018 |
<sect2> |
| 1019 |
<title>Configuring a Bridge</title> |
| 1020 |
|
| 1021 |
<sect3> |
| 1022 |
<title>Network Interface Card Selection</title> |
| 1023 |
|
| 1024 |
<para>A bridge requires at least two network cards to function. |
| 1025 |
Unfortunately, not all network interface cards as of FreeBSD 4.0 |
| 1026 |
support bridging. Read &man.bridge.4; for details on the cards that |
| 1027 |
are supported.</para> |
| 1028 |
|
| 1029 |
<para>Install and test the two network cards before continuing.</para> |
| 1030 |
</sect3> |
| 1031 |
|
| 1032 |
<sect3> |
| 1033 |
<title>Kernel Configuration Changes</title> |
| 1034 |
<indexterm> |
| 1035 |
<primary>kernel options</primary> |
| 1036 |
<secondary>options BRIDGE</secondary> |
| 1037 |
</indexterm> |
| 1038 |
|
| 1039 |
<para>To enable kernel support for bridging, add the:</para> |
| 1040 |
|
| 1041 |
<programlisting>options BRIDGE</programlisting> |
| 1042 |
|
| 1043 |
<para>statement to your kernel configuration file, and rebuild your |
| 1044 |
kernel.</para> |
| 1045 |
</sect3> |
| 1046 |
|
| 1047 |
<sect3> |
| 1048 |
<title>Firewall Support</title> |
| 1049 |
<indexterm><primary>firewall</primary></indexterm> |
| 1050 |
<para>If you are planning to use the bridge as a firewall, you |
| 1051 |
will need to add the <varname>IPFIREWALL</varname> option as |
| 1052 |
well. Read <xref linkend="firewalls"> for general |
| 1053 |
information on configuring the bridge as a firewall.</para> |
| 1054 |
|
| 1055 |
<para>If you need to allow non-IP packets (such as ARP) to flow |
| 1056 |
through the bridge, there is an undocumented firewall option that |
| 1057 |
must be set. This option is |
| 1058 |
<literal>IPFIREWALL_DEFAULT_TO_ACCEPT</literal>. Note that this |
| 1059 |
changes the default rule for the firewall to accept any packet. |
| 1060 |
Make sure you know how this changes the meaning of your ruleset |
| 1061 |
before you set it.</para> |
| 1062 |
</sect3> |
| 1063 |
|
| 1064 |
<sect3> |
| 1065 |
<title>Traffic Shaping Support</title> |
| 1066 |
|
| 1067 |
<para>If you want to use the bridge as a traffic shaper, you will need |
| 1068 |
to add the <literal>DUMMYNET</literal> option to your kernel |
| 1069 |
configuration. Read &man.dummynet.4; for further |
| 1070 |
information.</para> |
| 1071 |
</sect3> |
| 1072 |
</sect2> |
| 1073 |
|
| 1074 |
<sect2> |
| 1075 |
<title>Enabling the Bridge</title> |
| 1076 |
|
| 1077 |
<para>Add the line:</para> |
| 1078 |
|
| 1079 |
<programlisting>net.link.ether.bridge=1</programlisting> |
| 1080 |
|
| 1081 |
<para>to <filename>/etc/sysctl.conf</filename> to enable the bridge at |
| 1082 |
runtime, and the line:</para> |
| 1083 |
|
| 1084 |
<programlisting>net.link.ether.bridge_cfg=<replaceable>if1</replaceable>,<replaceable>if2</replaceable></programlisting> |
| 1085 |
|
| 1086 |
<para>to enable bridging on the specified interfaces (replace |
| 1087 |
<replaceable>if1</replaceable> and |
| 1088 |
<replaceable>if2</replaceable> with the names of your two |
| 1089 |
network interfaces). If you want the bridged packets to be |
| 1090 |
filtered by &man.ipfw.8;, you should add:</para> |
| 1091 |
|
| 1092 |
<programlisting>net.link.ether.bridge_ipfw=1</programlisting> |
| 1093 |
|
| 1094 |
<para>as well.</para> |
| 1095 |
</sect2> |
| 1096 |
|
| 1097 |
<sect2> |
| 1098 |
<title>Other Information</title> |
| 1099 |
|
| 1100 |
<para>If you want to be able to telnet into the bridge from the network, |
| 1101 |
it is OK to assign one of the network cards an IP address. The |
| 1102 |
consensus is that assigning both cards an address is a bad |
| 1103 |
idea.</para> |
| 1104 |
|
| 1105 |
<para>If you have multiple bridges on your network, there cannot be more |
| 1106 |
than one path between any two workstations. Technically, this means |
| 1107 |
that there is no support for spanning tree link management.</para> |
| 1108 |
|
| 1109 |
<para>A bridge can add latency to your ping times, especially for |
| 1110 |
traffic from one segment to another. |
| 1111 |
|
| 1112 |
</sect2> |
| 1113 |
</sect1> |
| 1114 |
|
| 1115 |
<sect1 id="network-nfs"> |
| 1116 |
<sect1info> |
| 1117 |
<authorgroup> |
| 1118 |
<author> |
| 1119 |
<firstname>Tom</firstname> |
| 1120 |
<surname>Rhodes</surname> |
| 1121 |
<contrib>Reorganized and enhanced by </contrib> |
| 1122 |
</author> |
| 1123 |
</authorgroup> |
| 1124 |
<authorgroup> |
| 1125 |
<author> |
| 1126 |
<firstname>Bill</firstname> |
| 1127 |
<surname>Swingle</surname> |
| 1128 |
<contrib>Written by </contrib> |
| 1129 |
</author> |
| 1130 |
</authorgroup> |
| 1131 |
</sect1info> |
| 1132 |
<title>NFS</title> |
| 1133 |
|
| 1134 |
<indexterm><primary>NFS</primary></indexterm> |
| 1135 |
<para>Among the many different filesystems that FreeBSD supports is |
| 1136 |
the Network File System, also known as <acronym>NFS</acronym>. |
| 1137 |
<acronym>NFS</acronym> allows a system to share directories and files |
| 1138 |
with others over a network. By using <acronym>NFS</acronym>, users and |
| 1139 |
programs can access files on remote systems almost as if they were local |
| 1140 |
files.</para> |
| 1141 |
|
| 1142 |
<para>Some of the most notable benefits that |
| 1143 |
<acronym>NFS</acronym> can provide are:</para> |
| 1144 |
|
| 1145 |
<itemizedlist> |
| 1146 |
<listitem> |
| 1147 |
<para>Local workstations use less disk space because |
| 1148 |
commonly used data can be stored on a single machine and still |
| 1149 |
remain accessible to others over the network.</para> |
| 1150 |
</listitem> |
| 1151 |
|
| 1152 |
<listitem> |
| 1153 |
<para>There is no need for users to have separate home directories |
| 1154 |
on every network machine. Home directories could be setup on the |
| 1155 |
<acronym>NFS</acronym> server and made available throughout |
| 1156 |
the network.</para> |
| 1157 |
</listitem> |
| 1158 |
|
| 1159 |
<listitem> |
| 1160 |
<para>Storage devices such as floppy disks, CDROM drives, and |
| 1161 |
ZIP drives can be used by other machines on the network. |
| 1162 |
This may reduce the number of removable media drives |
| 1163 |
throughout the network.</para> |
| 1164 |
</listitem> |
| 1165 |
</itemizedlist> |
| 1166 |
|
| 1167 |
<sect2> |
| 1168 |
<title>How <acronym>NFS</acronym> Works</title> |
| 1169 |
|
| 1170 |
<para><acronym>NFS</acronym> consists of at least two main parts: |
| 1171 |
a server and one or more clients. The client remotely accesses |
| 1172 |
the data that is stored |
| 1173 |
on the server machine. In order for this to function properly a few |
| 1174 |
processes have to be configured and running:</para> |
| 1175 |
|
| 1176 |
<note><para>In &os; 5.X, the <application>portmap</application> utility |
| 1177 |
has been replaced with the <command>rpcbind</command> utility. Thus, |
| 1178 |
in &os; 5.X the user is required to replace every instance of |
| 1179 |
<application>portmap</application> with <command>rpcbind</command> |
| 1180 |
in the forthcoming examples.</para></note> |
| 1181 |
|
| 1182 |
<para>The server has to be running the following daemons:</para> |
| 1183 |
<indexterm> |
| 1184 |
<primary>NFS</primary> |
| 1185 |
<secondary>server</secondary> |
| 1186 |
</indexterm> |
| 1187 |
<indexterm> |
| 1188 |
<primary><application>portmap</application></primary> |
| 1189 |
</indexterm> |
| 1190 |
<indexterm> |
| 1191 |
<primary><application>mountd</application></primary> |
| 1192 |
</indexterm> |
| 1193 |
<indexterm> |
| 1194 |
<primary><application>nfsd</application></primary> |
| 1195 |
</indexterm> |
| 1196 |
|
| 1197 |
<informaltable frame="none"> |
| 1198 |
<tgroup cols="2"> |
| 1199 |
<thead> |
| 1200 |
<row> |
| 1201 |
<entry>Daemon</entry> |
| 1202 |
<entry>Description</entry> |
| 1203 |
</row> |
| 1204 |
</thead> |
| 1205 |
<tbody> |
| 1206 |
<row> |
| 1207 |
<entry>nfsd</entry> |
| 1208 |
<entry>The <acronym>NFS</acronym> daemon which services requests from |
| 1209 |
the <acronym>NFS</acronym> clients.</entry> |
| 1210 |
</row> |
| 1211 |
<row> |
| 1212 |
<entry>mountd</entry> |
| 1213 |
<entry>The <acronym>NFS</acronym> mount daemon which carries out |
| 1214 |
the requests that &man.nfsd.8; passes on to it.</entry> |
| 1215 |
</row> |
| 1216 |
<row> |
| 1217 |
<entry>portmap</entry> |
| 1218 |
<entry> The portmapper daemon |
| 1219 |
allows <acronym>NFS</acronym> clients to discover which port the <acronym>NFS</acronym> server |
| 1220 |
is using.</entry> |
| 1221 |
</row> |
| 1222 |
</tbody> |
| 1223 |
</tgroup> |
| 1224 |
</informaltable> |
| 1225 |
|
| 1226 |
<para>The client can also run a daemon, known as |
| 1227 |
<application>nfsiod</application>. The |
| 1228 |
<application>nfsiod</application> daemon services the requests |
| 1229 |
from the <acronym>NFS</acronym> server. This is optional, and |
| 1230 |
improves performance, but is not required for normal and |
| 1231 |
correct operation. See the &man.nfsiod.8; manual page for |
| 1232 |
more information. |
| 1233 |
</para> |
| 1234 |
</sect2> |
| 1235 |
|
| 1236 |
<sect2 id="network-configuring-nfs"> |
| 1237 |
<title>Configuring <acronym>NFS</acronym></title> |
| 1238 |
<indexterm> |
| 1239 |
<primary>NFS</primary> |
| 1240 |
<secondary>configuration</secondary> |
| 1241 |
</indexterm> |
| 1242 |
|
| 1243 |
<para><acronym>NFS</acronym> configuration is a relatively |
| 1244 |
straightforward process. The processes that need to be |
| 1245 |
running can all start at boot time with a few modifications to |
| 1246 |
your <filename>/etc/rc.conf</filename> file.</para> |
| 1247 |
|
| 1248 |
<para>On the <acronym>NFS</acronym> server, make sure that the |
| 1249 |
following options are configured in the |
| 1250 |
<filename>/etc/rc.conf</filename> file:</para> |
| 1251 |
|
| 1252 |
<programlisting>portmap_enable="YES" |
| 1253 |
nfs_server_enable="YES" |
| 1254 |
mountd_flags="-r"</programlisting> |
| 1255 |
|
| 1256 |
<para><command>mountd</command> runs automatically whenever the |
| 1257 |
<acronym>NFS</acronym> server is enabled.</para> |
| 1258 |
|
| 1259 |
<para>On the client, make sure this option is present in |
| 1260 |
<filename>/etc/rc.conf</filename>:</para> |
| 1261 |
|
| 1262 |
<programlisting>nfs_client_enable="YES"</programlisting> |
| 1263 |
|
| 1264 |
<para>The <filename>/etc/exports</filename> file specifies which |
| 1265 |
filesystems <acronym>NFS</acronym> should export (sometimes |
| 1266 |
referred to as <quote>share</quote>). Each line in |
| 1267 |
<filename>/etc/exports</filename> specifies a filesystem to be |
| 1268 |
exported and which machines have access to that filesystem. |
| 1269 |
Along with what machines have access to that filesystem, |
| 1270 |
access options may also be specified. There are many such |
| 1271 |
options that can be used in this file but only a few will be |
| 1272 |
mentioned here. You can easily discover other options by |
| 1273 |
reading over the &man.exports.5; manual page.</para> |
| 1274 |
|
| 1275 |
<para>Here are a few example <filename>/etc/exports</filename> |
| 1276 |
entries:</para> |
| 1277 |
|
| 1278 |
<indexterm> |
| 1279 |
<primary>NFS</primary> |
| 1280 |
<secondary>export examples</secondary> |
| 1281 |
</indexterm> |
| 1282 |
|
| 1283 |
<para>The following examples give an idea of how to export filesystems, |
| 1284 |
although the settings may be different depending on |
| 1285 |
your environment and network configuration. |
| 1286 |
For instance, to export the <filename>/cdrom</filename> directory to |
| 1287 |
three example machines that have the same domain name as the server |
| 1288 |
(hence the lack of a domain name for each) or have entries in your |
| 1289 |
<filename>/etc/hosts</filename> file. The <option>-ro</option> |
| 1290 |
flag makes the exported filesystem read-only. With this flag, the |
| 1291 |
remote system will not be able to write any changes to the |
| 1292 |
exported filesystem.</para> |
| 1293 |
|
| 1294 |
<programlisting>/cdrom -ro host1 host2 host3</programlisting> |
| 1295 |
|
| 1296 |
<para>The following line exports <filename>/home</filename> to |
| 1297 |
three hosts by IP address. This is a useful setup if you have |
| 1298 |
a private network without a <acronym>DNS</acronym> server |
| 1299 |
configured. Optionally the <filename>/etc/hosts</filename> |
| 1300 |
file could be configured for internal hostnames; please review |
| 1301 |
&man.hosts.5; for more information. The |
| 1302 |
<option>-alldirs</option> flag allows the subdirectories to be |
| 1303 |
mount points. In other words, it will not mount the |
| 1304 |
subdirectories but permit the client to mount only the |
| 1305 |
directories that are required or needed.</para> |
| 1306 |
|
| 1307 |
<programlisting>/home -alldirs 10.0.0.2 10.0.0.3 10.0.0.4</programlisting> |
| 1308 |
|
| 1309 |
<para>The following line exports <filename>/a</filename> so that |
| 1310 |
two clients from different domains may access the filesystem. |
| 1311 |
The <option>-maproot=root</option> flag allows the |
| 1312 |
<username>root</username> user on the remote system to write |
| 1313 |
data on the exported filesystem as <username>root</username>. |
| 1314 |
If the <literal>-maproot=root</literal> flag is not specified, |
| 1315 |
then even if a user has <username>root</username> access on |
| 1316 |
the remote system, they will not be able to modify files on |
| 1317 |
the exported filesystem.</para> |
| 1318 |
|
| 1319 |
<programlisting>/a -maproot=root host.example.com box.example.org</programlisting> |
| 1320 |
|
| 1321 |
<para>In order for a client to access an exported filesystem, |
| 1322 |
the client must have permission to do so. Make sure the |
| 1323 |
client is listed in your <filename>/etc/exports</filename> |
| 1324 |
file.</para> |
| 1325 |
|
| 1326 |
<para>In <filename>/etc/exports</filename>, each line represents |
| 1327 |
the export information for one filesystem to one host. A |
| 1328 |
remote host can only be specified once per filesystem, and may |
| 1329 |
only have one default entry. For example, assume that |
| 1330 |
<filename>/usr</filename> is a single filesystem. The |
| 1331 |
following <filename>/etc/exports</filename> would be |
| 1332 |
invalid:</para> |
| 1333 |
|
| 1334 |
<programlisting>/usr/src client |
| 1335 |
/usr/ports client</programlisting> |
| 1336 |
|
| 1337 |
<para>One filesystem, <filename>/usr</filename>, has two lines |
| 1338 |
specifying exports to the same host, <hostid>client</hostid>. |
| 1339 |
The correct format for this situation is:</para> |
| 1340 |
|
| 1341 |
<programlisting>/usr/src /usr/ports client</programlisting> |
| 1342 |
|
| 1343 |
<para>The properties of one filesystem exported to a given host |
| 1344 |
must all occur on one line. Lines without a client specified |
| 1345 |
are treated as a single host. This limits how you can export |
| 1346 |
filesystems, but for most people this is not an issue.</para> |
| 1347 |
|
| 1348 |
<para>The following is an example of a valid export list, where |
| 1349 |
<filename>/usr</filename> and <filename>/exports</filename> |
| 1350 |
are local filesystems:</para> |
| 1351 |
|
| 1352 |
<programlisting># Export src and ports to client01 and client02, but only |
| 1353 |
# client01 has root privileges on it |
| 1354 |
/usr/src /usr/ports -maproot=root client01 |
| 1355 |
/usr/src /usr/ports client02 |
| 1356 |
# The client machines have root and can mount anywhere |
| 1357 |
# on /exports. Anyone in the world can mount /exports/obj read-only |
| 1358 |
/exports -alldirs -maproot=root client01 client02 |
| 1359 |
/exports/obj -ro</programlisting> |
| 1360 |
|
| 1361 |
<para>You must restart |
| 1362 |
<command>mountd</command> whenever you modify |
| 1363 |
<filename>/etc/exports</filename> so the changes can take effect. |
| 1364 |
This can be accomplished by sending the HUP signal |
| 1365 |
to the <command>mountd</command> process:</para> |
| 1366 |
|
| 1367 |
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/mountd.pid`</userinput></screen> |
| 1368 |
|
| 1369 |
<para>Alternatively, a reboot will make FreeBSD set everything |
| 1370 |
up properly. A reboot is not necessary though. |
| 1371 |
Executing the following commands as <username>root</username> |
| 1372 |
should start everything up.</para> |
| 1373 |
|
| 1374 |
<para>On the <acronym>NFS</acronym> server:</para> |
| 1375 |
|
| 1376 |
<screen>&prompt.root; <userinput>portmap</userinput> |
| 1377 |
&prompt.root; <userinput>nfsd -u -t -n 4</userinput> |
| 1378 |
&prompt.root; <userinput>mountd -r</userinput></screen> |
| 1379 |
|
| 1380 |
<para>On the <acronym>NFS</acronym> client:</para> |
| 1381 |
|
| 1382 |
<screen>&prompt.root; <userinput>nfsiod -n 4</userinput></screen> |
| 1383 |
|
| 1384 |
<para>Now everything should be ready to actually mount a remote file |
| 1385 |
system. In these examples the |
| 1386 |
server's name will be <literal>server</literal> and the client's |
| 1387 |
name will be <literal>client</literal>. If you only want to |
| 1388 |
temporarily mount a remote filesystem or would rather test the |
| 1389 |
configuration, just execute a command like this as <username>root</username> on the |
| 1390 |
client:</para> |
| 1391 |
<indexterm> |
| 1392 |
<primary>NFS</primary> |
| 1393 |
<secondary>mounting</secondary> |
| 1394 |
</indexterm> |
| 1395 |
<screen>&prompt.root; <userinput>mount server:/home /mnt</userinput></screen> |
| 1396 |
|
| 1397 |
<para>This will mount the <filename>/home</filename> directory |
| 1398 |
on the server at <filename>/mnt</filename> on the client. If |
| 1399 |
everything is set up correctly you should be able to enter |
| 1400 |
<filename>/mnt</filename> on the client and see all the files |
| 1401 |
that are on the server.</para> |
| 1402 |
|
| 1403 |
<para>If you want to automatically mount a remote filesystem |
| 1404 |
each time the computer boots, add the filesystem to the |
| 1405 |
<filename>/etc/fstab</filename> file. Here is an example:</para> |
| 1406 |
|
| 1407 |
<programlisting>server:/home /mnt nfs rw 0 0</programlisting> |
| 1408 |
|
| 1409 |
<para>The &man.fstab.5; manual page lists all the available options.</para> |
| 1410 |
</sect2> |
| 1411 |
|
| 1412 |
<sect2> |
| 1413 |
<title>Practical Uses</title> |
| 1414 |
|
| 1415 |
<para><acronym>NFS</acronym> has many practical uses. Some of the more common |
| 1416 |
ones are listed below:</para> |
| 1417 |
|
| 1418 |
<indexterm> |
| 1419 |
<primary>NFS</primary> |
| 1420 |
<secondary>uses</secondary> |
| 1421 |
</indexterm> |
| 1422 |
<itemizedlist> |
| 1423 |
<listitem> |
| 1424 |
<para>Set several machines to share a CDROM or other media |
| 1425 |
among them. This is cheaper and often a more convenient |
| 1426 |
method to install software on multiple machines.</para> |
| 1427 |
</listitem> |
| 1428 |
|
| 1429 |
<listitem> |
| 1430 |
<para>On large networks, it might be more convenient to |
| 1431 |
configure a central <acronym>NFS</acronym> server in which |
| 1432 |
to store all the user home directories. These home |
| 1433 |
directories can then be exported to the network so that |
| 1434 |
users would always have the same home directory, |
| 1435 |
regardless of which workstation they log in to.</para> |
| 1436 |
</listitem> |
| 1437 |
|
| 1438 |
<listitem> |
| 1439 |
<para>Several machines could have a common |
| 1440 |
<filename>/usr/ports/distfiles</filename> directory. That |
| 1441 |
way, when you need to install a port on several machines, |
| 1442 |
you can quickly access the source without downloading it |
| 1443 |
on each machine.</para> |
| 1444 |
</listitem> |
| 1445 |
</itemizedlist> |
| 1446 |
</sect2> |
| 1447 |
|
| 1448 |
<sect2 id="network-amd"> |
| 1449 |
<sect2info> |
| 1450 |
<authorgroup> |
| 1451 |
<author> |
| 1452 |
<firstname>Wylie</firstname> |
| 1453 |
<surname>Stilwell</surname> |
| 1454 |
<contrib>Contributed by </contrib> |
| 1455 |
</author> |
| 1456 |
</authorgroup> |
| 1457 |
<authorgroup> |
| 1458 |
<author> |
| 1459 |
<firstname>Chern</firstname> |
| 1460 |
<surname>Lee</surname> |
| 1461 |
<contrib>Rewritten by </contrib> |
| 1462 |
</author> |
| 1463 |
</authorgroup> |
| 1464 |
</sect2info> |
| 1465 |
<title>Automatic Mounts with <application>amd</application></title> |
| 1466 |
|
| 1467 |
<indexterm><primary>amd</primary></indexterm> |
| 1468 |
<indexterm><primary>automatic mounter daemon</primary></indexterm> |
| 1469 |
|
| 1470 |
<para>&man.amd.8; (the automatic mounter daemon) |
| 1471 |
automatically mounts a |
| 1472 |
remote filesystem whenever a file or directory within that |
| 1473 |
filesystem is accessed. Filesystems that are inactive for a |
| 1474 |
period of time will also be automatically unmounted by |
| 1475 |
<application>amd</application>. Using |
| 1476 |
<application>amd</application> provides a simple alternative |
| 1477 |
to permanent mounts, as permanent mounts are usually listed in |
| 1478 |
<filename>/etc/fstab</filename>.</para> |
| 1479 |
|
| 1480 |
<para><application>amd</application> operates by attaching |
| 1481 |
itself as an NFS server to the <filename>/host</filename> and |
| 1482 |
<filename>/net</filename> directories. When a file is accessed |
| 1483 |
within one of these directories, <application>amd</application> |
| 1484 |
looks up the corresponding remote mount and automatically mounts |
| 1485 |
it. <filename>/net</filename> is used to mount an exported |
| 1486 |
filesystem from an IP address, while <filename>/host</filename> |
| 1487 |
is used to mount an export from a remote hostname.</para> |
| 1488 |
|
| 1489 |
<para>An access to a file within |
| 1490 |
<filename>/host/foobar/usr</filename> would tell |
| 1491 |
<application>amd</application> to attempt to mount the |
| 1492 |
<filename>/usr</filename> export on the host |
| 1493 |
<hostid>foobar</hostid>.</para> |
| 1494 |
|
| 1495 |
<example> |
| 1496 |
<title>Mounting an Export with <application>amd</application></title> |
| 1497 |
|
| 1498 |
<para>You can view the available mounts of a remote host with |
| 1499 |
the <command>showmount</command> command. For example, to |
| 1500 |
view the mounts of a host named <hostid>foobar</hostid>, you |
| 1501 |
can use:</para> |
| 1502 |
|
| 1503 |
<screen>&prompt.user; <userinput>showmount -e foobar</userinput> |
| 1504 |
Exports list on foobar: |
| 1505 |
/usr 10.10.10.0 |
| 1506 |
/a 10.10.10.0 |
| 1507 |
&prompt.user; <userinput>cd /host/foobar/usr</userinput></screen> |
| 1508 |
</example> |
| 1509 |
|
| 1510 |
<para>As seen in the example, the <command>showmount</command> shows |
| 1511 |
<filename>/usr</filename> as an export. When changing directories to |
| 1512 |
<filename>/host/foobar/usr</filename>, <application>amd</application> |
| 1513 |
attempts to resolve the hostname <hostid>foobar</hostid> and |
| 1514 |
automatically mount the desired export.</para> |
| 1515 |
|
| 1516 |
<para><application>amd</application> can be started by the |
| 1517 |
startup scripts by placing the following lines in |
| 1518 |
<filename>/etc/rc.conf</filename>:</para> |
| 1519 |
|
| 1520 |
<programlisting>amd_enable="YES"</programlisting> |
| 1521 |
|
| 1522 |
<para>Additionally, custom flags can be passed to |
| 1523 |
<application>amd</application> from the |
| 1524 |
<varname>amd_flags</varname> option. By default, |
| 1525 |
<varname>amd_flags</varname> is set to:</para> |
| 1526 |
|
| 1527 |
<programlisting>amd_flags="-a /.amd_mnt -l syslog /host /etc/amd.map /net /etc/amd.map"</programlisting> |
| 1528 |
|
| 1529 |
<para>The <filename>/etc/amd.map</filename> file defines the |
| 1530 |
default options that exports are mounted with. The |
| 1531 |
<filename>/etc/amd.conf</filename> file defines some of the more |
| 1532 |
advanced features of <application>amd</application>.</para> |
| 1533 |
|
| 1534 |
<para>Consult the &man.amd.8; and &man.amd.conf.5; manual pages for more |
| 1535 |
information.</para> |
| 1536 |
</sect2> |
| 1537 |
|
| 1538 |
<sect2 id="network-nfs-integration"> |
| 1539 |
<sect2info> |
| 1540 |
<authorgroup> |
| 1541 |
<author> |
| 1542 |
<firstname>John</firstname> |
| 1543 |
<surname>Lind</surname> |
| 1544 |
<contrib>Contributed by </contrib> |
| 1545 |
</author> |
| 1546 |
</authorgroup> |
| 1547 |
</sect2info> |
| 1548 |
<title>Problems Integrating with Other Systems</title> |
| 1549 |
|
| 1550 |
<para>Certain Ethernet adapters for ISA PC systems have limitations |
| 1551 |
which can lead to serious network problems, particularly with NFS. |
| 1552 |
This difficulty is not specific to FreeBSD, but FreeBSD systems |
| 1553 |
are affected by it.</para> |
| 1554 |
|
| 1555 |
<para>The problem nearly always occurs when (FreeBSD) PC systems are |
| 1556 |
networked with high-performance workstations, such as those made |
| 1557 |
by Silicon Graphics, Inc., and Sun Microsystems, Inc. The NFS |
| 1558 |
mount will work fine, and some operations may succeed, but |
| 1559 |
suddenly the server will seem to become unresponsive to the |
| 1560 |
client, even though requests to and from other systems continue to |
| 1561 |
be processed. This happens to the client system, whether the |
| 1562 |
client is the FreeBSD system or the workstation. On many systems, |
| 1563 |
there is no way to shut down the client gracefully once this |
| 1564 |
problem has manifested itself. The only solution is often to |
| 1565 |
reset the client, because the NFS situation cannot be |
| 1566 |
resolved.</para> |
| 1567 |
|
| 1568 |
<para>Though the <quote>correct</quote> solution is to get a higher |
| 1569 |
performance and capacity Ethernet adapter for the FreeBSD system, |
| 1570 |
there is a simple workaround that will allow satisfactory |
| 1571 |
operation. If the FreeBSD system is the |
| 1572 |
<emphasis>server</emphasis>, include the option |
| 1573 |
<option>-w=1024</option> on the mount from the client. If the |
| 1574 |
FreeBSD system is the <emphasis>client</emphasis>, then mount the |
| 1575 |
NFS filesystem with the option <option>-r=1024</option>. These |
| 1576 |
options may be specified using the fourth field of the |
| 1577 |
<filename>fstab</filename> entry on the client for automatic |
| 1578 |
mounts, or by using the <option>-o</option> parameter of the mount |
| 1579 |
command for manual mounts.</para> |
| 1580 |
|
| 1581 |
<para>It should be noted that there is a different problem, |
| 1582 |
sometimes mistaken for this one, when the NFS servers and clients |
| 1583 |
are on different networks. If that is the case, make |
| 1584 |
<emphasis>certain</emphasis> that your routers are routing the |
| 1585 |
necessary UDP information, or you will not get anywhere, no matter |
| 1586 |
what else you are doing.</para> |
| 1587 |
|
| 1588 |
<para>In the following examples, <hostid>fastws</hostid> is the host |
| 1589 |
(interface) name of a high-performance workstation, and |
| 1590 |
<hostid>freebox</hostid> is the host (interface) name of a FreeBSD |
| 1591 |
system with a lower-performance Ethernet adapter. Also, |
| 1592 |
<filename>/sharedfs</filename> will be the exported NFS |
| 1593 |
filesystem (see &man.exports.5;), and |
| 1594 |
<filename>/project</filename> will be the mount point on the |
| 1595 |
client for the exported filesystem. In all cases, note that |
| 1596 |
additional options, such as <option>hard</option> or |
| 1597 |
<option>soft</option> and <option>bg</option> may be desirable in |
| 1598 |
your application.</para> |
| 1599 |
|
| 1600 |
<para>Examples for the FreeBSD system (<hostid>freebox</hostid>) as |
| 1601 |
the client in <filename>/etc/fstab</filename> on freebox:</para> |
| 1602 |
|
| 1603 |
<programlisting>fastws:/sharedfs /project nfs rw,-r=1024 0 0</programlisting> |
| 1604 |
|
| 1605 |
<para>As a manual mount command on <hostid>freebox</hostid>:</para> |
| 1606 |
|
| 1607 |
<screen>&prompt.root; <userinput>mount -t nfs -o -r=1024 fastws:/sharedfs /project</userinput></screen> |
| 1608 |
|
| 1609 |
<para>Examples for the FreeBSD system as the server in |
| 1610 |
<filename>/etc/fstab</filename> on <hostid>fastws</hostid>:</para> |
| 1611 |
|
| 1612 |
<programlisting>freebox:/sharedfs /project nfs rw,-w=1024 0 0</programlisting> |
| 1613 |
|
| 1614 |
<para>As a manual mount command on <hostid>fastws</hostid>:</para> |
| 1615 |
|
| 1616 |
<screen>&prompt.root; <userinput>mount -t nfs -o -w=1024 freebox:/sharedfs /project</userinput></screen> |
| 1617 |
|
| 1618 |
<para>Nearly any 16-bit Ethernet adapter will allow operation |
| 1619 |
without the above restrictions on the read or write size.</para> |
| 1620 |
|
| 1621 |
<para>For anyone who cares, here is what happens when the failure |
| 1622 |
occurs, which also explains why it is unrecoverable. NFS |
| 1623 |
typically works with a <quote>block</quote> size of 8 k (though it |
| 1624 |
may do fragments of smaller sizes). Since the maximum Ethernet |
| 1625 |
packet is around 1500 bytes, the NFS <quote>block</quote> gets |
| 1626 |
split into multiple Ethernet packets, even though it is still a |
| 1627 |
single unit to the upper-level code, and must be received, |
| 1628 |
assembled, and <emphasis>acknowledged</emphasis> as a unit. The |
| 1629 |
high-performance workstations can pump out the packets which |
| 1630 |
comprise the NFS unit one right after the other, just as close |
| 1631 |
together as the standard allows. On the smaller, lower capacity |
| 1632 |
cards, the later packets overrun the earlier packets of the same |
| 1633 |
unit before they can be transferred to the host and the unit as a |
| 1634 |
whole cannot be reconstructed or acknowledged. As a result, the |
| 1635 |
workstation will time out and try again, but it will try again |
| 1636 |
with the entire 8 K unit, and the process will be repeated, ad |
| 1637 |
infinitum.</para> |
| 1638 |
|
| 1639 |
<para>By keeping the unit size below the Ethernet packet size |
| 1640 |
limitation, we ensure that any complete Ethernet packet received |
| 1641 |
can be acknowledged individually, avoiding the deadlock |
| 1642 |
situation.</para> |
| 1643 |
|
| 1644 |
<para>Overruns may still occur when a high-performance workstations |
| 1645 |
is slamming data out to a PC system, but with the better cards, |
| 1646 |
such overruns are not guaranteed on NFS <quote>units</quote>. When |
| 1647 |
an overrun occurs, the units affected will be retransmitted, and |
| 1648 |
there will be a fair chance that they will be received, assembled, |
| 1649 |
and acknowledged.</para> |
| 1650 |
</sect2> |
| 1651 |
</sect1> |
| 1652 |
|
| 1653 |
<sect1 id="network-diskless"> |
| 1654 |
<sect1info> |
| 1655 |
<authorgroup> |
| 1656 |
<author> |
| 1657 |
<firstname>Jean-François</firstname> |
| 1658 |
<surname>Dockès</surname> |
| 1659 |
<contrib>Updated by </contrib> |
| 1660 |
</author> |
| 1661 |
</authorgroup> |
| 1662 |
</sect1info> |
| 1663 |
<title>Diskless Operation</title> |
| 1664 |
|
| 1665 |
<indexterm><primary>diskless workstation</primary></indexterm> |
| 1666 |
<indexterm><primary>diskless operation</primary></indexterm> |
| 1667 |
|
| 1668 |
<para>A FreeBSD machine can boot over the network and operate without a |
| 1669 |
local disk, using filesystems mounted from an NFS server. No system |
| 1670 |
modification is necessary, beyond standard configuration files. |
| 1671 |
Such a system is easy to set up because all the necessary elements |
| 1672 |
are readily available:</para> |
| 1673 |
<itemizedlist> |
| 1674 |
<listitem> |
| 1675 |
<para>There are at least two possible methods to load the kernel over |
| 1676 |
the network:</para> |
| 1677 |
<itemizedlist> |
| 1678 |
<listitem> |
| 1679 |
<para><emphasis>PXE</emphasis>: Intel's Preboot Execution |
| 1680 |
Environment system is a form of smart boot ROM built into some |
| 1681 |
networking cards or motherboards. See &man.pxeboot.8; for more |
| 1682 |
details.</para> |
| 1683 |
</listitem> |
| 1684 |
<listitem> |
| 1685 |
<para><emphasis>The <application>etherboot</application> |
| 1686 |
port</emphasis> (<filename |
| 1687 |
role="package">net/etherboot</filename>) produces |
| 1688 |
ROM-able code to boot kernels over the network. The |
| 1689 |
code can be either burnt into a boot PROM on a network |
| 1690 |
card, or loaded from a local floppy (or hard) disk |
| 1691 |
drive, or from a running MS-DOS system. Many network |
| 1692 |
cards are supported.</para> |
| 1693 |
</listitem> |
| 1694 |
</itemizedlist> |
| 1695 |
</listitem> |
| 1696 |
|
| 1697 |
<listitem> |
| 1698 |
<para>A sample script |
| 1699 |
(<filename>/usr/share/examples/diskless/clone_root</filename>) eases |
| 1700 |
the creation and maintenance of the workstation's root filesystem |
| 1701 |
on the server. The script will probably require a little |
| 1702 |
customization but it will get you started very quickly.</para> |
| 1703 |
</listitem> |
| 1704 |
|
| 1705 |
<listitem> |
| 1706 |
<para>Standard system startup files exist in <filename>/etc</filename> |
| 1707 |
to detect and support a diskless system startup.</para> |
| 1708 |
</listitem> |
| 1709 |
|
| 1710 |
<listitem> |
| 1711 |
<para>Swapping, if needed, can be done either to an NFS file or to |
| 1712 |
a local disk.</para> |
| 1713 |
</listitem> |
| 1714 |
</itemizedlist> |
| 1715 |
|
| 1716 |
<para>There are many ways to set up diskless workstations. Many |
| 1717 |
elements are involved, and most can be customized to suit local |
| 1718 |
taste. The following will describe the setup of a complete system, |
| 1719 |
emphasizing simplicity and compatibility with the |
| 1720 |
standard FreeBSD startup scripts. The system described has the |
| 1721 |
following characteristics:</para> |
| 1722 |
|
| 1723 |
<itemizedlist> |
| 1724 |
<listitem> |
| 1725 |
<para>The diskless workstations use a shared |
| 1726 |
read-only <filename>root</filename> filesystem, and a shared |
| 1727 |
read-only <filename>/usr</filename>.</para> |
| 1728 |
<para>The <filename>root</filename> filesystem is a copy of a |
| 1729 |
standard FreeBSD root (typically the server's), with some |
| 1730 |
configuration files overridden by ones specific to diskless |
| 1731 |
operation or, possibly, to the workstation they belong to.</para> |
| 1732 |
<para>The parts of the <filename>root</filename> which have to be |
| 1733 |
writable are overlaid with &man.mfs.8; filesystems. Any changes |
| 1734 |
will be lost when the system reboots.</para> |
| 1735 |
</listitem> |
| 1736 |
<listitem> |
| 1737 |
<para>The kernel is loaded by <application>etherboot |
| 1738 |
</application>, using DHCP (or BOOTP) and TFTP.</para> |
| 1739 |
</listitem> |
| 1740 |
</itemizedlist> |
| 1741 |
|
| 1742 |
<caution><para>As described, this system is insecure. It should |
| 1743 |
live in a protected area of a network, and be untrusted by |
| 1744 |
other hosts.</para> |
| 1745 |
</caution> |
| 1746 |
|
| 1747 |
|
| 1748 |
<sect2> |
| 1749 |
<title>Setup Instructions</title> |
| 1750 |
|
| 1751 |
<sect3> |
| 1752 |
<title>Configuring DHCP/BOOTP</title> |
| 1753 |
<indexterm> |
| 1754 |
<primary>diskless operation</primary> |
| 1755 |
<secondary>booting</secondary> |
| 1756 |
</indexterm> |
| 1757 |
|
| 1758 |
<para>There are two protocols that are commonly used to boot a |
| 1759 |
workstation that retrieves its configuration over the network: BOOTP |
| 1760 |
and DHCP. They are used at several points in the workstation |
| 1761 |
bootstrap:</para> |
| 1762 |
<itemizedlist> |
| 1763 |
<listitem><para><application>etherboot</application> uses |
| 1764 |
DHCP (by default) or BOOTP (needs a configuration option) to |
| 1765 |
find the kernel. (PXE uses DHCP).</para> |
| 1766 |
</listitem> |
| 1767 |
<listitem><para>The kernel uses BOOTP to locate the NFS |
| 1768 |
root.</para> |
| 1769 |
</listitem> |
| 1770 |
</itemizedlist> |
| 1771 |
|
| 1772 |
<para>It is possible to configure a system to use only BOOTP. |
| 1773 |
The &man.bootpd.8; server program is included in the |
| 1774 |
base FreeBSD system.</para> |
| 1775 |
|
| 1776 |
<para>However, DHCP has a number of advantages over BOOTP (nicer |
| 1777 |
configuration files, possibility of using PXE, plus many others |
| 1778 |
not directly related to diskless operation), and we shall describe |
| 1779 |
both a pure BOOTP, and a BOOTP+DHCP configuration, with an |
| 1780 |
emphasis on the latter, which will use the ISC DHCP software |
| 1781 |
package.</para> |
| 1782 |
|
| 1783 |
<sect4> |
| 1784 |
<title>Configuration Using ISC DHCP</title> |
| 1785 |
<indexterm> |
| 1786 |
<primary>DHCP</primary> |
| 1787 |
<secondary>diskless operation</secondary> |
| 1788 |
</indexterm> |
| 1789 |
|
| 1790 |
<para>The <application>isc-dhcp</application> server can answer |
| 1791 |
both BOOTP and DHCP requests.</para> |
| 1792 |
|
| 1793 |
<para>As of release 4.4, <application>isc-dhcp |
| 1794 |
3.0</application> is not part of the base |
| 1795 |
system. You will first need to install the |
| 1796 |
<filename role="package">net/isc-dhcp3</filename> port or the |
| 1797 |
corresponding package. Please refer to <xref linkend="ports"> |
| 1798 |
for general information about ports and packages.</para> |
| 1799 |
|
| 1800 |
<para>Once <application>isc-dhcp</application> is installed, it |
| 1801 |
needs a configuration file to run, (normally named |
| 1802 |
<filename>/usr/local/etc/dhcpd.conf</filename>). Here follows |
| 1803 |
a commented example:</para> |
| 1804 |
|
| 1805 |
<programlisting> |
| 1806 |
default-lease-time 600; |
| 1807 |
max-lease-time 7200; |
| 1808 |
authoritative; |
| 1809 |
|
| 1810 |
option domain-name "example.com"; |
| 1811 |
option domain-name-servers 192.168.4.1; |
| 1812 |
option routers 192.168.4.1; |
| 1813 |
|
| 1814 |
subnet 192.168.4.0 netmask 255.255.255.0 { |
| 1815 |
use-host-decl-names on; <co id="co-dhcp-host-name"> |
| 1816 |
option subnet-mask 255.255.255.0; |
| 1817 |
option broadcast-address 192.168.4.255; |
| 1818 |
|
| 1819 |
host margaux { |
| 1820 |
hardware ethernet 01:23:45:67:89:ab; |
| 1821 |
fixed-address margaux.example.com; |
| 1822 |
next-server 192.168.4.4;<co id="co-dhcp-next-server"> |
| 1823 |
filename "/tftpboot/kernel.diskless";<co id="co-dhcp-filename"> |
| 1824 |
option root-path "192.168.4.4:/data/misc/diskless";<co id="co-dhcp-root-path"> |
| 1825 |
} |
| 1826 |
} |
| 1827 |
</programlisting> |
| 1828 |
|
| 1829 |
<calloutlist> |
| 1830 |
<callout arearefs="co-dhcp-host-name"><para>This option tells |
| 1831 |
<command>dhcpd</command> to send the value in the |
| 1832 |
<literal>host</literal> declarations as the hostname for the |
| 1833 |
diskless host. An alternate way would be to add an |
| 1834 |
<literal>option host-name |
| 1835 |
<replaceable>margaux</replaceable></literal> inside the |
| 1836 |
host declarations.</para> |
| 1837 |
</callout> |
| 1838 |
|
| 1839 |
<callout arearefs="co-dhcp-next-server"><para>The |
| 1840 |
<literal>next-server</literal> directive designates |
| 1841 |
the TFTP server (the default is to use the same host as the |
| 1842 |
DHCP server).</para> |
| 1843 |
</callout> |
| 1844 |
|
| 1845 |
<callout arearefs="co-dhcp-filename"><para>The |
| 1846 |
<literal>filename</literal> directive defines the file that |
| 1847 |
<application>etherboot</application> will load as a |
| 1848 |
kernel. |
| 1849 |
<note><para>PXE appears to prefer a relative file |
| 1850 |
name, and it loads <command>pxeboot</command>, not the |
| 1851 |
kernel (<literal>option filename |
| 1852 |
"pxeboot"</literal>).</para> |
| 1853 |
</note> |
| 1854 |
</para> |
| 1855 |
</callout> |
| 1856 |
|
| 1857 |
<callout arearefs="co-dhcp-root-path"><para>The |
| 1858 |
<literal>root-path</literal> option defines the path to |
| 1859 |
the root filesystem, in usual NFS notation.</para> |
| 1860 |
</callout> |
| 1861 |
</calloutlist> |
| 1862 |
|
| 1863 |
</sect4> |
| 1864 |
<sect4> |
| 1865 |
<title>Configuration Using BOOTP</title> |
| 1866 |
<indexterm> |
| 1867 |
<primary>BOOTP</primary> |
| 1868 |
<secondary>diskless operation</secondary> |
| 1869 |
</indexterm> |
| 1870 |
|
| 1871 |
<para>Here follows an equivalent <command>bootpd</command> |
| 1872 |
configuration. This would be found in |
| 1873 |
<filename>/etc/bootptab</filename>.</para> |
| 1874 |
|
| 1875 |
<para>Please note that <application>etherboot</application> |
| 1876 |
must be compiled with the non-default option |
| 1877 |
<literal>NO_DHCP_SUPPORT</literal> in order to use BOOTP, |
| 1878 |
and that PXE <emphasis>needs</emphasis> DHCP. The only |
| 1879 |
obvious advantage of <application>bootpd</application> is |
| 1880 |
that it exists in the base system.</para> |
| 1881 |
|
| 1882 |
<programlisting> |
| 1883 |
.def100:\ |
| 1884 |
:hn:ht=1:sa=192.168.4.4:vm=rfc1048:\ |
| 1885 |
:sm=255.255.255.0:\ |
| 1886 |
:ds=192.168.4.1:\ |
| 1887 |
:gw=192.168.4.1:\ |
| 1888 |
:hd="/tftpboot":\ |
| 1889 |
:bf="/kernel.diskless":\ |
| 1890 |
:rp="192.168.4.4:/data/misc/diskless": |
| 1891 |
|
| 1892 |
margaux:ha=0123456789ab:tc=.def100 |
| 1893 |
</programlisting> |
| 1894 |
</sect4> |
| 1895 |
</sect3> |
| 1896 |
|
| 1897 |
<sect3> |
| 1898 |
<title>Preparing a Boot Program with |
| 1899 |
<application>Etherboot</application></title> |
| 1900 |
|
| 1901 |
<indexterm> |
| 1902 |
<primary>Etherboot</primary> |
| 1903 |
</indexterm> |
| 1904 |
|
| 1905 |
<para><ulink url="http://etherboot.sourceforge.net">Etherboot's Web |
| 1906 |
site</ulink> contains |
| 1907 |
<ulink url="http://etherboot.sourceforge.net/doc/html/userman.html"> |
| 1908 |
extensive documentation</ulink> mainly intended for Linux |
| 1909 |
systems, but nonetheless containing useful information. The |
| 1910 |
following will just outline how you would use |
| 1911 |
<application>etherboot</application> on a FreeBSD |
| 1912 |
system.</para> |
| 1913 |
|
| 1914 |
<para>You must first install the <filename |
| 1915 |
role="package">net/etherboot</filename> package or port. |
| 1916 |
The <application>etherboot</application> port can normally |
| 1917 |
be found in <filename>/usr/ports/net/etherboot</filename>. |
| 1918 |
If the ports tree is installed on your system, just typing |
| 1919 |
<literal>make</literal> in this directory should take care |
| 1920 |
of everything. Else refer to <xref linkend="ports"> for |
| 1921 |
information about ports and packages.</para> |
| 1922 |
|
| 1923 |
<para>For our setup, we shall use a boot floppy. For other methods |
| 1924 |
(PROM, or dos program), please refer to the |
| 1925 |
<application>etherboot</application> documentation.</para> |
| 1926 |
|
| 1927 |
<para>To make a boot floppy, insert a floppy in the drive on the |
| 1928 |
machine where you installed <application>etherboot</application>, |
| 1929 |
then change your current directory to the <filename>src</filename> |
| 1930 |
directory in the <application>etherboot</application> tree and |
| 1931 |
type:</para> |
| 1932 |
|
| 1933 |
<screen> |
| 1934 |
&prompt.root; <userinput>gmake bin32/<replaceable>devicetype</replaceable>.fd0</userinput> |
| 1935 |
</screen> |
| 1936 |
|
| 1937 |
<para><replaceable>devicetype</replaceable> depends on the type of |
| 1938 |
the Ethernet card in the diskless workstation. Refer to the |
| 1939 |
<filename>NIC</filename> file in the same directory to determine the |
| 1940 |
right <replaceable>devicetype</replaceable>.</para> |
| 1941 |
|
| 1942 |
</sect3> |
| 1943 |
|
| 1944 |
|
| 1945 |
<sect3> |
| 1946 |
<title>Configuring the TFTP and NFS Servers</title> |
| 1947 |
|
| 1948 |
<indexterm> |
| 1949 |
<primary>TFTP</primary> |
| 1950 |
<secondary>diskless operation</secondary> |
| 1951 |
</indexterm> |
| 1952 |
<indexterm> |
| 1953 |
<primary>NFS</primary> |
| 1954 |
<secondary>diskless operation</secondary> |
| 1955 |
</indexterm> |
| 1956 |
|
| 1957 |
<para>You need to enable <command>tftpd</command> on the TFTP |
| 1958 |
server:</para> |
| 1959 |
<procedure> |
| 1960 |
<step> |
| 1961 |
<para>Create a directory from which <command>tftpd</command> |
| 1962 |
will serve the files, i.e.: <filename>/tftpboot</filename></para> |
| 1963 |
</step> |
| 1964 |
|
| 1965 |
<step> |
| 1966 |
<para>Add this line to your |
| 1967 |
<filename>/etc/inetd.conf</filename>:</para> |
| 1968 |
|
| 1969 |
<programlisting>tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpboot</programlisting> |
| 1970 |
|
| 1971 |
<note><para>It appears that at least some PXE versions want |
| 1972 |
the TCP version of TFTP. In this case, add a second line, |
| 1973 |
replacing <literal>dgram udp</literal> with <literal>stream |
| 1974 |
tcp</literal>.</para> |
| 1975 |
</note> |
| 1976 |
</step> |
| 1977 |
<step> |
| 1978 |
<para>Tell <command>inetd</command> to reread its configuration |
| 1979 |
file:</para> |
| 1980 |
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/inetd.pid`</userinput></screen> |
| 1981 |
</step> |
| 1982 |
</procedure> |
| 1983 |
|
| 1984 |
<para>You can place the <filename>tftpboot</filename> |
| 1985 |
directory anywhere on the server. Make sure that the |
| 1986 |
location is set in both <filename>inetd.conf</filename> and |
| 1987 |
<filename>dhcpd.conf</filename>.</para> |
| 1988 |
|
| 1989 |
<para>You also need to enable NFS and export the |
| 1990 |
appropriate filesystem on the NFS server.</para> |
| 1991 |
|
| 1992 |
<procedure> |
| 1993 |
<step> |
| 1994 |
<para>Add this to <filename>/etc/rc.conf</filename>:</para> |
| 1995 |
<programlisting>nfs_server_enable="YES"</programlisting> |
| 1996 |
</step> |
| 1997 |
|
| 1998 |
<step> |
| 1999 |
<para>Export the filesystem where the diskless root directory |
| 2000 |
is located by adding the following to |
| 2001 |
<filename>/etc/exports</filename> (adjust the volume mount |
| 2002 |
point and replace <replaceable>margaux</replaceable> |
| 2003 |
with the name of the diskless workstation):</para> |
| 2004 |
|
| 2005 |
<programlisting><replaceable>/data/misc</replaceable> -alldirs -ro <replaceable>margaux</replaceable></programlisting> |
| 2006 |
</step> |
| 2007 |
<step> |
| 2008 |
<para>Tell <command>mountd</command> to reread its configuration |
| 2009 |
file. If you actually needed to enable NFS in |
| 2010 |
<filename>/etc/rc.conf</filename> |
| 2011 |
at the first step, you probably want to reboot instead.</para> |
| 2012 |
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/mountd.pid`</userinput></screen> |
| 2013 |
</step> |
| 2014 |
</procedure> |
| 2015 |
|
| 2016 |
</sect3> |
| 2017 |
|
| 2018 |
<sect3> |
| 2019 |
<title>Building a Diskless Kernel</title> |
| 2020 |
|
| 2021 |
<indexterm> |
| 2022 |
<primary>diskless operation</primary> |
| 2023 |
<secondary>kernel configuration</secondary> |
| 2024 |
</indexterm> |
| 2025 |
|
| 2026 |
<para>Create a kernel configuration file for the diskless client |
| 2027 |
with the following options (in addition to the usual |
| 2028 |
ones):</para> |
| 2029 |
|
| 2030 |
<programlisting> |
| 2031 |
options BOOTP # Use BOOTP to obtain IP address/hostname |
| 2032 |
options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info |
| 2033 |
options BOOTP_COMPAT # Workaround for broken bootp daemons. |
| 2034 |
</programlisting> |
| 2035 |
|
| 2036 |
<para>You may also want to use <literal>BOOTP_NFSV3</literal> and |
| 2037 |
<literal>BOOTP_WIRED_TO</literal> (refer to <filename>LINT</filename>).</para> |
| 2038 |
|
| 2039 |
<para>Build the kernel (See <xref linkend="kernelconfig">), |
| 2040 |
and copy it to the tftp directory, under the name listed |
| 2041 |
in <filename>dhcpd.conf</filename>.</para> |
| 2042 |
|
| 2043 |
|
| 2044 |
</sect3> |
| 2045 |
|
| 2046 |
<sect3> |
| 2047 |
<title>Preparing the Root Filesystem</title> |
| 2048 |
|
| 2049 |
<indexterm> |
| 2050 |
<primary>root file system</primary> |
| 2051 |
<secondary>diskless operation</secondary> |
| 2052 |
</indexterm> |
| 2053 |
|
| 2054 |
<para>You need to create a root filesystem for the diskless |
| 2055 |
workstations, in the location listed as |
| 2056 |
<literal>root-path</literal> in |
| 2057 |
<filename>dhcpd.conf</filename>.</para> |
| 2058 |
|
| 2059 |
<para>The easiest way to do this is to use the |
| 2060 |
<filename>/usr/share/examples/diskless/clone_root</filename> |
| 2061 |
shell script. This script needs customization, at least to adjust |
| 2062 |
the place where the filesystem will be created (the |
| 2063 |
<literal>DEST</literal> variable). |
| 2064 |
|
| 2065 |
<para>Refer to the comments at the top of the script for |
| 2066 |
instructions. They explain how the base filesystem is built, |
| 2067 |
and how files may be selectively overridden by versions specific |
| 2068 |
to diskless operation, to a subnetwork, or to an individual |
| 2069 |
workstation. They also give examples for the diskless |
| 2070 |
<filename>/etc/fstab</filename> and <filename> |
| 2071 |
/etc/rc.conf</filename> files.</para> |
| 2072 |
|
| 2073 |
<para>The <filename>README</filename> files in |
| 2074 |
<filename>/usr/share/examples/diskless</filename> contain a lot |
| 2075 |
of interesting background information, but, together with the |
| 2076 |
other examples in the <filename>diskless</filename> directory, |
| 2077 |
they actually document a configuration method which is distinct |
| 2078 |
from the one used by <filename>clone_root</filename> and |
| 2079 |
<filename>/etc/rc.diskless[12]</filename>, which is a little |
| 2080 |
confusing. Use them for reference only, except if you prefer |
| 2081 |
the method that they describe, in which case you will need |
| 2082 |
customized <filename>rc</filename> scripts.</para> |
| 2083 |
</sect3> |
| 2084 |
|
| 2085 |
<sect3> |
| 2086 |
<title>Configuring Swap</title> |
| 2087 |
|
| 2088 |
<para>If needed, a swap file located on the server can be |
| 2089 |
accessed via NFS. The exact <filename>bootptab</filename> |
| 2090 |
or <filename>dhcpd.conf</filename> options are not clearly |
| 2091 |
documented at this time. The following configuration |
| 2092 |
suggestions have been reported to work in some installations |
| 2093 |
using isc-dhcp 3.0rc11.</para> |
| 2094 |
<procedure> |
| 2095 |
<step><para>Add the following lines to |
| 2096 |
<filename>dhcpd.conf</filename>:</para> |
| 2097 |
<programlisting> |
| 2098 |
# Global section |
| 2099 |
option swap-path code 128 = string; |
| 2100 |
option swap-size code 129 = integer 32; |
| 2101 |
|
| 2102 |
host margaux { |
| 2103 |
... # Standard lines, see above |
| 2104 |
option swap-path <replaceable>"192.168.4.4:/netswapvolume/netswap"</replaceable>; |
| 2105 |
option swap-size <replaceable>64000</replaceable>; |
| 2106 |
} |
| 2107 |
</programlisting> |
| 2108 |
<para>The idea is that, at least for a FreeBSD client, |
| 2109 |
DHCP/BOOTP option code 128 is the path to the NFS swap file, |
| 2110 |
and option code 129 is the swap size in kilobytes. Older |
| 2111 |
versions of <command>dhcpd</command> allowed a syntax of |
| 2112 |
<literal>option option-128 "...</literal>, which does not |
| 2113 |
seem to work any more.</para> |
| 2114 |
<para><filename>/etc/bootptab</filename> would use the |
| 2115 |
following syntax instead:</para> |
| 2116 |
|
| 2117 |
<para><literal>T128="192.168.4.4:/netswapvolume/netswap":T129=64000 |
| 2118 |
</literal></para> |
| 2119 |
</step> |
| 2120 |
|
| 2121 |
<step> |
| 2122 |
<para>On the NFS swap file server, create the swap |
| 2123 |
file(s)</para> |
| 2124 |
<screen> |
| 2125 |
&prompt.root; <userinput>mkdir <replaceable>/netswapvolume/netswap</replaceable></userinput> |
| 2126 |
&prompt.root; <userinput>cd <replaceable>/netswapvolume/netswap</replaceable></userinput> |
| 2127 |
&prompt.root; <userinput>dd if=/dev/zero bs=1024 count=<replaceable>64000</replaceable> of=swap.<replaceable>192.168.4.6</replaceable></userinput> |
| 2128 |
&prompt.root; <userinput>chmod 0600 swap.<replaceable>192.168.4.6</replaceable></userinput> |
| 2129 |
</screen> |
| 2130 |
<para><replaceable>192.168.4.6</replaceable> is the IP address |
| 2131 |
for the diskless client.</para> |
| 2132 |
</step> |
| 2133 |
|
| 2134 |
<step> |
| 2135 |
<para>On the NFS swap file server, add the following line to |
| 2136 |
<filename>/etc/exports</filename>:</para> |
| 2137 |
<programlisting> |
| 2138 |
<replaceable>/netswapvolume</replaceable> -maproot=0:10 -alldirs <replaceable>margaux</replaceable> |
| 2139 |
</programlisting> |
| 2140 |
<para>Then tell <application>mountd</application> to reread the |
| 2141 |
exports file, as above.</para> |
| 2142 |
</step> |
| 2143 |
</procedure> |
| 2144 |
|
| 2145 |
</sect3> |
| 2146 |
|
| 2147 |
<sect3> |
| 2148 |
<title>Miscellaneous Issues</title> |
| 2149 |
|
| 2150 |
|
| 2151 |
<sect4> |
| 2152 |
<title>Running with a Read-only <filename>/usr</filename></title> |
| 2153 |
|
| 2154 |
<indexterm> |
| 2155 |
<primary>diskless operation</primary> |
| 2156 |
<secondary>/usr read-only</secondary> |
| 2157 |
</indexterm> |
| 2158 |
|
| 2159 |
<para>If the diskless workstation is configured to run X, you |
| 2160 |
will have to adjust the xdm configuration file, which puts |
| 2161 |
the error log on <filename>/usr</filename> by default.</para> |
| 2162 |
</sect4> |
| 2163 |
<sect4> |
| 2164 |
<title>Using a Non-FreeBSD Server</title> |
| 2165 |
|
| 2166 |
<para>When the server for the root filesystem is not running FreeBSD, |
| 2167 |
you will have to create the root filesystem on a |
| 2168 |
FreeBSD machine, then copy it to its destination, using |
| 2169 |
<command>tar</command> or <command>cpio</command>.</para> |
| 2170 |
<para>In this situation, there are sometimes |
| 2171 |
problems with the special files in <filename>/dev</filename>, |
| 2172 |
due to differing major/minor integer sizes. A solution to this |
| 2173 |
problem is to export a directory from the non-FreeBSD server, |
| 2174 |
mount this directory onto a FreeBSD machine, and run |
| 2175 |
<command>MAKEDEV</command> on the FreeBSD machine |
| 2176 |
to create the correct device entries (FreeBSD 5.0 and later |
| 2177 |
use &man.devfs.5; to allocate device nodes transparently for |
| 2178 |
the user, running <command>MAKEDEV</command> on these |
| 2179 |
versions is useless).</para> |
| 2180 |
|
| 2181 |
</sect4> |
| 2182 |
|
| 2183 |
</sect3> |
| 2184 |
|
| 2185 |
</sect2> |
| 2186 |
</sect1> |
| 2187 |
|
| 2188 |
<sect1 id="network-isdn"> |
| 2189 |
<title>ISDN</title> |
| 2190 |
|
| 2191 |
<indexterm> |
| 2192 |
<primary>ISDN</primary> |
| 2193 |
</indexterm> |
| 2194 |
|
| 2195 |
<para>A good resource for information on ISDN technology and hardware is |
| 2196 |
<ulink url="http://alumni.caltech.edu/~dank/isdn/">Dan Kegel's ISDN |
| 2197 |
Page</ulink>.</para> |
| 2198 |
|
| 2199 |
<para>A quick simple road map to ISDN follows:</para> |
| 2200 |
|
| 2201 |
<itemizedlist> |
| 2202 |
<listitem> |
| 2203 |
<para>If you live in Europe you might want to investigate the ISDN card |
| 2204 |
section.</para> |
| 2205 |
</listitem> |
| 2206 |
|
| 2207 |
<listitem> |
| 2208 |
<para>If you are planning to use ISDN primarily to connect to the |
| 2209 |
Internet with an Internet Provider on a dial-up non-dedicated basis, |
| 2210 |
you might look into Terminal Adapters. This will give you the |
| 2211 |
most flexibility, with the fewest problems, if you change |
| 2212 |
providers.</para> |
| 2213 |
</listitem> |
| 2214 |
|
| 2215 |
<listitem> |
| 2216 |
<para>If you are connecting two LANs together, or connecting to the |
| 2217 |
Internet with a dedicated ISDN connection, you might consider |
| 2218 |
the stand alone router/bridge option.</para> |
| 2219 |
</listitem> |
| 2220 |
</itemizedlist> |
| 2221 |
|
| 2222 |
<para>Cost is a significant factor in determining what solution you will |
| 2223 |
choose. The following options are listed from least expensive to most |
| 2224 |
expensive.</para> |
| 2225 |
|
| 2226 |
<sect2 id="network-isdn-cards"> |
| 2227 |
<sect2info> |
| 2228 |
<authorgroup> |
| 2229 |
<author> |
| 2230 |
<firstname>Hellmuth</firstname> |
| 2231 |
<surname>Michaelis</surname> |
| 2232 |
<contrib>Contributed by </contrib> |
| 2233 |
</author> |
| 2234 |
</authorgroup> |
| 2235 |
</sect2info> |
| 2236 |
<title>ISDN Cards</title> |
| 2237 |
|
| 2238 |
<indexterm> |
| 2239 |
<primary>ISDN</primary> |
| 2240 |
<secondary>cards</secondary> |
| 2241 |
</indexterm> |
| 2242 |
|
| 2243 |
<para>FreeBSD's ISDN implementation supports only the DSS1/Q.931 |
| 2244 |
(or Euro-ISDN) standard using passive cards. Starting with |
| 2245 |
FreeBSD 4.4, some active cards are supported where the firmware |
| 2246 |
also supports other signaling protocols; this also includes the |
| 2247 |
first supported Primary Rate (PRI) ISDN card.</para> |
| 2248 |
|
| 2249 |
<para><application>Isdn4bsd</application> allows you to connect |
| 2250 |
to other ISDN routers using either IP over raw HDLC or by using |
| 2251 |
synchronous PPP: either by using kernel PPP with isppp, a |
| 2252 |
modified sppp driver, or by using userland &man.ppp.8;. By using |
| 2253 |
userland &man.ppp.8;, channel bonding of two or more ISDN |
| 2254 |
B-channels is possible. A telephone answering machine |
| 2255 |
application is also available as well as many utilities such as |
| 2256 |
a software 300 Baud modem.</para> |
| 2257 |
|
| 2258 |
<para>Some growing number of PC ISDN cards are supported under |
| 2259 |
FreeBSD and the reports show that it is successfully used all |
| 2260 |
over Europe and in many other parts of the world.</para> |
| 2261 |
|
| 2262 |
<para>The passive ISDN cards supported are mostly the ones with |
| 2263 |
the Infineon (formerly Siemens) ISAC/HSCX/IPAC ISDN chipsets, |
| 2264 |
but also ISDN cards with chips from Cologne Chip (ISA bus only), |
| 2265 |
PCI cards with Winbond W6692 chips, some cards with the |
| 2266 |
Tiger300/320/ISAC chipset combinations and some vendor specific |
| 2267 |
chipset based cards such as the AVM Fritz!Card PCI V.1.0 and the |
| 2268 |
AVM Fritz!Card PnP.</para> |
| 2269 |
|
| 2270 |
<para>Currently the active supported ISDN cards are the AVM B1 |
| 2271 |
(ISA and PCI) BRI cards and the AVM T1 PCI PRI cards.</para> |
| 2272 |
|
| 2273 |
<para>For documentation on <application>isdn4bsd</application>, |
| 2274 |
have a look at <filename>/usr/share/examples/isdn/</filename> |
| 2275 |
directory on your FreeBSD system or at the <ulink |
| 2276 |
url="http://www.freebsd-support.de/i4b/">homepage of |
| 2277 |
isdn4bsd</ulink> which also has pointers to hints, erratas and |
| 2278 |
much more documentation such as the <ulink |
| 2279 |
url="http://people.FreeBSD.org/~hm/">isdn4bsd |
| 2280 |
handbook</ulink>.</para> |
| 2281 |
|
| 2282 |
<para>In case you are interested in adding support for a |
| 2283 |
different ISDN protocol, a currently unsupported ISDN PC card or |
| 2284 |
otherwise enhancing <application>isdn4bsd</application>, please |
| 2285 |
get in touch with &a.hm;.</para> |
| 2286 |
|
| 2287 |
<para>For questions regarding the installation, configuration |
| 2288 |
and troubleshooting <application>isdn4bsd</application>, a |
| 2289 |
&a.isdn.name; mailing list is available.</para> |
| 2290 |
</sect2> |
| 2291 |
|
| 2292 |
<sect2> |
| 2293 |
<title>ISDN Terminal Adapters</title> |
| 2294 |
|
| 2295 |
<para>Terminal adapters(TA), are to ISDN what modems are to regular |
| 2296 |
phone lines.</para> |
| 2297 |
<indexterm><primary>modem</primary></indexterm> |
| 2298 |
<para>Most TA's use the standard hayes modem AT command set, and can be |
| 2299 |
used as a drop in replacement for a modem.</para> |
| 2300 |
|
| 2301 |
<para>A TA will operate basically the same as a modem except connection |
| 2302 |
and throughput speeds will be much faster than your old modem. You |
| 2303 |
will need to configure <link linkend="ppp">PPP</link> exactly the same |
| 2304 |
as for a modem setup. Make sure you set your serial speed as high as |
| 2305 |
possible.</para> |
| 2306 |
<indexterm><primary>PPP</primary></indexterm> |
| 2307 |
<para>The main advantage of using a TA to connect to an Internet |
| 2308 |
Provider is that you can do Dynamic PPP. As IP address space becomes |
| 2309 |
more and more scarce, most providers are not willing to provide you |
| 2310 |
with a static IP anymore. Most stand-alone routers are not able to |
| 2311 |
accommodate dynamic IP allocation.</para> |
| 2312 |
|
| 2313 |
<para>TA's completely rely on the PPP daemon that you are running for |
| 2314 |
their features and stability of connection. This allows you to |
| 2315 |
upgrade easily from using a modem to ISDN on a FreeBSD machine, if you |
| 2316 |
already have PPP setup. However, at the same time any problems you |
| 2317 |
experienced with the PPP program and are going to persist.</para> |
| 2318 |
|
| 2319 |
<para>If you want maximum stability, use the kernel <link |
| 2320 |
linkend="ppp">PPP</link> option, not the user-land <link |
| 2321 |
linkend="userppp">iijPPP</link>.</para> |
| 2322 |
|
| 2323 |
<para>The following TA's are known to work with FreeBSD.</para> |
| 2324 |
|
| 2325 |
<itemizedlist> |
| 2326 |
<listitem> |
| 2327 |
<para>Motorola BitSurfer and Bitsurfer Pro</para> |
| 2328 |
</listitem> |
| 2329 |
|
| 2330 |
<listitem> |
| 2331 |
<para>Adtran</para> |
| 2332 |
</listitem> |
| 2333 |
</itemizedlist> |
| 2334 |
|
| 2335 |
<para>Most other TA's will probably work as well, TA vendors try to make |
| 2336 |
sure their product can accept most of the standard modem AT command |
| 2337 |
set.</para> |
| 2338 |
|
| 2339 |
<para>The real problem with external TA's is that, like modems, |
| 2340 |
you need a good serial card in your computer.</para> |
| 2341 |
|
| 2342 |
<para>You should read the <ulink |
| 2343 |
url="../../articles/serial-uart/index.html">FreeBSD Serial |
| 2344 |
Hardware</ulink> tutorial for a detailed understanding of |
| 2345 |
serial devices, and the differences between asynchronous and |
| 2346 |
synchronous serial ports.</para> |
| 2347 |
|
| 2348 |
<para>A TA running off a standard PC serial port (asynchronous) limits |
| 2349 |
you to 115.2 Kbs, even though you have a 128 Kbs connection. |
| 2350 |
To fully utilize the 128 Kbs that ISDN is capable of, |
| 2351 |
you must move the TA to a synchronous serial card.</para> |
| 2352 |
|
| 2353 |
<para>Do not be fooled into buying an internal TA and thinking you have |
| 2354 |
avoided the synchronous/asynchronous issue. Internal TA's simply have |
| 2355 |
a standard PC serial port chip built into them. All this will do is |
| 2356 |
save you having to buy another serial cable and find another empty |
| 2357 |
electrical socket.</para> |
| 2358 |
|
| 2359 |
<para>A synchronous card with a TA is at least as fast as a stand-alone |
| 2360 |
router, and with a simple 386 FreeBSD box driving it, probably more |
| 2361 |
flexible.</para> |
| 2362 |
|
| 2363 |
<para>The choice of sync/TA v.s. stand-alone router is largely a |
| 2364 |
religious issue. There has been some discussion of this in |
| 2365 |
the mailing lists. I suggest you search the <ulink |
| 2366 |
url="../../../../search/index.html">archives</ulink> for |
| 2367 |
the complete discussion.</para> |
| 2368 |
</sect2> |
| 2369 |
|
| 2370 |
<sect2> |
| 2371 |
<title>Stand-alone ISDN Bridges/Routers</title> |
| 2372 |
<indexterm> |
| 2373 |
<primary>ISDN</primary> |
| 2374 |
<secondary>stand-alone bridges/routers</secondary> |
| 2375 |
</indexterm> |
| 2376 |
<para>ISDN bridges or routers are not at all specific to FreeBSD |
| 2377 |
or any other operating system. For a more complete |
| 2378 |
description of routing and bridging technology, please refer |
| 2379 |
to a Networking reference book.</para> |
| 2380 |
|
| 2381 |
<para>In the context of this page, the terms router and bridge will |
| 2382 |
be used interchangeably.</para> |
| 2383 |
|
| 2384 |
<para>As the cost of low end ISDN routers/bridges comes down, it |
| 2385 |
will likely become a more and more popular choice. An ISDN |
| 2386 |
router is a small box that plugs directly into your local |
| 2387 |
Ethernet network, and manages its own connection to the other |
| 2388 |
bridge/router. It has built in software to communicate via |
| 2389 |
PPP and other popular protocols.</para> |
| 2390 |
|
| 2391 |
<para>A router will allow you much faster throughput than a |
| 2392 |
standard TA, since it will be using a full synchronous ISDN |
| 2393 |
connection.</para> |
| 2394 |
|
| 2395 |
<para>The main problem with ISDN routers and bridges is that |
| 2396 |
interoperability between manufacturers can still be a problem. |
| 2397 |
If you are planning to connect to an Internet provider, you |
| 2398 |
should discuss your needs with them.</para> |
| 2399 |
|
| 2400 |
<para>If you are planning to connect two LAN segments together, |
| 2401 |
such as your home LAN to the office LAN, this is the simplest |
| 2402 |
lowest |
| 2403 |
maintenance solution. Since you are buying the equipment for |
| 2404 |
both sides of the connection you can be assured that the link |
| 2405 |
will work.</para> |
| 2406 |
|
| 2407 |
<para>For example to connect a home computer or branch office |
| 2408 |
network to a head office network the following setup could be |
| 2409 |
used.</para> |
| 2410 |
|
| 2411 |
<example> |
| 2412 |
<title>Branch Office or Home Network</title> |
| 2413 |
|
| 2414 |
<indexterm><primary>10 base 2</primary></indexterm> |
| 2415 |
<para>Network uses a bus based topology with 10 base 2 |
| 2416 |
Ethernet (<quote>thinnet</quote>). Connect router to network cable with |
| 2417 |
AUI/10BT transceiver, if necessary.</para> |
| 2418 |
|
| 2419 |
<mediaobject> |
| 2420 |
<imageobject> |
| 2421 |
<imagedata fileref="advanced-networking/isdn-bus"> |
| 2422 |
</imageobject> |
| 2423 |
|
| 2424 |
<textobject> |
| 2425 |
<literallayout class="monospaced">---Sun workstation |
| 2426 |
| |
| 2427 |
---FreeBSD box |
| 2428 |
| |
| 2429 |
---Windows 95 (Do not admit to owning it) |
| 2430 |
| |
| 2431 |
Stand-alone router |
| 2432 |
| |
| 2433 |
ISDN BRI line</literallayout> |
| 2434 |
</textobject> |
| 2435 |
|
| 2436 |
<textobject> |
| 2437 |
<phrase>10 Base 2 Ethernet</phrase> |
| 2438 |
</textobject> |
| 2439 |
</mediaobject> |
| 2440 |
|
| 2441 |
<para>If your home/branch office is only one computer you can use a |
| 2442 |
twisted pair crossover cable to connect to the stand-alone router |
| 2443 |
directly.</para> |
| 2444 |
</example> |
| 2445 |
|
| 2446 |
<example> |
| 2447 |
<title>Head Office or Other LAN</title> |
| 2448 |
|
| 2449 |
<indexterm><primary>10 base T</primary></indexterm> |
| 2450 |
<para>Network uses a star topology with 10 base T Ethernet |
| 2451 |
(<quote>Twisted Pair</quote>).</para> |
| 2452 |
|
| 2453 |
<mediaobject> |
| 2454 |
<imageobject> |
| 2455 |
<imagedata fileref="advanced-networking/isdn-twisted-pair"> |
| 2456 |
</imageobject> |
| 2457 |
|
| 2458 |
<textobject> |
| 2459 |
<literallayout class="monospaced"> -------Novell Server |
| 2460 |
| H | |
| 2461 |
| ---Sun |
| 2462 |
| | |
| 2463 |
| U ---FreeBSD |
| 2464 |
| | |
| 2465 |
| ---Windows 95 |
| 2466 |
| B | |
| 2467 |
|___---Stand-alone router |
| 2468 |
| |
| 2469 |
ISDN BRI line</literallayout> |
| 2470 |
</textobject> |
| 2471 |
|
| 2472 |
<textobject> |
| 2473 |
<phrase>ISDN Network Diagram</phrase> |
| 2474 |
</textobject> |
| 2475 |
</mediaobject> |
| 2476 |
</example> |
| 2477 |
|
| 2478 |
<para>One large advantage of most routers/bridges is that they allow you |
| 2479 |
to have 2 <emphasis>separate independent</emphasis> PPP connections to |
| 2480 |
2 separate sites at the <emphasis>same</emphasis> time. This is not |
| 2481 |
supported on most TA's, except for specific (usually expensive) models |
| 2482 |
that |
| 2483 |
have two serial ports. Do not confuse this with channel bonding, MPP, |
| 2484 |
etc.</para> |
| 2485 |
|
| 2486 |
<para>This can be a very useful feature if, for example, you |
| 2487 |
have an dedicated ISDN connection at your office and would |
| 2488 |
like to tap into it, but do not want to get another ISDN line |
| 2489 |
at work. A router at the office location can manage a |
| 2490 |
dedicated B channel connection (64 Kbps) to the Internet |
| 2491 |
and use the other B channel for a separate data connection. |
| 2492 |
The second B channel can be used for dial-in, dial-out or |
| 2493 |
dynamically bonding (MPP, etc.) with the first B channel for |
| 2494 |
more bandwidth.</para> |
| 2495 |
|
| 2496 |
<indexterm><primary>IPX/SPX</primary></indexterm> |
| 2497 |
<para>An Ethernet bridge will also allow you to transmit more than just |
| 2498 |
IP traffic. You can also send IPX/SPX or whatever other protocols you |
| 2499 |
use.</para> |
| 2500 |
</sect2> |
| 2501 |
</sect1> |
| 2502 |
|
| 2503 |
<sect1 id="network-nis"> |
| 2504 |
<sect1info> |
| 2505 |
<authorgroup> |
| 2506 |
<author> |
| 2507 |
<firstname>Bill</firstname> |
| 2508 |
<surname>Swingle</surname> |
| 2509 |
<contrib>Written by </contrib> |
| 2510 |
</author> |
| 2511 |
</authorgroup> |
| 2512 |
<authorgroup> |
| 2513 |
<author> |
| 2514 |
<firstname>Eric</firstname> |
| 2515 |
<surname>Ogren</surname> |
| 2516 |
<contrib>Enhanced by </contrib> |
| 2517 |
</author> |
| 2518 |
<author> |
| 2519 |
<firstname>Udo</firstname> |
| 2520 |
<surname>Erdelhoff</surname> |
| 2521 |
</author> |
| 2522 |
</authorgroup> |
| 2523 |
</sect1info> |
| 2524 |
<title>NIS/YP</title> |
| 2525 |
|
| 2526 |
<sect2> |
| 2527 |
<title>What Is It?</title> |
| 2528 |
<indexterm><primary>NIS</primary></indexterm> |
| 2529 |
<indexterm><primary>Solaris</primary></indexterm> |
| 2530 |
<indexterm><primary>HP-UX</primary></indexterm> |
| 2531 |
<indexterm><primary>AIX</primary></indexterm> |
| 2532 |
<indexterm><primary>Linux</primary></indexterm> |
| 2533 |
<indexterm><primary>NetBSD</primary></indexterm> |
| 2534 |
<indexterm><primary>OpenBSD</primary></indexterm> |
| 2535 |
<para>NIS, which stands for Network Information Services, was |
| 2536 |
developed by Sun Microsystems to centralize administration of Unix |
| 2537 |
(originally SunOS) systems. It has now essentially become an |
| 2538 |
industry standard; all major Unix systems (Solaris, HP-UX, AIX, Linux, |
| 2539 |
NetBSD, OpenBSD, FreeBSD, etc) support NIS.</para> |
| 2540 |
|
| 2541 |
<indexterm><primary>yellow pages</primary><see>NIS</see></indexterm> |
| 2542 |
<para>NIS was formerly known as Yellow Pages, but because of |
| 2543 |
trademark issues, Sun changed the name. The old term (and yp) is |
| 2544 |
still often seen and used.</para> |
| 2545 |
|
| 2546 |
<indexterm> |
| 2547 |
<primary>NIS</primary> |
| 2548 |
<secondary>domains</secondary> |
| 2549 |
</indexterm> |
| 2550 |
<para>It is a RPC-based client/server system that allows a group |
| 2551 |
of machines within an NIS domain to share a common set of |
| 2552 |
configuration files. This permits a system administrator to set |
| 2553 |
up NIS client systems with only minimal configuration data and |
| 2554 |
add, remove or modify configuration data from a single |
| 2555 |
location.</para> |
| 2556 |
|
| 2557 |
<indexterm><primary>Windows NT</primary></indexterm> |
| 2558 |
<para>It is similar to Windows NT's domain system; although the |
| 2559 |
internal implementation of the two are not at all similar, |
| 2560 |
the basic functionality can be compared.</para> |
| 2561 |
</sect2> |
| 2562 |
|
| 2563 |
<sect2> |
| 2564 |
<title>Terms/Processes You Should Know</title> |
| 2565 |
|
| 2566 |
<para>There are several terms and several important user processes |
| 2567 |
that you will come across when |
| 2568 |
attempting to implement NIS on FreeBSD, whether you are trying to |
| 2569 |
create an NIS server or act as an NIS client:</para> |
| 2570 |
|
| 2571 |
<indexterm> |
| 2572 |
<primary><application>portmap</application></primary> |
| 2573 |
</indexterm> |
| 2574 |
|
| 2575 |
<informaltable> |
| 2576 |
<tgroup cols="2"> |
| 2577 |
<thead> |
| 2578 |
<row> |
| 2579 |
<entry>Term</entry> |
| 2580 |
<entry>Description</entry> |
| 2581 |
</row> |
| 2582 |
</thead> |
| 2583 |
<tbody> |
| 2584 |
<row> |
| 2585 |
<entry>NIS domainname</entry> |
| 2586 |
<entry>An NIS master server and all of its clients |
| 2587 |
(including its slave servers) have a NIS |
| 2588 |
domainname. Similar to an NT domain name, the NIS |
| 2589 |
domainname does not have anything to do with DNS.</entry> |
| 2590 |
</row> |
| 2591 |
<row> |
| 2592 |
<entry>portmap</entry> |
| 2593 |
<entry>Must be running in order to enable RPC (Remote |
| 2594 |
Procedure Call, a network protocol used by NIS). If |
| 2595 |
<command>portmap</command> is not running, it will be |
| 2596 |
impossible to run an NIS server, or to act as an NIS |
| 2597 |
client.</entry> |
| 2598 |
</row> |
| 2599 |
<row> |
| 2600 |
<entry>ypbind</entry> |
| 2601 |
|
| 2602 |
<entry><quote>Binds</quote> an NIS client to its NIS |
| 2603 |
server. It will take the NIS domainname from the |
| 2604 |
system, and using RPC, connect to the |
| 2605 |
server. <command>ypbind</command> is the core of |
| 2606 |
client-server communication in an NIS environment; if |
| 2607 |
<command>ypbind</command> dies on a client machine, it |
| 2608 |
will not be able to access the NIS server.</entry> |
| 2609 |
</row> |
| 2610 |
<row> |
| 2611 |
<entry>ypserv</entry> |
| 2612 |
<entry>Should only be running on NIS servers; this is the NIS |
| 2613 |
server process itself. If &man.ypserv.8; dies, then the |
| 2614 |
server will no longer be able to respond to NIS requests |
| 2615 |
(hopefully, there is a slave server to take over for |
| 2616 |
it). There are some implementations of NIS (but not the |
| 2617 |
FreeBSD one), that do not try to reconnect to another |
| 2618 |
server if the server it used before dies. Often, the |
| 2619 |
only thing that helps in this case is to restart the |
| 2620 |
server process (or even the whole server) or the |
| 2621 |
<command>ypbind</command> process on the client. |
| 2622 |
</entry> |
| 2623 |
</row> |
| 2624 |
<row> |
| 2625 |
<entry>rpc.yppasswdd</entry> |
| 2626 |
<entry>Another process that should only be running on |
| 2627 |
NIS master servers; this is a daemon that will allow NIS |
| 2628 |
clients to change their NIS passwords. If this daemon |
| 2629 |
is not running, users will have to login to the NIS |
| 2630 |
master server and change their passwords there.</entry> |
| 2631 |
</row> |
| 2632 |
</tbody> |
| 2633 |
</tgroup> |
| 2634 |
</informaltable> |
| 2635 |
<!-- XXX Missing: rpc.ypxfrd (not important, though) May only run |
| 2636 |
on the master --> |
| 2637 |
|
| 2638 |
</sect2> |
| 2639 |
|
| 2640 |
<sect2> |
| 2641 |
<title>How Does It Work?</title> |
| 2642 |
|
| 2643 |
<para>There are three types of hosts in an NIS environment: master |
| 2644 |
servers, slave servers, and clients. Servers act as a central |
| 2645 |
repository for host configuration information. Master servers |
| 2646 |
hold the authoritative copy of this information, while slave |
| 2647 |
servers mirror this information for redundancy. Clients rely on |
| 2648 |
the servers to provide this information to them.</para> |
| 2649 |
|
| 2650 |
<para>Information in many files can be shared in this manner. The |
| 2651 |
<filename>master.passwd</filename>, <filename>group</filename>, |
| 2652 |
and <filename>hosts</filename> files are commonly shared via NIS. |
| 2653 |
Whenever a process on a client needs information that would |
| 2654 |
normally be found in these files locally, it makes a query to the |
| 2655 |
NIS server that it is bound to instead.</para> |
| 2656 |
|
| 2657 |
<sect3> |
| 2658 |
<title>Machine Types</title> |
| 2659 |
|
| 2660 |
<itemizedlist> |
| 2661 |
<indexterm> |
| 2662 |
<primary>NIS</primary> |
| 2663 |
<secondary>master server</secondary> |
| 2664 |
</indexterm> |
| 2665 |
<listitem> |
| 2666 |
<para>A <emphasis>NIS master server</emphasis>. |
| 2667 |
This server, analogous to a Windows |
| 2668 |
NT primary domain controller, maintains the files used by all |
| 2669 |
of the NIS clients. The <filename>passwd</filename>, |
| 2670 |
<filename>group</filename>, and other various files used by the |
| 2671 |
NIS clients live on the master server.</para> |
| 2672 |
|
| 2673 |
<note><para>It is possible for one machine to be an NIS |
| 2674 |
master server for more than one NIS domain. However, this will |
| 2675 |
not be covered in this introduction, which assumes a relatively |
| 2676 |
small-scale NIS environment.</para></note> |
| 2677 |
</listitem> |
| 2678 |
<indexterm> |
| 2679 |
<primary>NIS</primary> |
| 2680 |
<secondary>slave server</secondary> |
| 2681 |
</indexterm> |
| 2682 |
<listitem> |
| 2683 |
<para><emphasis>NIS slave servers</emphasis>. |
| 2684 |
Similar to NT's backup domain |
| 2685 |
controllers, NIS slave servers maintain copies of the NIS |
| 2686 |
master's data files. NIS slave servers provide the redundancy, |
| 2687 |
which is needed in important environments. They also help |
| 2688 |
to balance the load of the master server: NIS Clients always |
| 2689 |
attach to the NIS server whose response they get first, and |
| 2690 |
this includes slave-server-replies.</para> |
| 2691 |
</listitem> |
| 2692 |
<indexterm> |
| 2693 |
<primary>NIS</primary> |
| 2694 |
<secondary>client</secondary> |
| 2695 |
</indexterm> |
| 2696 |
<listitem> |
| 2697 |
<para><emphasis>NIS clients</emphasis>. NIS clients, like most |
| 2698 |
NT workstations, authenticate against the NIS server (or the NT |
| 2699 |
domain controller in the NT Workstation case) to log on.</para> |
| 2700 |
</listitem> |
| 2701 |
</itemizedlist> |
| 2702 |
</sect3> |
| 2703 |
</sect2> |
| 2704 |
|
| 2705 |
<sect2> |
| 2706 |
<title>Using NIS/YP</title> |
| 2707 |
|
| 2708 |
<para>This section will deal with setting up a sample NIS |
| 2709 |
environment.</para> |
| 2710 |
|
| 2711 |
<note><para>This section assumes that you are running FreeBSD 3.3 |
| 2712 |
or later. The instructions given here will |
| 2713 |
<emphasis>probably</emphasis> work for any version of FreeBSD greater |
| 2714 |
than 3.0, but there are no guarantees that this is |
| 2715 |
true.</para></note> |
| 2716 |
|
| 2717 |
|
| 2718 |
<sect3> |
| 2719 |
<title>Planning</title> |
| 2720 |
|
| 2721 |
<para>Let us assume that you are the administrator of a small |
| 2722 |
university lab. This lab, which consists of 15 FreeBSD machines, |
| 2723 |
currently has no centralized point of administration; each machine |
| 2724 |
has its own <filename>/etc/passwd</filename> and |
| 2725 |
<filename>/etc/master.passwd</filename>. These files are kept in |
| 2726 |
sync with each other only through manual intervention; |
| 2727 |
currently, when you add a user to the lab, you must run |
| 2728 |
<command>adduser</command> on all 15 machines. |
| 2729 |
Clearly, this has to change, so you have decided to convert the |
| 2730 |
lab to use NIS, using two of the machines as servers.</para> |
| 2731 |
|
| 2732 |
<para>Therefore, the configuration of the lab now looks something |
| 2733 |
like:</para> |
| 2734 |
|
| 2735 |
<informaltable> |
| 2736 |
<tgroup cols="3"> |
| 2737 |
<thead> |
| 2738 |
<row> |
| 2739 |
<entry>Machine name</entry> |
| 2740 |
<entry>IP address</entry> |
| 2741 |
<entry>Machine role</entry> |
| 2742 |
</row> |
| 2743 |
</thead> |
| 2744 |
<tbody> |
| 2745 |
<row> |
| 2746 |
<entry><hostid>ellington</hostid></entry> |
| 2747 |
<entry><hostid role="ipaddr">10.0.0.2</hostid></entry> |
| 2748 |
<entry>NIS master</entry> |
| 2749 |
</row> |
| 2750 |
<row> |
| 2751 |
<entry><hostid>coltrane</hostid></entry> |
| 2752 |
<entry><hostid role="ipaddr">10.0.0.3</hostid></entry> |
| 2753 |
<entry>NIS slave</entry> |
| 2754 |
</row> |
| 2755 |
<row> |
| 2756 |
<entry><hostid>basie</hostid></entry> |
| 2757 |
<entry><hostid role="ipaddr">10.0.0.4</hostid></entry> |
| 2758 |
<entry>Faculty workstation</entry> |
| 2759 |
</row> |
| 2760 |
<row> |
| 2761 |
<entry><hostid>bird</hostid></entry> |
| 2762 |
<entry><hostid role="ipaddr">10.0.0.5</hostid></entry> |
| 2763 |
<entry>Client machine</entry> |
| 2764 |
</row> |
| 2765 |
<row> |
| 2766 |
<entry><hostid>cli[1-11]</hostid></entry> |
| 2767 |
<entry><hostid role="ipaddr">10.0.0.[6-17]</hostid></entry> |
| 2768 |
<entry>Other client machines</entry> |
| 2769 |
</row> |
| 2770 |
</tbody> |
| 2771 |
</tgroup> |
| 2772 |
</informaltable> |
| 2773 |
|
| 2774 |
<para>If you are setting up a NIS scheme for the first time, it |
| 2775 |
is a good idea to think through how you want to go about it. No |
| 2776 |
matter what the size of your network, there are a few decisions |
| 2777 |
that need to be made.</para> |
| 2778 |
|
| 2779 |
<sect4> |
| 2780 |
<title>Choosing a NIS Domain Name</title> |
| 2781 |
|
| 2782 |
<indexterm> |
| 2783 |
<primary>NIS</primary> |
| 2784 |
<secondary>domainname</secondary> |
| 2785 |
</indexterm> |
| 2786 |
<para>This might not be the <quote>domainname</quote> that you |
| 2787 |
are used to. It is more accurately called the |
| 2788 |
<quote>NIS domainname</quote>. When a client broadcasts its |
| 2789 |
requests for info, it includes the name of the NIS domain |
| 2790 |
that it is part of. This is how multiple servers on one |
| 2791 |
network can tell which server should answer which request. |
| 2792 |
Think of the NIS domainname as the name for a group of hosts |
| 2793 |
that are related in some way.</para> |
| 2794 |
|
| 2795 |
<para>Some organizations choose to use their Internet |
| 2796 |
domainname for their NIS domainname. This is not |
| 2797 |
recommended as it can cause confusion when trying to debug |
| 2798 |
network problems. The NIS domainname should be unique |
| 2799 |
within your network and it is helpful if it describes the |
| 2800 |
group of machines it represents. For example, the Art |
| 2801 |
department at Acme Inc. might be in the |
| 2802 |
<quote>acme-art</quote> NIS domain. For this example, |
| 2803 |
assume you have chosen the name |
| 2804 |
<emphasis>test-domain</emphasis>.</para> |
| 2805 |
|
| 2806 |
<indexterm><primary>SunOS</primary></indexterm> |
| 2807 |
<para>However, some operating systems (notably SunOS) use their |
| 2808 |
NIS domain name as their Internet domain name. |
| 2809 |
If one or more machines on your network have this restriction, |
| 2810 |
you <emphasis>must</emphasis> use the Internet domain name as |
| 2811 |
your NIS domain name.</para> |
| 2812 |
</sect4> |
| 2813 |
|
| 2814 |
<sect4> |
| 2815 |
<title>Physical Server Requirements</title> |
| 2816 |
|
| 2817 |
<para>There are several things to keep in mind when choosing a |
| 2818 |
machine to use as a NIS server. One of the unfortunate things |
| 2819 |
about NIS is the level of dependency the clients have on the |
| 2820 |
server. If a client cannot contact the server for its NIS |
| 2821 |
domain, very often the machine becomes unusable. The lack of |
| 2822 |
user and group information causes most systems to temporarily |
| 2823 |
freeze up. With this in mind you should make sure to choose a |
| 2824 |
machine that will not be prone to being rebooted regularly, or |
| 2825 |
one that might be used for development. The NIS server should |
| 2826 |
ideally be a stand alone machine whose sole purpose in life is |
| 2827 |
to be an NIS server. If you have a network that is not very |
| 2828 |
heavily used, it is acceptable to put the NIS server on a |
| 2829 |
machine running other services, just keep in mind that if the |
| 2830 |
NIS server becomes unavailable, it will affect |
| 2831 |
<emphasis>all</emphasis> of your NIS clients adversely.</para> |
| 2832 |
</sect4> |
| 2833 |
</sect3> |
| 2834 |
|
| 2835 |
<sect3> |
| 2836 |
<title>NIS Servers</title> |
| 2837 |
|
| 2838 |
<para> The canonical copies of all NIS information are stored on |
| 2839 |
a single machine called the NIS master server. The databases |
| 2840 |
used to store the information are called NIS maps. In FreeBSD, |
| 2841 |
these maps are stored in |
| 2842 |
<filename>/var/yp/[domainname]</filename> where |
| 2843 |
<filename>[domainname]</filename> is the name of the NIS domain |
| 2844 |
being served. A single NIS server can support several domains |
| 2845 |
at once, therefore it is possible to have several such |
| 2846 |
directories, one for each supported domain. Each domain will |
| 2847 |
have its own independent set of maps.</para> |
| 2848 |
|
| 2849 |
<para>NIS master and slave servers handle all NIS requests with |
| 2850 |
the <command>ypserv</command> daemon. <command>ypserv</command> |
| 2851 |
is responsible for receiving incoming requests from NIS clients, |
| 2852 |
translating the requested domain and map name to a path to the |
| 2853 |
corresponding database file and transmitting data from the |
| 2854 |
database back to the client.</para> |
| 2855 |
|
| 2856 |
<sect4> |
| 2857 |
<title>Setting Up a NIS Master Server</title> |
| 2858 |
<indexterm> |
| 2859 |
<primary>NIS</primary> |
| 2860 |
<secondary>server configuration</secondary> |
| 2861 |
</indexterm> |
| 2862 |
<para>Setting up a master NIS server can be relatively straight |
| 2863 |
forward, depending on your needs. FreeBSD comes with support |
| 2864 |
for NIS out-of-the-box. All you need is to add the following |
| 2865 |
lines to <filename>/etc/rc.conf</filename>, and FreeBSD will |
| 2866 |
do the rest for you.</para> |
| 2867 |
|
| 2868 |
<procedure> |
| 2869 |
<step> |
| 2870 |
<para><programlisting>nisdomainname="test-domain"</programlisting> |
| 2871 |
This line will set the NIS domainname to |
| 2872 |
<emphasis>test-domain</emphasis> |
| 2873 |
upon network setup (e.g. after reboot).</para> |
| 2874 |
</step> |
| 2875 |
<step> |
| 2876 |
<para><programlisting>nis_server_enable="YES"</programlisting> |
| 2877 |
This will tell FreeBSD to start up the NIS server processes |
| 2878 |
when the networking is next brought up.</para> |
| 2879 |
</step> |
| 2880 |
<step> |
| 2881 |
<para><programlisting>nis_yppasswdd_enable="YES"</programlisting> |
| 2882 |
This will enable the <command>rpc.yppasswdd</command> |
| 2883 |
daemon which, as mentioned above, will allow users to |
| 2884 |
change their NIS password from a client machine.</para> |
| 2885 |
</step> |
| 2886 |
</procedure> |
| 2887 |
|
| 2888 |
<note> |
| 2889 |
<para>Depending on your NIS setup, you may need to add |
| 2890 |
further entries. See the <link |
| 2891 |
linkend="network-nis-server-is-client">section about NIS servers |
| 2892 |
that are also NIS clients</link>, below, for |
| 2893 |
details.</para> |
| 2894 |
</note> |
| 2895 |
|
| 2896 |
<para>Now, all you have to do is to run the command |
| 2897 |
<command>/etc/netstart</command> as superuser. It will |
| 2898 |
set up everything for you, using the values you defined in |
| 2899 |
<filename>/etc/rc.conf</filename>.</para> |
| 2900 |
</sect4> |
| 2901 |
|
| 2902 |
<sect4> |
| 2903 |
<title>Initializing the NIS Maps</title> |
| 2904 |
<indexterm> |
| 2905 |
<primary>NIS</primary> |
| 2906 |
<secondary>maps</secondary> |
| 2907 |
</indexterm> |
| 2908 |
<para>The <emphasis>NIS maps</emphasis> are database files, |
| 2909 |
that are kept in the <filename>/var/yp</filename> directory. |
| 2910 |
They are generated from configuration files in the |
| 2911 |
<filename>/etc</filename> directory of the NIS master, with one |
| 2912 |
exception: the <filename>/etc/master.passwd</filename> file. |
| 2913 |
This is for a good reason; you do not want to propagate |
| 2914 |
passwords to your <username>root</username> and other |
| 2915 |
administrative accounts to all the servers in the NIS domain. |
| 2916 |
Therefore, before we initialize the NIS maps, you should:</para> |
| 2917 |
|
| 2918 |
<screen>&prompt.root; <userinput>cp /etc/master.passwd /var/yp/master.passwd</userinput> |
| 2919 |
&prompt.root; <userinput>cd /var/yp</userinput> |
| 2920 |
&prompt.root; <userinput>vi master.passwd</userinput></screen> |
| 2921 |
|
| 2922 |
<para>You should remove all entries regarding system accounts |
| 2923 |
(<username>bin</username>, <username>tty</username>, |
| 2924 |
<username>kmem</username>, <username>games</username>, etc), as |
| 2925 |
well as any accounts that you do not want to be propagated to the |
| 2926 |
NIS clients (for example <username>root</username> and any other |
| 2927 |
UID 0 (superuser) accounts).</para> |
| 2928 |
|
| 2929 |
<note><para>Make sure the |
| 2930 |
<filename>/var/yp/master.passwd</filename> is neither group |
| 2931 |
nor world readable (mode 600)! Use the |
| 2932 |
<command>chmod</command> command, if appropriate.</para></note> |
| 2933 |
|
| 2934 |
<indexterm><primary>Tru64 Unix</primary></indexterm> |
| 2935 |
<para>When you have finished, it is time to initialize the NIS |
| 2936 |
maps! FreeBSD includes a script named |
| 2937 |
<command>ypinit</command> to do this for you |
| 2938 |
(see its manual page for more information). Note that this |
| 2939 |
script is available on most Unix Operating Systems, but not on all. |
| 2940 |
On Digital Unix/Compaq Tru64 Unix it is called |
| 2941 |
<command>ypsetup</command>. |
| 2942 |
Because we are generating maps for an NIS master, we are |
| 2943 |
going to pass the <option>-m</option> option to |
| 2944 |
<command>ypinit</command>. |
| 2945 |
To generate the NIS maps, assuming you already performed |
| 2946 |
the steps above, run:</para> |
| 2947 |
|
| 2948 |
<screen>ellington&prompt.root; <userinput>ypinit -m test-domain</userinput> |
| 2949 |
Server Type: MASTER Domain: test-domain |
| 2950 |
Creating an YP server will require that you answer a few questions. |
| 2951 |
Questions will all be asked at the beginning of the procedure. |
| 2952 |
Do you want this procedure to quit on non-fatal errors? [y/n: n] <userinput>n</userinput> |
| 2953 |
Ok, please remember to go back and redo manually whatever fails. |
| 2954 |
If you don't, something might not work. |
| 2955 |
At this point, we have to construct a list of this domains YP servers. |
| 2956 |
rod.darktech.org is already known as master server. |
| 2957 |
Please continue to add any slave servers, one per line. When you are |
| 2958 |
done with the list, type a <control D>. |
| 2959 |
master server : ellington |
| 2960 |
next host to add: <userinput>coltrane</userinput> |
| 2961 |
next host to add: <userinput>^D</userinput> |
| 2962 |
The current list of NIS servers looks like this: |
| 2963 |
ellington |
| 2964 |
coltrane |
| 2965 |
Is this correct? [y/n: y] <userinput>y</userinput> |
| 2966 |
|
| 2967 |
[..output from map generation..] |
| 2968 |
|
| 2969 |
NIS Map update completed. |
| 2970 |
ellington has been setup as an YP master server without any errors.</screen> |
| 2971 |
|
| 2972 |
<para><command>ypinit</command> should have created |
| 2973 |
<filename>/var/yp/Makefile</filename> from |
| 2974 |
<filename>/var/yp/Makefile.dist</filename>. |
| 2975 |
When created, this file assumes that you are operating |
| 2976 |
in a single server NIS environment with only FreeBSD |
| 2977 |
machines. Since <emphasis>test-domain</emphasis> has |
| 2978 |
a slave server as well, you must edit |
| 2979 |
<filename>/var/yp/Makefile</filename>:</para> |
| 2980 |
|
| 2981 |
<screen>ellington&prompt.root; <userinput>vi /var/yp/Makefile</userinput></screen> |
| 2982 |
|
| 2983 |
<para>You should comment out the line that says</para> |
| 2984 |
|
| 2985 |
<programlisting>NOPUSH = "True"</programlisting> |
| 2986 |
|
| 2987 |
<para>(if it is not commented out already).</para> |
| 2988 |
</sect4> |
| 2989 |
|
| 2990 |
<sect4> |
| 2991 |
<title>Setting up a NIS Slave Server</title> |
| 2992 |
<indexterm> |
| 2993 |
<primary>NIS</primary> |
| 2994 |
<secondary>slave server</secondary> |
| 2995 |
</indexterm> |
| 2996 |
<para>Setting up an NIS slave server is even more simple than |
| 2997 |
setting up the master. Log on to the slave server and edit the |
| 2998 |
file <filename>/etc/rc.conf</filename> as you did before. |
| 2999 |
The only difference is that we now must use the |
| 3000 |
<option>-s</option> option when running <command>ypinit</command>. |
| 3001 |
The <option>-s</option> option requires the name of the NIS |
| 3002 |
master be passed to it as well, so our command line looks |
| 3003 |
like:</para> |
| 3004 |
|
| 3005 |
<screen>coltrane&prompt.root; <userinput>ypinit -s ellington test-domain</userinput> |
| 3006 |
|
| 3007 |
Server Type: SLAVE Domain: test-domain Master: ellington |
| 3008 |
|
| 3009 |
Creating an YP server will require that you answer a few questions. |
| 3010 |
Questions will all be asked at the beginning of the procedure. |
| 3011 |
|
| 3012 |
Do you want this procedure to quit on non-fatal errors? [y/n: n] <userinput>n</userinput> |
| 3013 |
|
| 3014 |
Ok, please remember to go back and redo manually whatever fails. |
| 3015 |
If you don't, something might not work. |
| 3016 |
There will be no further questions. The remainder of the procedure |
| 3017 |
should take a few minutes, to copy the databases from ellington. |
| 3018 |
Transferring netgroup... |
| 3019 |
ypxfr: Exiting: Map successfully transferred |
| 3020 |
Transferring netgroup.byuser... |
| 3021 |
ypxfr: Exiting: Map successfully transferred |
| 3022 |
Transferring netgroup.byhost... |
| 3023 |
ypxfr: Exiting: Map successfully transferred |
| 3024 |
Transferring master.passwd.byuid... |
| 3025 |
ypxfr: Exiting: Map successfully transferred |
| 3026 |
Transferring passwd.byuid... |
| 3027 |
ypxfr: Exiting: Map successfully transferred |
| 3028 |
Transferring passwd.byname... |
| 3029 |
ypxfr: Exiting: Map successfully transferred |
| 3030 |
Transferring group.bygid... |
| 3031 |
ypxfr: Exiting: Map successfully transferred |
| 3032 |
Transferring group.byname... |
| 3033 |
ypxfr: Exiting: Map successfully transferred |
| 3034 |
Transferring services.byname... |
| 3035 |
ypxfr: Exiting: Map successfully transferred |
| 3036 |
Transferring rpc.bynumber... |
| 3037 |
ypxfr: Exiting: Map successfully transferred |
| 3038 |
Transferring rpc.byname... |
| 3039 |
ypxfr: Exiting: Map successfully transferred |
| 3040 |
Transferring protocols.byname... |
| 3041 |
ypxfr: Exiting: Map successfully transferred |
| 3042 |
Transferring master.passwd.byname... |
| 3043 |
ypxfr: Exiting: Map successfully transferred |
| 3044 |
Transferring networks.byname... |
| 3045 |
ypxfr: Exiting: Map successfully transferred |
| 3046 |
Transferring networks.byaddr... |
| 3047 |
ypxfr: Exiting: Map successfully transferred |
| 3048 |
Transferring netid.byname... |
| 3049 |
ypxfr: Exiting: Map successfully transferred |
| 3050 |
Transferring hosts.byaddr... |
| 3051 |
ypxfr: Exiting: Map successfully transferred |
| 3052 |
Transferring protocols.bynumber... |
| 3053 |
ypxfr: Exiting: Map successfully transferred |
| 3054 |
Transferring ypservers... |
| 3055 |
ypxfr: Exiting: Map successfully transferred |
| 3056 |
Transferring hosts.byname... |
| 3057 |
ypxfr: Exiting: Map successfully transferred |
| 3058 |
|
| 3059 |
coltrane has been setup as an YP slave server without any errors. |
| 3060 |
Don't forget to update map ypservers on ellington.</screen> |
| 3061 |
|
| 3062 |
<para>You should now have a directory called |
| 3063 |
<filename>/var/yp/test-domain</filename>. Copies of the NIS |
| 3064 |
master server's maps should be in this directory. You will |
| 3065 |
need to make sure that these stay updated. The following |
| 3066 |
<filename>/etc/crontab</filename> entries on your slave |
| 3067 |
servers should do the job:</para> |
| 3068 |
|
| 3069 |
<programlisting>20 * * * * root /usr/libexec/ypxfr passwd.byname |
| 3070 |
21 * * * * root /usr/libexec/ypxfr passwd.byuid</programlisting> |
| 3071 |
|
| 3072 |
<para>These two lines force the slave to sync its maps with |
| 3073 |
the maps on the master server. Although these entries are |
| 3074 |
not mandatory, since the master server attempts to ensure |
| 3075 |
any changes to its NIS maps are communicated to its slaves |
| 3076 |
and because password information is vital to systems |
| 3077 |
depending on the server, it is a good idea to force the |
| 3078 |
updates. This is more important on busy networks where map |
| 3079 |
updates might not always complete.</para> |
| 3080 |
|
| 3081 |
<para>Now, run the command <command>/etc/netstart</command> on the |
| 3082 |
slave server as well, which again starts the NIS server.</para> |
| 3083 |
</sect4> |
| 3084 |
</sect3> |
| 3085 |
|
| 3086 |
<sect3> |
| 3087 |
<title>NIS Clients</title> |
| 3088 |
|
| 3089 |
<para> An NIS client establishes what is called a binding to a |
| 3090 |
particular NIS server using the |
| 3091 |
<command>ypbind</command> daemon. |
| 3092 |
<command>ypbind</command> checks the system's default |
| 3093 |
domain (as set by the <command>domainname</command> command), |
| 3094 |
and begins broadcasting RPC requests on the local network. |
| 3095 |
These requests specify the name of the domain for which |
| 3096 |
<command>ypbind</command> is attempting to establish a binding. |
| 3097 |
If a server that has been configured to serve the requested |
| 3098 |
domain receives one of the broadcasts, it will respond to |
| 3099 |
<command>ypbind</command>, which will record the server's |
| 3100 |
address. If there are several servers available (a master and |
| 3101 |
several slaves, for example), <command>ypbind</command> will |
| 3102 |
use the address of the first one to respond. From that point |
| 3103 |
on, the client system will direct all of its NIS requests to |
| 3104 |
that server. <command>ypbind</command> will |
| 3105 |
occasionally <quote>ping</quote> the server to make sure it is |
| 3106 |
still up and running. If it fails to receive a reply to one of |
| 3107 |
its pings within a reasonable amount of time, |
| 3108 |
<command>ypbind</command> will mark the domain as unbound and |
| 3109 |
begin broadcasting again in the hopes of locating another |
| 3110 |
server.</para> |
| 3111 |
|
| 3112 |
<sect4> |
| 3113 |
<title>Setting Up a NIS Client</title> |
| 3114 |
<indexterm> |
| 3115 |
<primary>NIS</primary> |
| 3116 |
<secondary>client configuration</secondary> |
| 3117 |
</indexterm> |
| 3118 |
<para>Setting up a FreeBSD machine to be a NIS client is fairly |
| 3119 |
straightforward.</para> |
| 3120 |
|
| 3121 |
<procedure> |
| 3122 |
<step> |
| 3123 |
<para>Edit the file <filename>/etc/rc.conf</filename> and |
| 3124 |
add the following lines in order to set the NIS domainname |
| 3125 |
and start <command>ypbind</command> upon network |
| 3126 |
startup:</para> |
| 3127 |
|
| 3128 |
<programlisting>nisdomainname="test-domain" |
| 3129 |
nis_client_enable="YES"</programlisting> |
| 3130 |
</step> |
| 3131 |
|
| 3132 |
<step> |
| 3133 |
<para>To import all possible password entries from the NIS |
| 3134 |
server, remove all user accounts from your |
| 3135 |
<filename>/etc/master.passwd</filename> file and use |
| 3136 |
<command>vipw</command> to add the following line to |
| 3137 |
the end of the file:</para> |
| 3138 |
|
| 3139 |
<programlisting>+:::::::::</programlisting> |
| 3140 |
|
| 3141 |
<note> |
| 3142 |
<para>This line will afford anyone with a valid account in |
| 3143 |
the NIS server's password maps an account. There are |
| 3144 |
many ways to configure your NIS client by changing this |
| 3145 |
line. See the <link linkend="network-netgroups">netgroups |
| 3146 |
section</link> below for more information. |
| 3147 |
For more detailed reading see O'Reilly's book on |
| 3148 |
<literal>Managing NFS and NIS</literal>.</para> |
| 3149 |
</note> |
| 3150 |
|
| 3151 |
<note> |
| 3152 |
<para>You should keep at least one local account (i.e. |
| 3153 |
not imported via NIS) in your |
| 3154 |
<filename>/etc/master.passwd</filename> and this |
| 3155 |
account should also be a member of the group |
| 3156 |
<groupname>wheel</groupname>. If there is something |
| 3157 |
wrong with NIS, this account can be used to log in |
| 3158 |
remotely, become root, and fix things.</para> |
| 3159 |
</note> |
| 3160 |
</step> |
| 3161 |
|
| 3162 |
<step> |
| 3163 |
<para>To import all possible group entries from the NIS |
| 3164 |
server, add this line to your |
| 3165 |
<filename>/etc/group</filename> file:</para> |
| 3166 |
|
| 3167 |
<programlisting>+:*::</programlisting> |
| 3168 |
</step> |
| 3169 |
</procedure> |
| 3170 |
|
| 3171 |
<para>After completing these steps, you should be able to run |
| 3172 |
<command>ypcat passwd</command> and see the NIS server's |
| 3173 |
passwd map.</para> |
| 3174 |
</sect4> |
| 3175 |
</sect3> |
| 3176 |
</sect2> |
| 3177 |
|
| 3178 |
<sect2> |
| 3179 |
<title>NIS Security</title> |
| 3180 |
|
| 3181 |
<para>In general, any remote user can issue an RPC to |
| 3182 |
&man.ypserv.8; and retrieve the contents of your NIS maps, |
| 3183 |
provided the remote user knows your domainname. To prevent |
| 3184 |
such unauthorized transactions, &man.ypserv.8; supports a |
| 3185 |
feature called securenets which can be used to restrict access |
| 3186 |
to a given set of hosts. At startup, &man.ypserv.8; will |
| 3187 |
attempt to load the securenets information from a file called |
| 3188 |
<filename>/var/yp/securenets</filename>.</para> |
| 3189 |
|
| 3190 |
<note> |
| 3191 |
<para>This path varies depending on the path specified with the |
| 3192 |
<option>-p</option> option. This file contains entries that |
| 3193 |
consist of a network specification and a network mask separated |
| 3194 |
by white space. Lines starting with <quote>#</quote> are |
| 3195 |
considered to be comments. A sample securenets file might look |
| 3196 |
like this:</para> |
| 3197 |
</note> |
| 3198 |
|
| 3199 |
<programlisting># allow connections from local host -- mandatory |
| 3200 |
127.0.0.1 255.255.255.255 |
| 3201 |
# allow connections from any host |
| 3202 |
# on the 192.168.128.0 network |
| 3203 |
192.168.128.0 255.255.255.0 |
| 3204 |
# allow connections from any host |
| 3205 |
# between 10.0.0.0 to 10.0.15.255 |
| 3206 |
# this includes the machines in the testlab |
| 3207 |
10.0.0.0 255.255.240.0</programlisting> |
| 3208 |
|
| 3209 |
<para>If &man.ypserv.8; receives a request from an address that |
| 3210 |
matches one of these rules, it will process the request |
| 3211 |
normally. If the address fails to match a rule, the request |
| 3212 |
will be ignored and a warning message will be logged. If the |
| 3213 |
<filename>/var/yp/securenets</filename> file does not exist, |
| 3214 |
<command>ypserv</command> will allow connections from any |
| 3215 |
host.</para> |
| 3216 |
|
| 3217 |
<para>The <command>ypserv</command> program also has support for Wietse |
| 3218 |
Venema's |
| 3219 |
<application>tcpwrapper</application> package. This allows the |
| 3220 |
administrator to use the <application>tcpwrapper</application> configuration |
| 3221 |
files for access control instead of |
| 3222 |
<filename>/var/yp/securenets</filename>.</para> |
| 3223 |
|
| 3224 |
<note> |
| 3225 |
<para>While both of these access control mechanisms provide some |
| 3226 |
security, they, like the privileged port test, are |
| 3227 |
vulnerable to <quote>IP spoofing</quote> attacks. All |
| 3228 |
NIS-related traffic should be blocked at your firewall.</para> |
| 3229 |
|
| 3230 |
<para>Servers using <filename>/var/yp/securenets</filename> |
| 3231 |
may fail to serve legitimate NIS clients with archaic TCP/IP |
| 3232 |
implementations. Some of these implementations set all |
| 3233 |
host bits to zero when doing broadcasts and/or fail to |
| 3234 |
observe the subnet mask when calculating the broadcast |
| 3235 |
address. While some of these problems can be fixed by |
| 3236 |
changing the client configuration, other problems may force |
| 3237 |
the retirement of the client systems in question or the |
| 3238 |
abandonment of <filename>/var/yp/securenets</filename>.</para> |
| 3239 |
|
| 3240 |
<para>Using <filename>/var/yp/securenets</filename> on a |
| 3241 |
server with such an archaic implementation of TCP/IP is a |
| 3242 |
really bad idea and will lead to loss of NIS functionality |
| 3243 |
for large parts of your network.</para> |
| 3244 |
|
| 3245 |
<indexterm><primary>tcpwrapper</primary></indexterm> |
| 3246 |
<para>The use of the <application>tcpwrapper</application> |
| 3247 |
package increases the latency of your NIS server. The |
| 3248 |
additional delay may be long enough to cause timeouts in |
| 3249 |
client programs, especially in busy networks or with slow |
| 3250 |
NIS servers. If one or more of your client systems |
| 3251 |
suffers from these symptoms, you should convert the client |
| 3252 |
systems in question into NIS slave servers and force them |
| 3253 |
to bind to themselves.</para> |
| 3254 |
</note> |
| 3255 |
</sect2> |
| 3256 |
|
| 3257 |
<sect2> |
| 3258 |
<title>Barring Some Users from Logging On</title> |
| 3259 |
|
| 3260 |
<para>In our lab, there is a machine <hostid>basie</hostid> that is |
| 3261 |
supposed to be a faculty only workstation. We do not want to take this |
| 3262 |
machine out of the NIS domain, yet the <filename>passwd</filename> |
| 3263 |
file on the master NIS server contains accounts for both faculty and |
| 3264 |
students. What can we do?</para> |
| 3265 |
|
| 3266 |
<para>There is a way to bar specific users from logging on to a |
| 3267 |
machine, even if they are present in the NIS database. To do this, |
| 3268 |
all you must do is add |
| 3269 |
<emphasis>-<replaceable>username</replaceable></emphasis> to the end of |
| 3270 |
the <filename>/etc/master.passwd</filename> file on the client |
| 3271 |
machine, where <replaceable>username</replaceable> is the username of |
| 3272 |
the user you wish to bar from logging in. This should preferably be |
| 3273 |
done using <command>vipw</command>, since <command>vipw</command> |
| 3274 |
will sanity check your changes to |
| 3275 |
<filename>/etc/master.passwd</filename>, as well as |
| 3276 |
automatically rebuild the password database when you |
| 3277 |
finish editing. For example, if we wanted to bar user |
| 3278 |
<emphasis>bill</emphasis> from logging on to <hostid>basie</hostid> |
| 3279 |
we would:</para> |
| 3280 |
|
| 3281 |
<screen>basie&prompt.root; <userinput>vipw</userinput> |
| 3282 |
<userinput>[add -bill to the end, exit]</userinput> |
| 3283 |
vipw: rebuilding the database... |
| 3284 |
vipw: done |
| 3285 |
|
| 3286 |
basie&prompt.root; <userinput>cat /etc/master.passwd</userinput> |
| 3287 |
|
| 3288 |
root:[password]:0:0::0:0:The super-user:/root:/bin/csh |
| 3289 |
toor:[password]:0:0::0:0:The other super-user:/root:/bin/sh |
| 3290 |
daemon:*:1:1::0:0:Owner of many system processes:/root:/sbin/nologin |
| 3291 |
operator:*:2:5::0:0:System &:/:/sbin/nologin |
| 3292 |
bin:*:3:7::0:0:Binaries Commands and Source,,,:/:/sbin/nologin |
| 3293 |
tty:*:4:65533::0:0:Tty Sandbox:/:/sbin/nologin |
| 3294 |
kmem:*:5:65533::0:0:KMem Sandbox:/:/sbin/nologin |
| 3295 |
games:*:7:13::0:0:Games pseudo-user:/usr/games:/sbin/nologin |
| 3296 |
news:*:8:8::0:0:News Subsystem:/:/sbin/nologin |
| 3297 |
man:*:9:9::0:0:Mister Man Pages:/usr/share/man:/sbin/nologin |
| 3298 |
bind:*:53:53::0:0:Bind Sandbox:/:/sbin/nologin |
| 3299 |
uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/libexec/uucp/uucico |
| 3300 |
xten:*:67:67::0:0:X-10 daemon:/usr/local/xten:/sbin/nologin |
| 3301 |
pop:*:68:6::0:0:Post Office Owner:/nonexistent:/sbin/nologin |
| 3302 |
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/sbin/nologin |
| 3303 |
+::::::::: |
| 3304 |
-bill |
| 3305 |
|
| 3306 |
basie&prompt.root;</screen> |
| 3307 |
</sect2> |
| 3308 |
|
| 3309 |
<sect2 id="network-netgroups"> |
| 3310 |
<sect2info> |
| 3311 |
<authorgroup> |
| 3312 |
<author> |
| 3313 |
<firstname>Udo</firstname> |
| 3314 |
<surname>Erdelhoff</surname> |
| 3315 |
<contrib>Contributed by </contrib> |
| 3316 |
</author> |
| 3317 |
</authorgroup> |
| 3318 |
</sect2info> |
| 3319 |
|
| 3320 |
<title>Using Netgroups</title> |
| 3321 |
<indexterm><primary>netgroups</primary></indexterm> |
| 3322 |
|
| 3323 |
<para>The method shown in the previous section works reasonably |
| 3324 |
well if you need special rules for a very small number of |
| 3325 |
users and/or machines. On larger networks, you |
| 3326 |
<emphasis>will</emphasis> forget to bar some users from logging |
| 3327 |
onto sensitive machines, or you may even have to modify each |
| 3328 |
machine separately, thus losing the main benefit of NIS, |
| 3329 |
<emphasis>centralized</emphasis> administration.</para> |
| 3330 |
|
| 3331 |
<para>The NIS developers' solution for this problem is called |
| 3332 |
<emphasis>netgroups</emphasis>. Their purpose and semantics |
| 3333 |
can be compared to the normal groups used by Unix file |
| 3334 |
systems. The main differences are the lack of a numeric id |
| 3335 |
and the ability to define a netgroup by including both user |
| 3336 |
accounts and other netgroups.</para> |
| 3337 |
|
| 3338 |
<para>Netgroups were developed to handle large, complex networks |
| 3339 |
with hundreds of users and machines. On one hand, this is |
| 3340 |
a Good Thing if you are forced to deal with such a situation. |
| 3341 |
On the other hand, this complexity makes it almost impossible to |
| 3342 |
explain netgroups with really simple examples. The example |
| 3343 |
used in the remainder of this section demonstrates this |
| 3344 |
problem.</para> |
| 3345 |
|
| 3346 |
<para>Let us assume that your successful introduction of NIS in |
| 3347 |
your laboratory caught your superiors' interest. Your next |
| 3348 |
job is to extend your NIS domain to cover some of the other |
| 3349 |
machines on campus. The two tables contain the names of the |
| 3350 |
new users and new machines as well as brief descriptions of |
| 3351 |
them.</para> |
| 3352 |
|
| 3353 |
<informaltable> |
| 3354 |
<tgroup cols="2"> |
| 3355 |
<thead> |
| 3356 |
<row> |
| 3357 |
<entry>User Name(s)</entry> |
| 3358 |
<entry>Description</entry> |
| 3359 |
</row> |
| 3360 |
</thead> |
| 3361 |
|
| 3362 |
<tbody> |
| 3363 |
<row> |
| 3364 |
<entry>alpha, beta</entry> |
| 3365 |
<entry>Normal employees of the IT department</entry> |
| 3366 |
</row> |
| 3367 |
|
| 3368 |
<row> |
| 3369 |
<entry>charlie, delta</entry> |
| 3370 |
<entry>The new apprentices of the IT department</entry> |
| 3371 |
</row> |
| 3372 |
|
| 3373 |
<row> |
| 3374 |
<entry>echo, foxtrott, golf, ...</entry> |
| 3375 |
<entry>Ordinary employees</entry> |
| 3376 |
</row> |
| 3377 |
|
| 3378 |
<row> |
| 3379 |
<entry>able, baker, ...</entry> |
| 3380 |
<entry>The current interns</entry> |
| 3381 |
</row> |
| 3382 |
</tbody> |
| 3383 |
</tgroup> |
| 3384 |
</informaltable> |
| 3385 |
|
| 3386 |
<informaltable> |
| 3387 |
<tgroup cols="2"> |
| 3388 |
<thead> |
| 3389 |
<row> |
| 3390 |
<entry>Machine Name(s)</entry> |
| 3391 |
<entry>Description</entry> |
| 3392 |
</row> |
| 3393 |
</thead> |
| 3394 |
|
| 3395 |
<tbody> |
| 3396 |
<row> |
| 3397 |
<!-- Names taken from "Good Omens" by Neil Gaiman and Terry |
| 3398 |
Pratchett. Many thanks for a brilliant book. --> |
| 3399 |
<entry>war, death, famine, pollution</entry> |
| 3400 |
<entry>Your most important servers. Only the IT |
| 3401 |
employees are allowed to log onto these |
| 3402 |
machines.</entry> |
| 3403 |
</row> |
| 3404 |
<row> |
| 3405 |
<!-- gluttony was omitted because it was too fat --> |
| 3406 |
<entry>pride, greed, envy, wrath, lust, sloth</entry> |
| 3407 |
<entry>Less important servers. All members of the IT |
| 3408 |
department are allowed to login onto these machines.</entry> |
| 3409 |
</row> |
| 3410 |
|
| 3411 |
<row> |
| 3412 |
<entry>one, two, three, four, ...</entry> |
| 3413 |
<entry>Ordinary workstations. Only the |
| 3414 |
<emphasis>real</emphasis> employees are allowed to use |
| 3415 |
these machines.</entry> |
| 3416 |
</row> |
| 3417 |
|
| 3418 |
<row> |
| 3419 |
<entry>trashcan</entry> |
| 3420 |
<entry>A very old machine without any critical data. |
| 3421 |
Even the intern is allowed to use this box.</entry> |
| 3422 |
</row> |
| 3423 |
</tbody> |
| 3424 |
</tgroup> |
| 3425 |
</informaltable> |
| 3426 |
|
| 3427 |
<para>If you tried to implement these restrictions by separately |
| 3428 |
blocking each user, you would have to add one |
| 3429 |
-<replaceable>user</replaceable> line to each system's |
| 3430 |
<filename>passwd</filename> |
| 3431 |
for each user who is not allowed to login onto that system. |
| 3432 |
If you forget just one entry, you could be in trouble. It may |
| 3433 |
be feasible to do this correctly during the initial setup, |
| 3434 |
however you <emphasis>will</emphasis> eventually forget to add |
| 3435 |
the lines for new users during day-to-day operations. After |
| 3436 |
all, Murphy was an optimist.</para> |
| 3437 |
|
| 3438 |
<para>Handling this situation with netgroups offers several |
| 3439 |
advantages. Each user need not be handled separately; |
| 3440 |
you assign a user to one or more netgroups and allow or forbid |
| 3441 |
logins for all members of the netgroup. If you add a new |
| 3442 |
machine, you will only have to define login restrictions for |
| 3443 |
netgroups. If a new user is added, you will only have to add |
| 3444 |
the user to one or more netgroups. Those changes are |
| 3445 |
independent of each other; no more <quote>for each combination |
| 3446 |
of user and machine do...</quote> If your NIS setup is planned |
| 3447 |
carefully, you will only have to modify exactly one central |
| 3448 |
configuration file to grant or deny access to machines.</para> |
| 3449 |
|
| 3450 |
<para>The first step is the initialization of the NIS map |
| 3451 |
netgroup. FreeBSD's &man.ypinit.8; does not create this map by |
| 3452 |
default, but its NIS implementation will support it once it has |
| 3453 |
been created. To create an empty map, simply type</para> |
| 3454 |
|
| 3455 |
<screen>ellington&prompt.root; <userinput>vi /var/yp/netgroup</userinput></screen> |
| 3456 |
|
| 3457 |
<para>and start adding content. For our example, we need at |
| 3458 |
least four netgroups: IT employees, IT apprentices, normal |
| 3459 |
employees and interns.</para> |
| 3460 |
|
| 3461 |
<programlisting>IT_EMP (,alpha,test-domain) (,beta,test-domain) |
| 3462 |
IT_APP (,charlie,test-domain) (,delta,test-domain) |
| 3463 |
USERS (,echo,test-domain) (,foxtrott,test-domain) \ |
| 3464 |
(,golf,test-domain) |
| 3465 |
INTERNS (,able,test-domain) (,baker,test-domain)</programlisting> |
| 3466 |
|
| 3467 |
<para><literal>IT_EMP</literal>, <literal>IT_APP</literal> etc. |
| 3468 |
are the names of the netgroups. Each bracketed group adds |
| 3469 |
one or more user accounts to it. The three fields inside a |
| 3470 |
group are:</para> |
| 3471 |
|
| 3472 |
<orderedlist> |
| 3473 |
<listitem> |
| 3474 |
<para>The name of the host(s) where the following items are |
| 3475 |
valid. If you do not specify a hostname, the entry is |
| 3476 |
valid on all hosts. If you do specify a hostname, you |
| 3477 |
will enter a realm of darkness, horror and utter confusion.</para> |
| 3478 |
</listitem> |
| 3479 |
|
| 3480 |
<listitem> |
| 3481 |
<para>The name of the account that belongs to this |
| 3482 |
netgroup.</para> |
| 3483 |
</listitem> |
| 3484 |
|
| 3485 |
<listitem> |
| 3486 |
<para>The NIS domain for the account. You can import |
| 3487 |
accounts from other NIS domains into your netgroup if you |
| 3488 |
are one of the unlucky fellows with more than one NIS |
| 3489 |
domain.</para> |
| 3490 |
</listitem> |
| 3491 |
</orderedlist> |
| 3492 |
|
| 3493 |
<para>Each of these fields can contain wildcards. See |
| 3494 |
&man.netgroup.5; for details.</para> |
| 3495 |
|
| 3496 |
<note> |
| 3497 |
<indexterm><primary>netgroups</primary></indexterm> |
| 3498 |
<para>Netgroup names longer than 8 characters should not be |
| 3499 |
used, especially if you have machines running other |
| 3500 |
operating systems within your NIS domain. The names are |
| 3501 |
case sensitive; using capital letters for your netgroup |
| 3502 |
names is an easy way to distinguish between user, machine |
| 3503 |
and netgroup names.</para> |
| 3504 |
|
| 3505 |
<para>Some NIS clients (other than FreeBSD) cannot handle |
| 3506 |
netgroups with a large number of entries. For example, some |
| 3507 |
older versions of SunOS start to cause trouble if a netgroup |
| 3508 |
contains more than 15 <emphasis>entries</emphasis>. You can |
| 3509 |
circumvent this limit by creating several sub-netgroups with |
| 3510 |
15 users or less and a real netgroup that consists of the |
| 3511 |
sub-netgroups:</para> |
| 3512 |
|
| 3513 |
<programlisting>BIGGRP1 (,joe1,domain) (,joe2,domain) (,joe3,domain) [...] |
| 3514 |
BIGGRP2 (,joe16,domain) (,joe17,domain) [...] |
| 3515 |
BIGGRP3 (,joe31,domain) (,joe32,domain) |
| 3516 |
BIGGROUP BIGGRP1 BIGGRP2 BIGGRP3</programlisting> |
| 3517 |
|
| 3518 |
<para>You can repeat this process if you need more than 225 |
| 3519 |
users within a single netgroup.</para> |
| 3520 |
</note> |
| 3521 |
|
| 3522 |
<para>Activating and distributing your new NIS map is |
| 3523 |
easy:</para> |
| 3524 |
|
| 3525 |
<screen>ellington&prompt.root; <userinput>cd /var/yp</userinput> |
| 3526 |
ellington&prompt.root; <userinput>make</userinput></screen> |
| 3527 |
|
| 3528 |
<para>This will generate the three NIS maps |
| 3529 |
<filename>netgroup</filename>, |
| 3530 |
<filename>netgroup.byhost</filename> and |
| 3531 |
<filename>netgroup.byuser</filename>. Use &man.ypcat.1; to |
| 3532 |
check if your new NIS maps are available:</para> |
| 3533 |
|
| 3534 |
<screen>ellington&prompt.user; <userinput>ypcat -k netgroup</userinput> |
| 3535 |
ellington&prompt.user; <userinput>ypcat -k netgroup.byhost</userinput> |
| 3536 |
ellington&prompt.user; <userinput>ypcat -k netgroup.byuser</userinput></screen> |
| 3537 |
|
| 3538 |
<para>The output of the first command should resemble the |
| 3539 |
contents of <filename>/var/yp/netgroup</filename>. The second |
| 3540 |
command will not produce output if you have not specified |
| 3541 |
host-specific netgroups. The third command can be used to |
| 3542 |
get the list of netgroups for a user.</para> |
| 3543 |
|
| 3544 |
<para>The client setup is quite simple. To configure the server |
| 3545 |
<replaceable>war</replaceable>, you only have to start |
| 3546 |
&man.vipw.8; and replace the line</para> |
| 3547 |
|
| 3548 |
<programlisting>+:::::::::</programlisting> |
| 3549 |
|
| 3550 |
<para>with</para> |
| 3551 |
|
| 3552 |
<programlisting>+@IT_EMP:::::::::</programlisting> |
| 3553 |
|
| 3554 |
<para>Now, only the data for the users defined in the netgroup |
| 3555 |
<replaceable>IT_EMP</replaceable> is imported into |
| 3556 |
<replaceable>war</replaceable>'s password database and only |
| 3557 |
these users are allowed to login.</para> |
| 3558 |
|
| 3559 |
<para>Unfortunately, this limitation also applies to the ~ |
| 3560 |
function of the shell and all routines converting between user |
| 3561 |
names and numerical user IDs. In other words, |
| 3562 |
<command>cd ~<replaceable>user</replaceable></command> will not work, |
| 3563 |
<command>ls -l</command> will show the numerical id instead of |
| 3564 |
the username and <command>find . -user joe -print</command> will |
| 3565 |
fail with <errorname>No such user</errorname>. To fix this, you will |
| 3566 |
have to import all user entries <emphasis>without allowing them |
| 3567 |
to login onto your servers</emphasis>.</para> |
| 3568 |
|
| 3569 |
<para>This can be achieved by adding another line to |
| 3570 |
<filename>/etc/master.passwd</filename>. This line should |
| 3571 |
contain:</para> |
| 3572 |
|
| 3573 |
<para><literal>+:::::::::/sbin/nologin</literal>, meaning |
| 3574 |
<quote>Import all entries but replace the shell with |
| 3575 |
<filename>/sbin/nologin</filename> in the imported |
| 3576 |
entries</quote>. You can replace any field |
| 3577 |
in the passwd entry by placing a default value in your |
| 3578 |
<filename>/etc/master.passwd</filename>.</para> |
| 3579 |
|
| 3580 |
<!-- Been there, done that, got the scars to prove it - ue --> |
| 3581 |
<warning> |
| 3582 |
<para>Make sure that the line |
| 3583 |
<literal>+:::::::::/sbin/nologin</literal> is placed after |
| 3584 |
<literal>+@IT_EMP:::::::::</literal>. Otherwise, all user |
| 3585 |
accounts imported from NIS will have /sbin/nologin as their |
| 3586 |
login shell.</para> |
| 3587 |
</warning> |
| 3588 |
|
| 3589 |
<para>After this change, you will only have to change one NIS |
| 3590 |
map if a new employee joins the IT department. You could use |
| 3591 |
a similar approach for the less important servers by replacing |
| 3592 |
the old <literal>+:::::::::</literal> in their local version |
| 3593 |
of <filename>/etc/master.passwd</filename> with something like |
| 3594 |
this:</para> |
| 3595 |
|
| 3596 |
<programlisting>+@IT_EMP::::::::: |
| 3597 |
+@IT_APP::::::::: |
| 3598 |
+:::::::::/sbin/nologin</programlisting> |
| 3599 |
|
| 3600 |
<para>The corresponding lines for the normal workstations |
| 3601 |
could be:</para> |
| 3602 |
|
| 3603 |
<programlisting>+@IT_EMP::::::::: |
| 3604 |
+@USERS::::::::: |
| 3605 |
+:::::::::/sbin/nologin</programlisting> |
| 3606 |
|
| 3607 |
<para>And everything would be fine until there is a policy |
| 3608 |
change a few weeks later: The IT department starts hiring |
| 3609 |
interns. The IT interns are allowed to use the normal |
| 3610 |
workstations and the less important servers; and the IT |
| 3611 |
apprentices are allowed to login onto the main servers. You |
| 3612 |
add a new netgroup IT_INTERN, add the new IT interns to this |
| 3613 |
netgroup and start to change the config on each and every |
| 3614 |
machine... As the old saying goes: <quote>Errors in |
| 3615 |
centralized planning lead to global mess</quote>.</para> |
| 3616 |
|
| 3617 |
<para>NIS' ability to create netgroups from other netgroups can |
| 3618 |
be used to prevent situations like these. One possibility |
| 3619 |
is the creation of role-based netgroups. For example, you |
| 3620 |
could create a netgroup called |
| 3621 |
<replaceable>BIGSRV</replaceable> to define the login |
| 3622 |
restrictions for the important servers, another netgroup |
| 3623 |
called <replaceable>SMALLSRV</replaceable> for the less |
| 3624 |
important servers and a third netgroup called |
| 3625 |
<replaceable>USERBOX</replaceable> for the normal |
| 3626 |
workstations. Each of these netgroups contains the netgroups |
| 3627 |
that are allowed to login onto these machines. The new |
| 3628 |
entries for your NIS map netgroup should look like this:</para> |
| 3629 |
|
| 3630 |
<programlisting>BIGSRV IT_EMP IT_APP |
| 3631 |
SMALLSRV IT_EMP IT_APP ITINTERN |
| 3632 |
USERBOX IT_EMP ITINTERN USERS</programlisting> |
| 3633 |
|
| 3634 |
<para>This method of defining login restrictions works |
| 3635 |
reasonably well if you can define groups of machines with |
| 3636 |
identical restrictions. Unfortunately, this is the exception |
| 3637 |
and not the rule. Most of the time, you will need the ability |
| 3638 |
to define login restrictions on a per-machine basis.</para> |
| 3639 |
|
| 3640 |
<para>Machine-specific netgroup definitions are the other |
| 3641 |
possibility to deal with the policy change outlined above. In |
| 3642 |
this scenario, the <filename>/etc/master.passwd</filename> of |
| 3643 |
each box contains two lines starting with <quote>+</quote>. |
| 3644 |
The first of them adds a netgroup with the accounts allowed to |
| 3645 |
login onto this machine, the second one adds all other |
| 3646 |
accounts with <filename>/sbin/nologin</filename> as shell. It |
| 3647 |
is a good idea to use the ALL-CAPS version of the machine name |
| 3648 |
as the name of the netgroup. In other words, the lines should |
| 3649 |
look like this:</para> |
| 3650 |
|
| 3651 |
<programlisting>+@<replaceable>BOXNAME</replaceable>::::::::: |
| 3652 |
+:::::::::/sbin/nologin</programlisting> |
| 3653 |
|
| 3654 |
<para>Once you have completed this task for all your machines, |
| 3655 |
you will not have to modify the local versions of |
| 3656 |
<filename>/etc/master.passwd</filename> ever again. All |
| 3657 |
further changes can be handled by modifying the NIS map. Here |
| 3658 |
is an example of a possible netgroup map for this |
| 3659 |
scenario with some additional goodies.</para> |
| 3660 |
|
| 3661 |
<programlisting># Define groups of users first |
| 3662 |
IT_EMP (,alpha,test-domain) (,beta,test-domain) |
| 3663 |
IT_APP (,charlie,test-domain) (,delta,test-domain) |
| 3664 |
DEPT1 (,echo,test-domain) (,foxtrott,test-domain) |
| 3665 |
DEPT2 (,golf,test-domain) (,hotel,test-domain) |
| 3666 |
DEPT3 (,india,test-domain) (,juliet,test-domain) |
| 3667 |
ITINTERN (,kilo,test-domain) (,lima,test-domain) |
| 3668 |
D_INTERNS (,able,test-domain) (,baker,test-domain) |
| 3669 |
# |
| 3670 |
# Now, define some groups based on roles |
| 3671 |
USERS DEPT1 DEPT2 DEPT3 |
| 3672 |
BIGSRV IT_EMP IT_APP |
| 3673 |
SMALLSRV IT_EMP IT_APP ITINTERN |
| 3674 |
USERBOX IT_EMP ITINTERN USERS |
| 3675 |
# |
| 3676 |
# And a groups for a special tasks |
| 3677 |
# Allow echo and golf to access our anti-virus-machine |
| 3678 |
SECURITY IT_EMP (,echo,test-domain) (,golf,test-domain) |
| 3679 |
# |
| 3680 |
# machine-based netgroups |
| 3681 |
# Our main servers |
| 3682 |
WAR BIGSRV |
| 3683 |
FAMINE BIGSRV |
| 3684 |
# User india needs access to this server |
| 3685 |
POLLUTION BIGSRV (,india,test-domain) |
| 3686 |
# |
| 3687 |
# This one is really important and needs more access restrictions |
| 3688 |
DEATH IT_EMP |
| 3689 |
# |
| 3690 |
# The anti-virus-machine mentioned above |
| 3691 |
ONE SECURITY |
| 3692 |
# |
| 3693 |
# Restrict a machine to a single user |
| 3694 |
TWO (,hotel,test-domain) |
| 3695 |
# [...more groups to follow]</programlisting> |
| 3696 |
|
| 3697 |
<para>If you are using some kind of database to manage your user |
| 3698 |
accounts, you should be able to create the first part of the |
| 3699 |
map with your database's report tools. This way, new users |
| 3700 |
will automatically have access to the boxes.</para> |
| 3701 |
|
| 3702 |
<para>One last word of caution: It may not always be advisable |
| 3703 |
to use machine-based netgroups. If you are deploying a couple of |
| 3704 |
dozen or even hundreds of identical machines for student labs, |
| 3705 |
you should use role-based netgroups instead of machine-based |
| 3706 |
netgroups to keep the size of the NIS map within reasonable |
| 3707 |
limits.</para> |
| 3708 |
</sect2> |
| 3709 |
|
| 3710 |
<sect2> |
| 3711 |
<title>Important Things to Remember</title> |
| 3712 |
|
| 3713 |
<para>There are still a couple of things that you will need to do |
| 3714 |
differently now that you are in an NIS environment.</para> |
| 3715 |
|
| 3716 |
<itemizedlist> |
| 3717 |
<listitem> |
| 3718 |
<para>Every time you wish to add a user to the lab, you |
| 3719 |
must add it to the master NIS server <emphasis>only</emphasis>, |
| 3720 |
and <emphasis>you must remember to rebuild the NIS |
| 3721 |
maps</emphasis>. If you forget to do this, the new user will |
| 3722 |
not be able to login anywhere except on the NIS master. |
| 3723 |
For example, if we needed to add a new user |
| 3724 |
<quote>jsmith</quote> to the lab, we would:</para> |
| 3725 |
|
| 3726 |
<screen>&prompt.root; <userinput>pw useradd jsmith</userinput> |
| 3727 |
&prompt.root; <userinput>cd /var/yp</userinput> |
| 3728 |
&prompt.root; <userinput>make test-domain</userinput></screen> |
| 3729 |
|
| 3730 |
<para>You could also run <command>adduser jsmith</command> instead |
| 3731 |
of <command>pw useradd jsmith</command>.</para> |
| 3732 |
</listitem> |
| 3733 |
<listitem> |
| 3734 |
<para><emphasis>Keep the administration accounts out of the NIS |
| 3735 |
maps</emphasis>. You do not want to be propagating administrative |
| 3736 |
accounts and passwords to machines that will have users that |
| 3737 |
should not have access to those accounts.</para> |
| 3738 |
</listitem> |
| 3739 |
<listitem> |
| 3740 |
<para><emphasis>Keep the NIS master and slave |
| 3741 |
secure, and minimize their downtime</emphasis>. |
| 3742 |
If somebody either hacks or simply turns off |
| 3743 |
these machines, they have effectively rendered many people without |
| 3744 |
the ability to login to the lab.</para> |
| 3745 |
|
| 3746 |
<para>This is the chief weakness of any centralized administration |
| 3747 |
system, and it is probably the most important weakness. If you do |
| 3748 |
not protect your NIS servers, you will have a lot of angry |
| 3749 |
users!</para> |
| 3750 |
</listitem> |
| 3751 |
</itemizedlist> |
| 3752 |
</sect2> |
| 3753 |
|
| 3754 |
<sect2> |
| 3755 |
<title>NIS v1 Compatibility</title> |
| 3756 |
|
| 3757 |
<para> FreeBSD's <application>ypserv</application> has some support |
| 3758 |
for serving NIS v1 clients. FreeBSD's NIS implementation only |
| 3759 |
uses the NIS v2 protocol, however other implementations include |
| 3760 |
support for the v1 protocol for backwards compatibility with older |
| 3761 |
systems. The <application>ypbind</application> daemons supplied |
| 3762 |
with these systems will try to establish a binding to an NIS v1 |
| 3763 |
server even though they may never actually need it (and they may |
| 3764 |
persist in broadcasting in search of one even after they receive a |
| 3765 |
response from a v2 server). Note that while support for normal |
| 3766 |
client calls is provided, this version of ypserv does not handle |
| 3767 |
v1 map transfer requests; consequently, it cannot be used as a |
| 3768 |
master or slave in conjunction with older NIS servers that only |
| 3769 |
support the v1 protocol. Fortunately, there probably are not any |
| 3770 |
such servers still in use today.</para> |
| 3771 |
</sect2> |
| 3772 |
|
| 3773 |
<sect2 id="network-nis-server-is-client"> |
| 3774 |
<title>NIS Servers That Are Also NIS Clients</title> |
| 3775 |
|
| 3776 |
<para> Care must be taken when running ypserv in a multi-server |
| 3777 |
domain where the server machines are also NIS clients. It is |
| 3778 |
generally a good idea to force the servers to bind to themselves |
| 3779 |
rather than allowing them to broadcast bind requests and possibly |
| 3780 |
become bound to each other. Strange failure modes can result if |
| 3781 |
one server goes down and others are dependent upon it. |
| 3782 |
Eventually all the clients will time out and attempt to bind to |
| 3783 |
other servers, but the delay involved can be considerable and the |
| 3784 |
failure mode is still present since the servers might bind to each |
| 3785 |
other all over again.</para> |
| 3786 |
|
| 3787 |
<para>You can force a host to bind to a particular server by running |
| 3788 |
<command>ypbind</command> with the <option>-S</option> |
| 3789 |
flag. If you do not want to do this manually each time you |
| 3790 |
reboot your NIS server, you can add the following lines to |
| 3791 |
your <filename>/etc/rc.conf</filename>:</para> |
| 3792 |
|
| 3793 |
<programlisting>nis_client_enable="YES" # run client stuff as well |
| 3794 |
nis_client_flags="-S <replaceable>NIS domain</replaceable>,<replaceable>server</replaceable>"</programlisting> |
| 3795 |
|
| 3796 |
<para>See &man.ypbind.8; for further information.</para> |
| 3797 |
</sect2> |
| 3798 |
|
| 3799 |
<sect2> |
| 3800 |
<title>Password Formats</title> |
| 3801 |
<indexterm> |
| 3802 |
<primary>NIS</primary> |
| 3803 |
<secondary>password formats</secondary> |
| 3804 |
</indexterm> |
| 3805 |
<para>One of the most common issues that people run into when trying |
| 3806 |
to implement NIS is password format compatibility. If your NIS |
| 3807 |
server is using DES encrypted passwords, it will only support |
| 3808 |
clients that are also using DES. For example, if you have |
| 3809 |
Solaris NIS clients in your network, then you will almost certainly |
| 3810 |
need to use DES encrypted passwords.</para> |
| 3811 |
|
| 3812 |
<para>To check which format your servers |
| 3813 |
and clients are using, look at <filename>/etc/login.conf</filename>. |
| 3814 |
If the host is configured to use DES encrypted passwords, then the |
| 3815 |
<literal>default</literal> class will contain an entry like this:</para> |
| 3816 |
|
| 3817 |
<programlisting>default:\ |
| 3818 |
:passwd_format=des:\ |
| 3819 |
:copyright=/etc/COPYRIGHT:\ |
| 3820 |
[Further entries elided]</programlisting> |
| 3821 |
|
| 3822 |
<para>Other possible values for the <literal>passwd_format</literal> |
| 3823 |
capability include <literal>blf</literal> and <literal>md5</literal> |
| 3824 |
(for Blowfish and MD5 encrypted passwords, respectively).</para> |
| 3825 |
|
| 3826 |
<para>If you have made changes to <filename>/etc/login.conf</filename>, |
| 3827 |
you will also need to rebuild the login capability database, which is |
| 3828 |
achieved by running the following command as <username>root</username>:</para> |
| 3829 |
|
| 3830 |
<screen>&prompt.root; <userinput>cap_mkdb /etc/login.conf</userinput></screen> |
| 3831 |
|
| 3832 |
<note><para>The format of passwords already in |
| 3833 |
<filename>/etc/master.passwd</filename> will not be updated until |
| 3834 |
a user changes their password for the first time <emphasis>after</emphasis> |
| 3835 |
the login capability database is rebuilt.</para></note> |
| 3836 |
|
| 3837 |
<para>Next, in order to ensure that passwords are encrypted with the |
| 3838 |
format that you have chosen, you should also check that the |
| 3839 |
<literal>crypt_default</literal> in <filename>/etc/auth.conf</filename> |
| 3840 |
gives precedence to your chosen password format. To do this, place |
| 3841 |
the format that you have chosen first in the list. For example, when |
| 3842 |
using DES encrypted passwords, the entry would be:</para> |
| 3843 |
|
| 3844 |
<programlisting>crypt_default = des blf md5</programlisting> |
| 3845 |
|
| 3846 |
<para>Having followed the above steps on each of the &os; based NIS |
| 3847 |
servers and clients, you can be sure that they all agree on which |
| 3848 |
password format is used within your network. |
| 3849 |
If you have trouble authenticating on an NIS client, this |
| 3850 |
is a pretty good place to start looking for possible problems. |
| 3851 |
Remember: if you want to deploy an NIS server for a heterogenous |
| 3852 |
network, you will probably have to use DES on all systems |
| 3853 |
because it is the lowest common standard.</para> |
| 3854 |
</sect2> |
| 3855 |
</sect1> |
| 3856 |
|
| 3857 |
<sect1 id="network-dhcp"> |
| 3858 |
<sect1info> |
| 3859 |
<authorgroup> |
| 3860 |
<author> |
| 3861 |
<firstname>Greg</firstname> |
| 3862 |
<surname>Sutter</surname> |
| 3863 |
<contrib>Written by </contrib> |
| 3864 |
</author> |
| 3865 |
</authorgroup> |
| 3866 |
</sect1info> |
| 3867 |
<title>DHCP</title> |
| 3868 |
|
| 3869 |
<sect2> |
| 3870 |
<title>What Is DHCP?</title> |
| 3871 |
<indexterm> |
| 3872 |
<primary>Dynamic Host Configuration Protocol</primary> |
| 3873 |
<see>DHCP</see> |
| 3874 |
</indexterm> |
| 3875 |
<indexterm> |
| 3876 |
<primary>Internet Software Consortium (ISC)</primary> |
| 3877 |
</indexterm> |
| 3878 |
|
| 3879 |
<para>DHCP, the Dynamic Host Configuration Protocol, describes |
| 3880 |
the means by which a system can connect to a network and obtain the |
| 3881 |
necessary information for communication upon that network. FreeBSD |
| 3882 |
uses the ISC (Internet Software Consortium) DHCP implementation, so |
| 3883 |
all implementation-specific information here is for use with the ISC |
| 3884 |
distribution.</para> |
| 3885 |
</sect2> |
| 3886 |
|
| 3887 |
<sect2> |
| 3888 |
<title>What This Section Covers</title> |
| 3889 |
|
| 3890 |
<para>This section describes both the client-side and server-side |
| 3891 |
components of the ISC DHCP system. The client-side program, |
| 3892 |
<command>dhclient</command>, comes integrated within FreeBSD, and |
| 3893 |
the server-side portion is available from the |
| 3894 |
<filename role="package">net/isc-dhcp3</filename> port. The |
| 3895 |
&man.dhclient.8;, &man.dhcp-options.5;, and &man.dhclient.conf.5; |
| 3896 |
manual pages, in addition to the references below, are useful |
| 3897 |
resources.</para> |
| 3898 |
</sect2> |
| 3899 |
|
| 3900 |
<sect2> |
| 3901 |
<title>How It Works</title> |
| 3902 |
<indexterm><primary>UDP</primary></indexterm> |
| 3903 |
<para>When <command>dhclient</command>, the DHCP client, is |
| 3904 |
executed on the client machine, it begins broadcasting |
| 3905 |
requests for configuration information. By default, these |
| 3906 |
requests are on UDP port 68. The server replies on UDP 67, |
| 3907 |
giving the client an IP address and other relevant network |
| 3908 |
information such as netmask, router, and DNS servers. All of |
| 3909 |
this information comes in the form of a DHCP |
| 3910 |
<quote>lease</quote> and is only valid for a certain time |
| 3911 |
(configured by the DHCP server maintainer). In this manner, |
| 3912 |
stale IP addresses for clients no longer connected to the |
| 3913 |
network can be automatically reclaimed.</para> |
| 3914 |
|
| 3915 |
<para>DHCP clients can obtain a great deal of information from |
| 3916 |
the server. An exhaustive list may be found in |
| 3917 |
&man.dhcp-options.5;.</para> |
| 3918 |
</sect2> |
| 3919 |
|
| 3920 |
<sect2> |
| 3921 |
<title>FreeBSD Integration</title> |
| 3922 |
|
| 3923 |
<para>FreeBSD fully integrates the ISC DHCP client, |
| 3924 |
<command>dhclient</command>. DHCP client support is provided |
| 3925 |
within both the installer and the base system, obviating the need |
| 3926 |
for detailed knowledge of network configurations on any network |
| 3927 |
that runs a DHCP server. <command>dhclient</command> has been |
| 3928 |
included in all FreeBSD distributions since 3.2.</para> |
| 3929 |
<indexterm> |
| 3930 |
<primary><application>sysinstall</application></primary> |
| 3931 |
</indexterm> |
| 3932 |
|
| 3933 |
<para>DHCP is supported by |
| 3934 |
<application>sysinstall</application>. When configuring a |
| 3935 |
network interface within sysinstall, the first question |
| 3936 |
asked is, <quote>Do you want to try DHCP configuration of |
| 3937 |
this interface?</quote> Answering affirmatively will execute |
| 3938 |
<command>dhclient</command>, and if successful, will fill in |
| 3939 |
the network configuration information automatically.</para> |
| 3940 |
|
| 3941 |
<para>There are two things you must do to have your system use |
| 3942 |
DHCP upon startup:</para> |
| 3943 |
<indexterm> |
| 3944 |
<primary>DHCP</primary> |
| 3945 |
<secondary>requirements</secondary> |
| 3946 |
</indexterm> |
| 3947 |
<itemizedlist> |
| 3948 |
<listitem> |
| 3949 |
<para>Make sure that the <devicename>bpf</devicename> |
| 3950 |
device is compiled into your kernel. To do this, add |
| 3951 |
<literal>pseudo-device bpf</literal> to your kernel |
| 3952 |
configuration file, and rebuild the kernel. For more |
| 3953 |
information about building kernels, see <xref |
| 3954 |
linkend="kernelconfig">.</para> |
| 3955 |
<para>The <devicename>bpf</devicename> device is already |
| 3956 |
part of the <filename>GENERIC</filename> kernel that is |
| 3957 |
supplied with FreeBSD, so if you do not have a custom |
| 3958 |
kernel, you should not need to create one in order to get |
| 3959 |
DHCP working.</para> |
| 3960 |
<note> |
| 3961 |
<para>For those who are particularly security conscious, |
| 3962 |
you should be warned that <devicename>bpf</devicename> |
| 3963 |
is also the device that allows packet sniffers to work |
| 3964 |
correctly (although they still have to be run as |
| 3965 |
<username>root</username>). <devicename>bpf</devicename> |
| 3966 |
<emphasis>is</emphasis> required to use DHCP, but if |
| 3967 |
you are very sensitive about security, you probably |
| 3968 |
should not add <devicename>bpf</devicename> to your |
| 3969 |
kernel in the expectation that at some point in the |
| 3970 |
future you will be using DHCP.</para> |
| 3971 |
</note> |
| 3972 |
</listitem> |
| 3973 |
<listitem> |
| 3974 |
<para>Edit your <filename>/etc/rc.conf</filename> to |
| 3975 |
include the following:</para> |
| 3976 |
|
| 3977 |
<programlisting>ifconfig_fxp0="DHCP"</programlisting> |
| 3978 |
|
| 3979 |
<note> |
| 3980 |
<para>Be sure to replace <literal>fxp0</literal> with the |
| 3981 |
designation for the interface that you wish to dynamically |
| 3982 |
configure, as described in |
| 3983 |
<xref linkend="config-network-setup">.</para> |
| 3984 |
</note> |
| 3985 |
|
| 3986 |
<para>If you are using a different location for |
| 3987 |
<command>dhclient</command>, or if you wish to pass additional |
| 3988 |
flags to <command>dhclient</command>, also include the |
| 3989 |
following (editing as necessary):</para> |
| 3990 |
|
| 3991 |
<programlisting>dhcp_program="/sbin/dhclient" |
| 3992 |
dhcp_flags=""</programlisting> |
| 3993 |
</listitem> |
| 3994 |
</itemizedlist> |
| 3995 |
|
| 3996 |
<indexterm> |
| 3997 |
<primary>DHCP</primary> |
| 3998 |
<secondary>server</secondary> |
| 3999 |
</indexterm> |
| 4000 |
<para>The DHCP server, <command>dhcpd</command>, is included |
| 4001 |
as part of the <filename |
| 4002 |
role="package">net/isc-dhcp3</filename> port in the ports |
| 4003 |
collection. This port contains the full ISC DHCP |
| 4004 |
distribution, consisting of client, server, relay agent and |
| 4005 |
documentation. |
| 4006 |
</para> |
| 4007 |
</sect2> |
| 4008 |
|
| 4009 |
<sect2> |
| 4010 |
<title>Files</title> |
| 4011 |
<indexterm> |
| 4012 |
<primary>DHCP</primary> |
| 4013 |
<secondary>configuration files</secondary> |
| 4014 |
</indexterm> |
| 4015 |
<itemizedlist> |
| 4016 |
<listitem><para><filename>/etc/dhclient.conf</filename></para> |
| 4017 |
<para><command>dhclient</command> requires a configuration file, |
| 4018 |
<filename>/etc/dhclient.conf</filename>. Typically the file |
| 4019 |
contains only comments, the defaults being reasonably sane. This |
| 4020 |
configuration file is described by the &man.dhclient.conf.5; |
| 4021 |
manual page.</para> |
| 4022 |
</listitem> |
| 4023 |
|
| 4024 |
<listitem><para><filename>/sbin/dhclient</filename></para> |
| 4025 |
<para><command>dhclient</command> is statically linked and |
| 4026 |
resides in <filename>/sbin</filename>. The &man.dhclient.8; |
| 4027 |
manual page gives more information about |
| 4028 |
<command>dhclient</command>.</para> |
| 4029 |
</listitem> |
| 4030 |
|
| 4031 |
<listitem><para><filename>/sbin/dhclient-script</filename></para> |
| 4032 |
<para><command>dhclient-script</command> is the FreeBSD-specific |
| 4033 |
DHCP client configuration script. It is described in |
| 4034 |
&man.dhclient-script.8;, but should not need any user |
| 4035 |
modification to function properly.</para> |
| 4036 |
</listitem> |
| 4037 |
|
| 4038 |
<listitem><para><filename>/var/db/dhclient.leases</filename></para> |
| 4039 |
<para>The DHCP client keeps a database of valid leases in this |
| 4040 |
file, which is written as a log. &man.dhclient.leases.5; |
| 4041 |
gives a slightly longer description.</para> |
| 4042 |
</listitem> |
| 4043 |
</itemizedlist> |
| 4044 |
</sect2> |
| 4045 |
|
| 4046 |
<sect2> |
| 4047 |
<title>Further Reading</title> |
| 4048 |
|
| 4049 |
<para>The DHCP protocol is fully described in |
| 4050 |
<ulink url="http://www.freesoft.org/CIE/RFC/2131/">RFC 2131</ulink>. |
| 4051 |
An informational resource has also been set up at |
| 4052 |
<ulink url="http://www.dhcp.org/">dhcp.org</ulink>.</para> |
| 4053 |
</sect2> |
| 4054 |
|
| 4055 |
<sect2 id="network-dhcp-server"> |
| 4056 |
<title>Installing and Configuring a DHCP Server</title> |
| 4057 |
|
| 4058 |
<sect3> |
| 4059 |
<title>What This Section Covers</title> |
| 4060 |
|
| 4061 |
<para>This section provides information on how to configure |
| 4062 |
a FreeBSD system to act as a DHCP server using the ISC |
| 4063 |
(Internet Software Consortium) implementation of the DHCP |
| 4064 |
suite.</para> |
| 4065 |
|
| 4066 |
<para>The server portion of the suite is not provided as part of |
| 4067 |
FreeBSD, and so you will need to install the |
| 4068 |
<filename role="package">net/isc-dhcp3</filename> |
| 4069 |
port to provide this service. See <xref linkend="ports"> for |
| 4070 |
more information on using the ports collection.</para> |
| 4071 |
</sect3> |
| 4072 |
|
| 4073 |
<sect3> |
| 4074 |
<title>DHCP Server Installation</title> |
| 4075 |
<indexterm> |
| 4076 |
<primary>DHCP</primary> |
| 4077 |
<secondary>installation</secondary> |
| 4078 |
</indexterm> |
| 4079 |
<para>In order to configure your FreeBSD system as a DHCP server, |
| 4080 |
you will need to ensure that the &man.bpf.4; |
| 4081 |
device is compiled into your kernel. To do this, add |
| 4082 |
<literal>pseudo-device bpf</literal> to your kernel |
| 4083 |
configuration file, and rebuild the kernel. For more |
| 4084 |
information about building kernels, see <xref |
| 4085 |
linkend="kernelconfig">.</para> |
| 4086 |
|
| 4087 |
<para>The <devicename>bpf</devicename> device is already |
| 4088 |
part of the <filename>GENERIC</filename> kernel that is |
| 4089 |
supplied with FreeBSD, so you do not need to create a custom |
| 4090 |
kernel in order to get DHCP working.</para> |
| 4091 |
|
| 4092 |
<note> |
| 4093 |
<para>Those who are particularly security conscious |
| 4094 |
should note that <devicename>bpf</devicename> |
| 4095 |
is also the device that allows packet sniffers to work |
| 4096 |
correctly (although such programs still need privileged |
| 4097 |
access). <devicename>bpf</devicename> |
| 4098 |
<emphasis>is</emphasis> required to use DHCP, but if |
| 4099 |
you are very sensitive about security, you probably |
| 4100 |
should not include <devicename>bpf</devicename> in your |
| 4101 |
kernel purely because you expect to use DHCP at some |
| 4102 |
point in the future.</para> |
| 4103 |
</note> |
| 4104 |
|
| 4105 |
<para>The next thing that you will need to do is edit the sample |
| 4106 |
<filename>dhcpd.conf</filename> which was installed by the |
| 4107 |
<filename role="package">net/isc-dhcp3</filename> port. |
| 4108 |
By default, this will be |
| 4109 |
<filename>/usr/local/etc/dhcpd.conf.sample</filename>, and you |
| 4110 |
should copy this to |
| 4111 |
<filename>/usr/local/etc/dhcpd.conf</filename> before proceeding |
| 4112 |
to make changes.</para> |
| 4113 |
</sect3> |
| 4114 |
|
| 4115 |
<sect3> |
| 4116 |
<title>Configuring the DHCP Server</title> |
| 4117 |
<indexterm> |
| 4118 |
<primary>DHCP</primary> |
| 4119 |
<secondary>dhcpd.conf</secondary> |
| 4120 |
</indexterm> |
| 4121 |
<para><filename>dhcpd.conf</filename> is |
| 4122 |
comprised of declarations regarding subnets and hosts, and is |
| 4123 |
perhaps most easily explained using an example :</para> |
| 4124 |
|
| 4125 |
<programlisting>option domain-name "example.com";<co id="domain-name"> |
| 4126 |
option domain-name-servers 192.168.4.100;<co id="domain-name-servers"> |
| 4127 |
option subnet-mask 255.255.255.0;<co id="subnet-mask"> |
| 4128 |
|
| 4129 |
default-lease-time 3600;<co id="default-lease-time"> |
| 4130 |
max-lease-time 86400;<co id="max-lease-time"> |
| 4131 |
ddns-update-style none;<co id="ddns-update-style"> |
| 4132 |
|
| 4133 |
subnet 192.168.4.0 netmask 255.255.255.0 { |
| 4134 |
range 192.168.4.129 192.168.4.254;<co id="range"> |
| 4135 |
option routers 192.168.4.1;<co id="routers"> |
| 4136 |
} |
| 4137 |
|
| 4138 |
host mailhost { |
| 4139 |
hardware ethernet 02:03:04:05:06:07;<co id="hardware"> |
| 4140 |
fixed-address mailhost.example.com;<co id="fixed-address"> |
| 4141 |
}</programlisting> |
| 4142 |
|
| 4143 |
<calloutlist> |
| 4144 |
<callout arearefs="domain-name"> |
| 4145 |
<para>This option specifies the domain that will be provided |
| 4146 |
to clients as the default search domain. See |
| 4147 |
&man.resolv.conf.5; for more information on what this |
| 4148 |
means.</para> |
| 4149 |
</callout> |
| 4150 |
|
| 4151 |
<callout arearefs="domain-name-servers"> |
| 4152 |
<para>This option specifies a comma separated list of DNS |
| 4153 |
servers that the client should use.</para> |
| 4154 |
</callout> |
| 4155 |
|
| 4156 |
<callout arearefs="subnet-mask"> |
| 4157 |
<para>The netmask that will be provided to clients.</para> |
| 4158 |
</callout> |
| 4159 |
|
| 4160 |
<callout arearefs="default-lease-time"> |
| 4161 |
<para>A client may request a specific length of time that a |
| 4162 |
lease will be valid. Otherwise the server will assign |
| 4163 |
a lease with this expiry value (in seconds).</para> |
| 4164 |
</callout> |
| 4165 |
|
| 4166 |
<callout arearefs="max-lease-time"> |
| 4167 |
<para>This is the maximum length of time that the server will |
| 4168 |
lease for. Should a client request a longer lease, a lease |
| 4169 |
will be issued, although it will only be valid for |
| 4170 |
<literal>max-lease-time</literal> seconds.</para> |
| 4171 |
</callout> |
| 4172 |
|
| 4173 |
<callout arearefs="ddns-update-style"> |
| 4174 |
<para>This option specifies whether the DHCP server should |
| 4175 |
attempt to update DNS when a lease is accepted or released. |
| 4176 |
In the ISC implementation, this option is |
| 4177 |
<emphasis>required</emphasis>.</para> |
| 4178 |
</callout> |
| 4179 |
|
| 4180 |
<callout arearefs="range"> |
| 4181 |
<para>This denotes which IP addresses should be used in |
| 4182 |
the pool reserved for allocating to clients. IP |
| 4183 |
addresses between, and including, the ones stated are |
| 4184 |
handed out to clients.</para> |
| 4185 |
</callout> |
| 4186 |
|
| 4187 |
<callout arearefs="routers"> |
| 4188 |
<para>Declares the default gateway that will be provided to |
| 4189 |
clients.</para> |
| 4190 |
</callout> |
| 4191 |
|
| 4192 |
<callout arearefs="hardware"> |
| 4193 |
<para>The hardware MAC address of a host (so that the DHCP server |
| 4194 |
can recognize a host when it makes a request).</para> |
| 4195 |
</callout> |
| 4196 |
|
| 4197 |
<callout arearefs="fixed-address"> |
| 4198 |
<para>Specifies that the host should always be given the same |
| 4199 |
IP address. Note that a hostname is OK here, since the DHCP |
| 4200 |
server will resolve the hostname itself before returning the |
| 4201 |
lease information.</para> |
| 4202 |
</callout> |
| 4203 |
</calloutlist> |
| 4204 |
|
| 4205 |
<para>Once you have finished writing your |
| 4206 |
<filename>dhcpd.conf</filename>, you can proceed to start the |
| 4207 |
server by issuing the following command:</para> |
| 4208 |
|
| 4209 |
<screen>&prompt.root; <userinput>/usr/local/etc/rc.d/isc-dhcpd.sh start</userinput></screen> |
| 4210 |
|
| 4211 |
<para>Should you need to make changes to the configuration of your |
| 4212 |
server in the future, it is important to note that sending a |
| 4213 |
<literal>SIGHUP</literal> signal to |
| 4214 |
<application>dhcpd</application> does <emphasis>not</emphasis> |
| 4215 |
result in the configuration being reloaded, as it does with most |
| 4216 |
daemons. You will need to send a <literal>SIGTERM</literal> |
| 4217 |
signal to stop the process, and then restart it using the command |
| 4218 |
above.</para> |
| 4219 |
</sect3> |
| 4220 |
|
| 4221 |
<sect3> |
| 4222 |
<title>Files</title> |
| 4223 |
<indexterm> |
| 4224 |
<primary>DHCP</primary> |
| 4225 |
<secondary>configuration files</secondary> |
| 4226 |
</indexterm> |
| 4227 |
<itemizedlist> |
| 4228 |
<listitem><para><filename>/usr/local/sbin/dhcpd</filename></para> |
| 4229 |
<para><application>dhcpd</application> is statically linked and |
| 4230 |
resides in <filename>/usr/local/sbin</filename>. The |
| 4231 |
dhcpd(8) manual page installed with the |
| 4232 |
port gives more information about |
| 4233 |
<application>dhcpd</application>.</para> |
| 4234 |
</listitem> |
| 4235 |
|
| 4236 |
<listitem><para><filename>/usr/local/etc/dhcpd.conf</filename></para> |
| 4237 |
<para><application>dhcpd</application> requires a configuration |
| 4238 |
file, <filename>/usr/local/etc/dhcpd.conf</filename> before it |
| 4239 |
will start providing service to clients. This file needs to |
| 4240 |
contain all the information that should be provided to clients |
| 4241 |
that are being serviced, along with information regarding the |
| 4242 |
operation of the server. This configuration file is described |
| 4243 |
by the dhcpd.conf(5) manual page installed |
| 4244 |
by the port.</para> |
| 4245 |
</listitem> |
| 4246 |
|
| 4247 |
<listitem><para><filename>/var/db/dhcpd.leases</filename></para> |
| 4248 |
<para>The DHCP server keeps a database of leases it has issued |
| 4249 |
in this file, which is written as a log. The manual page |
| 4250 |
dhcpd.leases(5), installed by the port |
| 4251 |
gives a slightly longer description.</para> |
| 4252 |
</listitem> |
| 4253 |
|
| 4254 |
<listitem><para><filename>/usr/local/sbin/dhcrelay</filename></para> |
| 4255 |
<para><application>dhcrelay</application> is used in advanced |
| 4256 |
environments where one DHCP server forwards a request from a |
| 4257 |
client to another DHCP server on a separate network. The |
| 4258 |
dhcrelay(8) manual page provided with the |
| 4259 |
port contains more detail.</para> |
| 4260 |
</listitem> |
| 4261 |
</itemizedlist> |
| 4262 |
</sect3> |
| 4263 |
|
| 4264 |
</sect2> |
| 4265 |
|
| 4266 |
</sect1> |
| 4267 |
|
| 4268 |
<sect1 id="network-dns"> |
| 4269 |
<sect1info> |
| 4270 |
<authorgroup> |
| 4271 |
<author> |
| 4272 |
<firstname>Chern</firstname> |
| 4273 |
<surname>Lee</surname> |
| 4274 |
<contrib>Contributed by </contrib> |
| 4275 |
</author> |
| 4276 |
</authorgroup> |
| 4277 |
</sect1info> |
| 4278 |
<title>DNS</title> |
| 4279 |
|
| 4280 |
<sect2> |
| 4281 |
<title>Overview</title> |
| 4282 |
<indexterm><primary>BIND</primary></indexterm> |
| 4283 |
|
| 4284 |
<para>FreeBSD utilizes, by default, a version of BIND (Berkeley |
| 4285 |
Internet Name Domain), which is the most common implementation of the |
| 4286 |
DNS protocol. DNS is the protocol through which names are mapped to |
| 4287 |
IP addresses, and vice versa. For example, a query for |
| 4288 |
<hostid>www.FreeBSD.org</hostid> |
| 4289 |
will receive a reply with the IP address of The FreeBSD Project's |
| 4290 |
web server, whereas, a query for <hostid>ftp.FreeBSD.org</hostid> |
| 4291 |
will return the IP |
| 4292 |
address of the corresponding FTP machine. Likewise, the opposite can |
| 4293 |
happen. A query for an IP address can resolve its hostname. It is |
| 4294 |
not necessary to run a name server to perform DNS lookups on a system. |
| 4295 |
</para> |
| 4296 |
|
| 4297 |
<indexterm><primary>DNS</primary></indexterm> |
| 4298 |
<para>DNS is coordinated across the Internet through a somewhat |
| 4299 |
complex system of authoritative root name servers, and other |
| 4300 |
smaller-scale name servers who host and cache individual domain |
| 4301 |
information. |
| 4302 |
</para> |
| 4303 |
|
| 4304 |
<para> |
| 4305 |
This document refers to BIND 8.x, as it is the stable version |
| 4306 |
used in FreeBSD. BIND 9.x in FreeBSD can be installed through |
| 4307 |
the <filename role="package">net/bind9</filename> port. |
| 4308 |
</para> |
| 4309 |
|
| 4310 |
<para> |
| 4311 |
RFC1034 and RFC1035 dictate the DNS protocol. |
| 4312 |
</para> |
| 4313 |
|
| 4314 |
<para> |
| 4315 |
Currently, BIND is maintained by the <ulink |
| 4316 |
url="http://www.isc.org/"> |
| 4317 |
Internet Software Consortium (www.isc.org)</ulink> |
| 4318 |
</para> |
| 4319 |
</sect2> |
| 4320 |
|
| 4321 |
<sect2> |
| 4322 |
<title>Terminology</title> |
| 4323 |
|
| 4324 |
<para>To understand this document, some terms related to DNS must be |
| 4325 |
understood.</para> |
| 4326 |
|
| 4327 |
<informaltable frame="none"> |
| 4328 |
<tgroup cols="2"> |
| 4329 |
<thead> |
| 4330 |
<row> |
| 4331 |
<entry>Term</entry> |
| 4332 |
<entry>Definition</entry> |
| 4333 |
</row> |
| 4334 |
</thead> |
| 4335 |
|
| 4336 |
<tbody> |
| 4337 |
<row> |
| 4338 |
<entry>forward DNS</entry> |
| 4339 |
<entry>mapping of hostnames to IP addresses</entry> |
| 4340 |
</row> |
| 4341 |
|
| 4342 |
<row> |
| 4343 |
<entry>origin</entry> |
| 4344 |
<entry>refers to the domain covered for the particular zone |
| 4345 |
file</entry> |
| 4346 |
</row> |
| 4347 |
|
| 4348 |
<row> |
| 4349 |
<entry>named, bind, name server</entry> |
| 4350 |
<entry>common names for the BIND name server package within |
| 4351 |
FreeBSD</entry> |
| 4352 |
</row> |
| 4353 |
|
| 4354 |
<indexterm><primary>resolver</primary></indexterm> |
| 4355 |
<row> |
| 4356 |
<entry>resolver</entry> |
| 4357 |
<entry>a system process through which a |
| 4358 |
machine queries a name server for zone information</entry> |
| 4359 |
</row> |
| 4360 |
|
| 4361 |
<indexterm><primary>reverse DNS</primary></indexterm> |
| 4362 |
<row> |
| 4363 |
<entry>reverse DNS</entry> |
| 4364 |
<entry>the opposite of forward DNS, mapping of IP addresses to |
| 4365 |
hostnames</entry> |
| 4366 |
</row> |
| 4367 |
|
| 4368 |
<indexterm><primary>root zone</primary></indexterm> |
| 4369 |
<row> |
| 4370 |
<entry>root zone</entry> |
| 4371 |
|
| 4372 |
<entry>literally, a <quote>.</quote>, refers to the |
| 4373 |
root, or beginning zone. All zones fall under this, as |
| 4374 |
do all files in fall under the root directory. It is |
| 4375 |
the beginning of the Internet zone hierarchy.</entry> |
| 4376 |
</row> |
| 4377 |
|
| 4378 |
<row> |
| 4379 |
<entry>zone</entry> |
| 4380 |
<entry>Each individual domain, subdomain, or area dictated by |
| 4381 |
DNS</entry> |
| 4382 |
</row> |
| 4383 |
</tbody> |
| 4384 |
</tgroup> |
| 4385 |
</informaltable> |
| 4386 |
|
| 4387 |
<indexterm> |
| 4388 |
<primary>zones</primary> |
| 4389 |
<secondary>examples</secondary> |
| 4390 |
</indexterm> |
| 4391 |
|
| 4392 |
<para>Examples of zones: |
| 4393 |
</para> |
| 4394 |
<itemizedlist> |
| 4395 |
<listitem> |
| 4396 |
<para>. is the root zone</para> |
| 4397 |
</listitem> |
| 4398 |
<listitem> |
| 4399 |
<para><hostid>org.</hostid> is a zone under the root zone</para> |
| 4400 |
</listitem> |
| 4401 |
<listitem> |
| 4402 |
<para><hostid>example.org</hostid> is a zone under the |
| 4403 |
org. zone</para> |
| 4404 |
</listitem> |
| 4405 |
<listitem> |
| 4406 |
<para><hostid>foo.example.org.</hostid> is a subdomain, a |
| 4407 |
zone under the <hostid>example.org.</hostid> zone</para> |
| 4408 |
</listitem> |
| 4409 |
<listitem> |
| 4410 |
<para> |
| 4411 |
<hostid>1.2.3.in-addr.arpa</hostid> is a zone referencing |
| 4412 |
all IP addresses which fall under the 3.2.1.* IP space. |
| 4413 |
</para> |
| 4414 |
</listitem> |
| 4415 |
</itemizedlist> |
| 4416 |
|
| 4417 |
<para>As one can see, the more specific part of a hostname appears to |
| 4418 |
its left. For example, <hostid>example.org.</hostid> is more |
| 4419 |
specific than <hostid>org.</hostid>, as <hostid>org.</hostid> is |
| 4420 |
more specific than the root zone. The layout of each part of |
| 4421 |
a hostname is much like a filesystem: the <filename>/dev</filename> |
| 4422 |
directory falls within the root, and so on.</para> |
| 4423 |
|
| 4424 |
|
| 4425 |
</sect2> |
| 4426 |
|
| 4427 |
<sect2> |
| 4428 |
<title>Reasons to Run a Name Server</title> |
| 4429 |
|
| 4430 |
<para>Name servers usually come in two forms: an authoritative |
| 4431 |
name server, and a caching name server.</para> |
| 4432 |
|
| 4433 |
<para>An authoritative name server is needed when:</para> |
| 4434 |
|
| 4435 |
<itemizedlist> |
| 4436 |
<listitem> |
| 4437 |
<para>one wants to serve DNS information to the |
| 4438 |
world, replying authoritatively to queries.</para> |
| 4439 |
</listitem> |
| 4440 |
<listitem> |
| 4441 |
<para>a domain, such as <hostid>example.org</hostid>, is |
| 4442 |
registered and IP addresses need to be assigned to hostnames |
| 4443 |
under it.</para> |
| 4444 |
</listitem> |
| 4445 |
<listitem> |
| 4446 |
<para>an IP address block requires reverse DNS entries (IP to |
| 4447 |
hostname).</para> |
| 4448 |
</listitem> |
| 4449 |
<listitem> |
| 4450 |
<para>a backup name server, called a slave, must reply to queries |
| 4451 |
when the primary is down or inaccessible.</para> |
| 4452 |
</listitem> |
| 4453 |
</itemizedlist> |
| 4454 |
|
| 4455 |
<para>A caching name server is needed when:</para> |
| 4456 |
|
| 4457 |
<itemizedlist> |
| 4458 |
<listitem> |
| 4459 |
<para>a local DNS server may cache and respond more quickly |
| 4460 |
than querying an outside name server.</para> |
| 4461 |
</listitem> |
| 4462 |
<listitem> |
| 4463 |
<para>a reduction in overall network traffic is desired (DNS |
| 4464 |
traffic has been measured to account for 5% or more of total |
| 4465 |
Internet traffic).</para> |
| 4466 |
</listitem> |
| 4467 |
</itemizedlist> |
| 4468 |
|
| 4469 |
<para>When one queries for <hostid>www.FreeBSD.org</hostid>, the |
| 4470 |
resolver usually queries the uplink ISP's name server, and retrieves |
| 4471 |
the reply. With a local, caching DNS server, the query only has to |
| 4472 |
be made once to the outside world by the caching DNS server. Every |
| 4473 |
additional query will not have to look to the outside of the local |
| 4474 |
network, since the information is cached locally.</para> |
| 4475 |
|
| 4476 |
</sect2> |
| 4477 |
|
| 4478 |
<sect2> |
| 4479 |
<title>How It Works</title> |
| 4480 |
<para>In FreeBSD, the BIND daemon is called |
| 4481 |
<application>named</application> for obvious reasons.</para> |
| 4482 |
|
| 4483 |
<informaltable frame="none"> |
| 4484 |
<tgroup cols="2"> |
| 4485 |
<thead> |
| 4486 |
<row> |
| 4487 |
<entry>File</entry> |
| 4488 |
<entry>Description</entry> |
| 4489 |
</row> |
| 4490 |
</thead> |
| 4491 |
|
| 4492 |
<tbody> |
| 4493 |
<row> |
| 4494 |
<entry><application>named</application></entry> |
| 4495 |
<entry>the BIND daemon</entry> |
| 4496 |
</row> |
| 4497 |
|
| 4498 |
<row> |
| 4499 |
<entry><command>ndc</command></entry> |
| 4500 |
<entry>name daemon control program</entry> |
| 4501 |
</row> |
| 4502 |
|
| 4503 |
<row> |
| 4504 |
<entry><filename>/etc/namedb</filename></entry> |
| 4505 |
<entry>directory where BIND zone information resides</entry> |
| 4506 |
</row> |
| 4507 |
|
| 4508 |
<row> |
| 4509 |
<entry><filename>/etc/namedb/named.conf</filename></entry> |
| 4510 |
<entry>daemon configuration file</entry> |
| 4511 |
</row> |
| 4512 |
</tbody> |
| 4513 |
</tgroup> |
| 4514 |
</informaltable> |
| 4515 |
|
| 4516 |
<para> |
| 4517 |
Zone files are usually contained within the |
| 4518 |
<filename>/etc/namedb</filename> |
| 4519 |
directory, and contain the DNS zone information |
| 4520 |
served by the name server. |
| 4521 |
</para> |
| 4522 |
</sect2> |
| 4523 |
|
| 4524 |
<sect2> |
| 4525 |
<title>Starting BIND</title> |
| 4526 |
<indexterm> |
| 4527 |
<primary>BIND</primary> |
| 4528 |
<secondary>starting</secondary> |
| 4529 |
</indexterm> |
| 4530 |
<para> |
| 4531 |
Since BIND is installed by default, configuring it all is |
| 4532 |
relatively simple. |
| 4533 |
</para> |
| 4534 |
<para> |
| 4535 |
To ensure the named daemon is started at boot, put the following |
| 4536 |
modifications in <filename>/etc/rc.conf</filename>: |
| 4537 |
</para> |
| 4538 |
<programlisting>named_enable="YES"</programlisting> |
| 4539 |
<para>To start the daemon manually (after configuring it)</para> |
| 4540 |
<screen>&prompt.root; <userinput>ndc start</userinput></screen> |
| 4541 |
</sect2> |
| 4542 |
|
| 4543 |
<sect2> |
| 4544 |
<title>Configuration Files</title> |
| 4545 |
<indexterm> |
| 4546 |
<primary>BIND</primary> |
| 4547 |
<secondary>configuration files</secondary> |
| 4548 |
</indexterm> |
| 4549 |
<sect3> |
| 4550 |
<title>Using <command>make-localhost</command></title> |
| 4551 |
<para>Be sure to: |
| 4552 |
</para> |
| 4553 |
<screen>&prompt.root; <userinput>cd /etc/namedb</userinput> |
| 4554 |
&prompt.root; <userinput>sh make-localhost</userinput></screen> |
| 4555 |
<para>to properly create the local reverse DNS zone file in |
| 4556 |
<filename>/etc/namedb/localhost.rev</filename>. |
| 4557 |
</para> |
| 4558 |
</sect3> |
| 4559 |
|
| 4560 |
<sect3> |
| 4561 |
<title><filename>/etc/namedb/named.conf</filename></title> |
| 4562 |
|
| 4563 |
<programlisting>// $FreeBSD$ |
| 4564 |
// |
| 4565 |
// Refer to the named(8) manual page for details. If you are ever going |
| 4566 |
// to setup a primary server, make sure you've understood the hairy |
| 4567 |
// details of how DNS is working. Even with simple mistakes, you can |
| 4568 |
// break connectivity for affected parties, or cause huge amount of |
| 4569 |
// useless Internet traffic. |
| 4570 |
|
| 4571 |
options { |
| 4572 |
directory "/etc/namedb"; |
| 4573 |
|
| 4574 |
// In addition to the "forwarders" clause, you can force your name |
| 4575 |
// server to never initiate queries of its own, but always ask its |
| 4576 |
// forwarders only, by enabling the following line: |
| 4577 |
// |
| 4578 |
// forward only; |
| 4579 |
|
| 4580 |
// If you've got a DNS server around at your upstream provider, enter |
| 4581 |
// its IP address here, and enable the line below. This will make you |
| 4582 |
// benefit from its cache, thus reduce overall DNS traffic in the |
| 4583 |
Internet. |
| 4584 |
/* |
| 4585 |
forwarders { |
| 4586 |
127.0.0.1; |
| 4587 |
}; |
| 4588 |
*/</programlisting> |
| 4589 |
|
| 4590 |
<para> |
| 4591 |
Just as the comment says, to benefit from an uplink's cache, |
| 4592 |
<literal>forwarders</literal> can be enabled here. Under normal |
| 4593 |
circumstances, a name server will recursively query the Internet |
| 4594 |
looking at certain name servers until it finds the answer it is |
| 4595 |
looking for. Having this enabled will have it query the uplink's |
| 4596 |
name server (or name server provided) first, taking advantage of |
| 4597 |
its cache. If the uplink name server in question is a heavily |
| 4598 |
trafficked, fast name server, enabling this may be worthwhile. |
| 4599 |
</para> |
| 4600 |
|
| 4601 |
<warning><para><hostid role="ipaddr">127.0.0.1</hostid> |
| 4602 |
will <emphasis>not</emphasis> work here. |
| 4603 |
Change this IP address to a name server at your uplink.</para> |
| 4604 |
</warning> |
| 4605 |
|
| 4606 |
<programlisting> /* |
| 4607 |
* If there is a firewall between you and name servers you want |
| 4608 |
* to talk to, you might need to uncomment the query-source |
| 4609 |
* directive below. Previous versions of BIND always asked |
| 4610 |
* questions using port 53, but BIND 8.1 uses an unprivileged |
| 4611 |
* port by default. |
| 4612 |
*/ |
| 4613 |
// query-source address * port 53; |
| 4614 |
|
| 4615 |
/* |
| 4616 |
* If running in a sandbox, you may have to specify a different |
| 4617 |
* location for the dumpfile. |
| 4618 |
*/ |
| 4619 |
// dump-file "s/named_dump.db"; |
| 4620 |
}; |
| 4621 |
|
| 4622 |
// Note: the following will be supported in a future release. |
| 4623 |
/* |
| 4624 |
host { any; } { |
| 4625 |
topology { |
| 4626 |
127.0.0.0/8; |
| 4627 |
}; |
| 4628 |
}; |
| 4629 |
*/ |
| 4630 |
|
| 4631 |
// Setting up secondaries is way easier and the rough picture for this |
| 4632 |
// is explained below. |
| 4633 |
// |
| 4634 |
// If you enable a local name server, don't forget to enter 127.0.0.1 |
| 4635 |
// into your /etc/resolv.conf so this server will be queried first. |
| 4636 |
// Also, make sure to enable it in /etc/rc.conf. |
| 4637 |
|
| 4638 |
zone "." { |
| 4639 |
type hint; |
| 4640 |
file "named.root"; |
| 4641 |
}; |
| 4642 |
|
| 4643 |
zone "0.0.127.IN-ADDR.ARPA" { |
| 4644 |
type master; |
| 4645 |
file "localhost.rev"; |
| 4646 |
}; |
| 4647 |
|
| 4648 |
zone |
| 4649 |
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" { |
| 4650 |
type master; |
| 4651 |
file "localhost.rev"; |
| 4652 |
}; |
| 4653 |
|
| 4654 |
// NB: Do not use the IP addresses below, they are faked, and only |
| 4655 |
// serve demonstration/documentation purposes! |
| 4656 |
// |
| 4657 |
// Example secondary config entries. It can be convenient to become |
| 4658 |
// a secondary at least for the zone where your own domain is in. Ask |
| 4659 |
// your network administrator for the IP address of the responsible |
| 4660 |
// primary. |
| 4661 |
// |
| 4662 |
// Never forget to include the reverse lookup (IN-ADDR.ARPA) zone! |
| 4663 |
// (This is the first bytes of the respective IP address, in reverse |
| 4664 |
// order, with ".IN-ADDR.ARPA" appended.) |
| 4665 |
// |
| 4666 |
// Before starting to setup a primary zone, better make sure you fully |
| 4667 |
// understand how DNS and BIND works, however. There are sometimes |
| 4668 |
// unobvious pitfalls. Setting up a secondary is comparably simpler. |
| 4669 |
// |
| 4670 |
// NB: Don't blindly enable the examples below. :-) Use actual names |
| 4671 |
// and addresses instead. |
| 4672 |
// |
| 4673 |
// NOTE!!! FreeBSD runs bind in a sandbox (see named_flags in rc.conf). |
| 4674 |
// The directory containing the secondary zones must be write accessible |
| 4675 |
// to bind. The following sequence is suggested: |
| 4676 |
// |
| 4677 |
// mkdir /etc/namedb/s |
| 4678 |
// chown bind:bind /etc/namedb/s |
| 4679 |
// chmod 750 /etc/namedb/s</programlisting> |
| 4680 |
|
| 4681 |
<para>For more information on running BIND in a sandbox, see |
| 4682 |
<link linkend="network-named-sandbox">Running named in a sandbox</link>. |
| 4683 |
</para> |
| 4684 |
|
| 4685 |
<programlisting>/* |
| 4686 |
zone "example.com" { |
| 4687 |
type slave; |
| 4688 |
file "s/example.com.bak"; |
| 4689 |
masters { |
| 4690 |
192.168.1.1; |
| 4691 |
}; |
| 4692 |
}; |
| 4693 |
|
| 4694 |
zone "0.168.192.in-addr.arpa" { |
| 4695 |
type slave; |
| 4696 |
file "s/0.168.192.in-addr.arpa.bak"; |
| 4697 |
masters { |
| 4698 |
192.168.1.1; |
| 4699 |
}; |
| 4700 |
}; |
| 4701 |
*/</programlisting> |
| 4702 |
<para>In <filename>named.conf</filename>, these are examples of slave |
| 4703 |
entries for a forward and reverse zone.</para> |
| 4704 |
|
| 4705 |
<para>For each new zone served, a new zone entry must be added to |
| 4706 |
<filename>named.conf</filename></para> |
| 4707 |
|
| 4708 |
<para>For example, the simplest zone entry for |
| 4709 |
<hostid role="domainname">example.org</hostid> can look like:</para> |
| 4710 |
|
| 4711 |
<programlisting>zone "example.org" { |
| 4712 |
type master; |
| 4713 |
file "example.org"; |
| 4714 |
};</programlisting> |
| 4715 |
|
| 4716 |
<para>The zone is a master, as indicated by the <option>type</option> |
| 4717 |
statement, holding its zone information in |
| 4718 |
<filename>/etc/namedb/example.org</filename> indicated by |
| 4719 |
the <option>file</option> statement.</para> |
| 4720 |
|
| 4721 |
<programlisting>zone "example.org" { |
| 4722 |
type slave; |
| 4723 |
file "example.org"; |
| 4724 |
};</programlisting> |
| 4725 |
|
| 4726 |
<para>In the slave case, the zone information is transferred from |
| 4727 |
the master name server for the particular zone, and saved in the |
| 4728 |
file specified. If and when the master server dies or is |
| 4729 |
unreachable, the slave name server will have the transferred |
| 4730 |
zone information and will be able to serve it.</para> |
| 4731 |
</sect3> |
| 4732 |
|
| 4733 |
<sect3> |
| 4734 |
<title>Zone Files</title> |
| 4735 |
<para> |
| 4736 |
An example master zone file for <hostid>example.org</hostid> |
| 4737 |
(existing within <filename>/etc/namedb/example.org</filename>) |
| 4738 |
is as follows: |
| 4739 |
</para> |
| 4740 |
|
| 4741 |
<programlisting>$TTL 3600 |
| 4742 |
|
| 4743 |
example.org. IN SOA ns1.example.org. admin.example.org. ( |
| 4744 |
5 ; Serial |
| 4745 |
10800 ; Refresh |
| 4746 |
3600 ; Retry |
| 4747 |
604800 ; Expire |
| 4748 |
86400 ) ; Minimum TTL |
| 4749 |
|
| 4750 |
; DNS Servers |
| 4751 |
@ IN NS ns1.example.org. |
| 4752 |
@ IN NS ns2.example.org. |
| 4753 |
|
| 4754 |
; Machine Names |
| 4755 |
localhost IN A 127.0.0.1 |
| 4756 |
ns1 IN A 3.2.1.2 |
| 4757 |
ns2 IN A 3.2.1.3 |
| 4758 |
mail IN A 3.2.1.10 |
| 4759 |
@ IN A 3.2.1.30 |
| 4760 |
|
| 4761 |
; Aliases |
| 4762 |
www IN CNAME @ |
| 4763 |
|
| 4764 |
; MX Record |
| 4765 |
@ IN MX 10 mail.example.org.</programlisting> |
| 4766 |
|
| 4767 |
<para> |
| 4768 |
Note that every hostname ending in a <quote>.</quote> is an |
| 4769 |
exact hostname, whereas everything without a trailing |
| 4770 |
<quote>.</quote> is referenced to the origin. For example, |
| 4771 |
<literal>www</literal> is translated into <literal>www + |
| 4772 |
origin</literal>. In our fictitious zone file, our origin |
| 4773 |
is <hostid>example.org.</hostid>, so |
| 4774 |
<literal>www</literal> would translate to |
| 4775 |
<hostid>www.example.org.</hostid> |
| 4776 |
</para> |
| 4777 |
|
| 4778 |
<para> |
| 4779 |
The format of a zone file follows: |
| 4780 |
</para> |
| 4781 |
<programlisting>recordname IN recordtype value</programlisting> |
| 4782 |
|
| 4783 |
<indexterm> |
| 4784 |
<primary>DNS</primary> |
| 4785 |
<secondary>records</secondary> |
| 4786 |
</indexterm> |
| 4787 |
<para> |
| 4788 |
The most commonly used DNS records: |
| 4789 |
</para> |
| 4790 |
|
| 4791 |
<variablelist> |
| 4792 |
<varlistentry> |
| 4793 |
<term>SOA</term> |
| 4794 |
|
| 4795 |
<listitem><para>start of zone authority</para></listitem> |
| 4796 |
</varlistentry> |
| 4797 |
|
| 4798 |
<varlistentry> |
| 4799 |
<term>NS</term> |
| 4800 |
|
| 4801 |
<listitem><para>an authoritative name server</para></listitem> |
| 4802 |
</varlistentry> |
| 4803 |
|
| 4804 |
<varlistentry> |
| 4805 |
<term>A</term> |
| 4806 |
|
| 4807 |
<listitem><para>A host address</para></listitem> |
| 4808 |
</varlistentry> |
| 4809 |
|
| 4810 |
<varlistentry> |
| 4811 |
<term>CNAME</term> |
| 4812 |
|
| 4813 |
<listitem><para>the canonical name for an alias</para></listitem> |
| 4814 |
</varlistentry> |
| 4815 |
|
| 4816 |
<varlistentry> |
| 4817 |
<term>MX</term> |
| 4818 |
|
| 4819 |
<listitem><para>mail exchanger</para></listitem> |
| 4820 |
</varlistentry> |
| 4821 |
|
| 4822 |
<varlistentry> |
| 4823 |
<term>PTR</term> |
| 4824 |
|
| 4825 |
<listitem><para>a domain name pointer (used in reverse DNS) |
| 4826 |
</para></listitem> |
| 4827 |
</varlistentry> |
| 4828 |
</variablelist> |
| 4829 |
|
| 4830 |
<programlisting> |
| 4831 |
example.org. IN SOA ns1.example.org. admin.example.org. ( |
| 4832 |
5 ; Serial |
| 4833 |
10800 ; Refresh after 3 hours |
| 4834 |
3600 ; Retry after 1 hour |
| 4835 |
604800 ; Expire after 1 week |
| 4836 |
86400 ) ; Minimum TTL of 1 day</programlisting> |
| 4837 |
|
| 4838 |
|
| 4839 |
|
| 4840 |
<variablelist> |
| 4841 |
<varlistentry> |
| 4842 |
<term><hostid>example.org.</hostid></term> |
| 4843 |
|
| 4844 |
<listitem><para>the domain name, also the origin for this |
| 4845 |
zone file.</para></listitem> |
| 4846 |
</varlistentry> |
| 4847 |
|
| 4848 |
<varlistentry> |
| 4849 |
<term><hostid>ns1.example.org.</hostid></term> |
| 4850 |
|
| 4851 |
<listitem><para>the primary/authoritative name server for this |
| 4852 |
zone</para></listitem> |
| 4853 |
</varlistentry> |
| 4854 |
|
| 4855 |
<varlistentry> |
| 4856 |
<term><literal>admin.example.org.</literal></term> |
| 4857 |
|
| 4858 |
<listitem><para>the responsible person for this zone, |
| 4859 |
email address with @ |
| 4860 |
replaced. (<email>admin@example.org</email> becomes |
| 4861 |
<literal>admin.example.org</literal>)</para> |
| 4862 |
</listitem> |
| 4863 |
</varlistentry> |
| 4864 |
|
| 4865 |
<varlistentry> |
| 4866 |
<term><literal>5</literal></term> |
| 4867 |
|
| 4868 |
<listitem><para>the serial number of the file. this |
| 4869 |
must be incremented each time the zone file is modified. |
| 4870 |
Nowadays, many admins prefer a |
| 4871 |
<literal>yyyymmddrr</literal> format for the serial |
| 4872 |
number. 2001041002 would mean last modified 04/10/2001, |
| 4873 |
the latter 02 being the second time the zone file has |
| 4874 |
been modified this day. The serial number is important |
| 4875 |
as it alerts slave name servers for a zone when it is |
| 4876 |
updated.</para> |
| 4877 |
</listitem> |
| 4878 |
</varlistentry> |
| 4879 |
</variablelist> |
| 4880 |
|
| 4881 |
<programlisting> |
| 4882 |
@ IN NS ns1.example.org.</programlisting> |
| 4883 |
|
| 4884 |
<para> |
| 4885 |
This is an <varname>NS</varname> entry. Every name server that is going to reply |
| 4886 |
authoritatively for the zone must have one of these entries. |
| 4887 |
The <literal>@</literal> as seen here could have been |
| 4888 |
<hostid role="domainname">example.org.</hostid> |
| 4889 |
The <literal>@</literal> translates to the origin. |
| 4890 |
</para> |
| 4891 |
|
| 4892 |
<programlisting> |
| 4893 |
localhost IN A 127.0.0.1 |
| 4894 |
ns1 IN A 3.2.1.2 |
| 4895 |
ns2 IN A 3.2.1.3 |
| 4896 |
mail IN A 3.2.1.10 |
| 4897 |
@ IN A 3.2.1.30</programlisting> |
| 4898 |
|
| 4899 |
<para> |
| 4900 |
The A record indicates machine names. As seen above, |
| 4901 |
<hostid>ns1.example.org</hostid> would resolve to |
| 4902 |
<hostid role="ipaddr">3.2.1.2</hostid>. Again, |
| 4903 |
the origin symbol, <literal>@</literal>, is |
| 4904 |
used here, thus meaning <hostid>example.org</hostid> |
| 4905 |
would resolve to <hostid role="ipaddr">3.2.1.30</hostid>. |
| 4906 |
</para> |
| 4907 |
|
| 4908 |
<programlisting> |
| 4909 |
www IN CNAME @</programlisting> |
| 4910 |
|
| 4911 |
<para> |
| 4912 |
The canonical name record is usually used for giving aliases |
| 4913 |
to a machine. In the example, <hostid>www</hostid> is |
| 4914 |
aliased to the machine addressed to the origin, or |
| 4915 |
<hostid>example.org</hostid> |
| 4916 |
(<hostid role="ipaddr">3.2.1.30</hostid>). |
| 4917 |
<varname>CNAME</varname>s can be used to provide alias |
| 4918 |
hostnames, or round robin one hostname among multiple |
| 4919 |
machines. |
| 4920 |
</para> |
| 4921 |
|
| 4922 |
<programlisting> |
| 4923 |
@ IN MX 10 mail.example.org.</programlisting> |
| 4924 |
|
| 4925 |
<para> |
| 4926 |
The <varname>MX</varname> record indicates which mail |
| 4927 |
servers are responsible for handling incoming mail for the |
| 4928 |
zone. <hostid role="fqdn">mail.example.org</hostid> is the |
| 4929 |
hostname of the mail server, and 10 being the priority of |
| 4930 |
that mail server. |
| 4931 |
</para> |
| 4932 |
|
| 4933 |
<para> |
| 4934 |
One can have several mail servers, with priorities of 3, 2, |
| 4935 |
1. A mail server attempting to deliver to <hostid |
| 4936 |
role="domainname">example.org</hostid> would first try the |
| 4937 |
highest priority MX, then the second highest, etc, until the |
| 4938 |
mail can be properly delivered. |
| 4939 |
</para> |
| 4940 |
|
| 4941 |
<para> |
| 4942 |
For in-addr.arpa zone files (reverse DNS), the same format is |
| 4943 |
used, except with <varname>PTR</varname> entries instead of |
| 4944 |
<varname>A</varname> or <varname>CNAME</varname>. |
| 4945 |
</para> |
| 4946 |
|
| 4947 |
<programlisting>$TTL 3600 |
| 4948 |
|
| 4949 |
1.2.3.in-addr.arpa. IN SOA ns1.example.org. admin.example.org. ( |
| 4950 |
5 ; Serial |
| 4951 |
10800 ; Refresh |
| 4952 |
3600 ; Retry |
| 4953 |
604800 ; Expire |
| 4954 |
3600 ) ; Minimum |
| 4955 |
|
| 4956 |
@ IN NS ns1.example.org. |
| 4957 |
@ IN NS ns2.example.org. |
| 4958 |
|
| 4959 |
2 IN PTR ns1.example.org. |
| 4960 |
3 IN PTR ns2.example.org. |
| 4961 |
10 IN PTR mail.example.org. |
| 4962 |
30 IN PTR example.org.</programlisting> |
| 4963 |
<para> |
| 4964 |
This file gives the proper IP address to hostname mappings of our above |
| 4965 |
fictitious domain. |
| 4966 |
</para> |
| 4967 |
</sect3> |
| 4968 |
</sect2> |
| 4969 |
|
| 4970 |
<sect2> |
| 4971 |
<title>Caching Name Server</title> |
| 4972 |
<indexterm> |
| 4973 |
<primary>BIND</primary> |
| 4974 |
<secondary>caching name server</secondary> |
| 4975 |
</indexterm> |
| 4976 |
<para> |
| 4977 |
A caching name server is a name server that is not |
| 4978 |
authoritative for any zones. It simply asks queries of its own, |
| 4979 |
and remembers them for later use. To set one up, just configure |
| 4980 |
the name server as usual, omitting any inclusions of zones. |
| 4981 |
</para> |
| 4982 |
</sect2> |
| 4983 |
|
| 4984 |
<sect2 id="network-named-sandbox"> |
| 4985 |
<title>Running <application>named</application> in a Sandbox</title> |
| 4986 |
<indexterm> |
| 4987 |
<primary>BIND</primary> |
| 4988 |
<secondary>running in a sandbox</secondary> |
| 4989 |
</indexterm> |
| 4990 |
|
| 4991 |
<indexterm> |
| 4992 |
<primary><command>chroot</command></primary> |
| 4993 |
</indexterm> |
| 4994 |
<para>For added security you may want to run &man.named.8; as an |
| 4995 |
unprivileged user, and configure it to &man.chroot.8; into a |
| 4996 |
sandbox directory. This makes everything outside of the sandbox |
| 4997 |
inaccessible to the <application>named</application> daemon. Should |
| 4998 |
<application>named</application> be compromised, this will help to |
| 4999 |
reduce the damage that can be caused. By default, FreeBSD has a user |
| 5000 |
and a group called <groupname>bind</groupname>, intended for this |
| 5001 |
use.</para> |
| 5002 |
|
| 5003 |
<note><para>Various people would recommend that instead of configuring |
| 5004 |
<application>named</application> to <command>chroot</command>, you |
| 5005 |
should run <application>named</application> inside a &man.jail.8;. |
| 5006 |
This section does not attempt to cover this situation.</para> |
| 5007 |
</note> |
| 5008 |
|
| 5009 |
<para>Since <application>named</application> will not be able to |
| 5010 |
access anything outside of the sandbox (such as shared |
| 5011 |
libraries, log sockets, and so on), there are a number of steps |
| 5012 |
that need to be followed in order to allow |
| 5013 |
<application>named</application> to function correctly. In the |
| 5014 |
following checklist, it is assumed that the path to the sandbox |
| 5015 |
is <filename>/etc/namedb</filename> and that you have made no |
| 5016 |
prior modifications to the contents of this directory. Perform |
| 5017 |
the following steps as <username>root</username>.</para> |
| 5018 |
|
| 5019 |
<itemizedlist> |
| 5020 |
<listitem> |
| 5021 |
<para>Create all directories that <application>named</application> |
| 5022 |
expects to see:</para> |
| 5023 |
|
| 5024 |
<screen>&prompt.root; <userinput>cd /etc/namedb</userinput> |
| 5025 |
&prompt.root; <userinput>mkdir -p bin dev etc var/tmp var/run master slave</userinput> |
| 5026 |
&prompt.root; <userinput>chown bind:bind slave var/*</userinput><co id="chown-slave"></screen> |
| 5027 |
|
| 5028 |
|
| 5029 |
|
| 5030 |
<calloutlist> |
| 5031 |
<callout arearefs="chown-slave"> |
| 5032 |
<para><application>named</application> only needs write access to |
| 5033 |
these directories, so that is all we give it.</para> |
| 5034 |
</callout> |
| 5035 |
</calloutlist> |
| 5036 |
</listitem> |
| 5037 |
|
| 5038 |
<listitem> |
| 5039 |
<para>Rearrange and create basic zone and configuration files:</para> |
| 5040 |
<screen>&prompt.root; <userinput>cp /etc/localtime etc</userinput><co id="localtime"> |
| 5041 |
&prompt.root; <userinput>mv named.conf etc && ln -sf etc/named.conf</userinput> |
| 5042 |
&prompt.root; <userinput>mv named.root master</userinput> |
| 5043 |
<!-- I don't like this next bit --> |
| 5044 |
&prompt.root; <userinput>sh make-localhost && mv localhost.rev localhost-v6.rev master</userinput> |
| 5045 |
&prompt.root; <userinput>cat > master/named.localhost |
| 5046 |
$ORIGIN localhost. |
| 5047 |
$TTL 6h |
| 5048 |
@ IN SOA localhost. postmaster.localhost. ( |
| 5049 |
1 ; serial |
| 5050 |
3600 ; refresh |
| 5051 |
1800 ; retry |
| 5052 |
604800 ; expiration |
| 5053 |
3600 ) ; minimum |
| 5054 |
IN NS localhost. |
| 5055 |
IN A 127.0.0.1 |
| 5056 |
^D</userinput></screen> |
| 5057 |
|
| 5058 |
<calloutlist> |
| 5059 |
<callout arearefs="localtime"> |
| 5060 |
<para>This allows <application>named</application> to log the |
| 5061 |
correct time to &man.syslogd.8;</para> |
| 5062 |
</callout> |
| 5063 |
</calloutlist> |
| 5064 |
</listitem> |
| 5065 |
|
| 5066 |
<listitem> |
| 5067 |
<para>Build a statically linked copy of |
| 5068 |
<application>named-xfer</application>, and copy it into the sandbox:</para> |
| 5069 |
|
| 5070 |
<screen>&prompt.root; <userinput>cd /usr/src/lib/libisc</userinput> |
| 5071 |
&prompt.root; <userinput>make cleandir && make cleandir && make depend && make all</userinput> |
| 5072 |
&prompt.root; <userinput>cd /usr/src/lib/libbind</userinput> |
| 5073 |
&prompt.root; <userinput>make cleandir && make cleandir && make depend && make all</userinput> |
| 5074 |
&prompt.root; <userinput>cd /usr/src/libexec/named-xfer</userinput> |
| 5075 |
&prompt.root; <userinput>make cleandir && make cleandir && make depend && make NOSHARED=yes all</userinput> |
| 5076 |
&prompt.root; <userinput>cp named-xfer /etc/namedb/bin && chmod 555 /etc/namedb/bin/named-xfer</userinput><co id="clean-cruft"></screen> |
| 5077 |
|
| 5078 |
<para>After your statically linked |
| 5079 |
<command>named-xfer</command> is installed some cleaning up |
| 5080 |
is required, to avoid leaving stale copies of libraries or |
| 5081 |
programs in your source tree:</para> |
| 5082 |
|
| 5083 |
<screen>&prompt.root; <userinput>cd /usr/src/lib/libisc</userinput> |
| 5084 |
&prompt.root; <userinput>make cleandir</userinput> |
| 5085 |
&prompt.root; <userinput>cd /usr/src/lib/libbind</userinput> |
| 5086 |
&prompt.root; <userinput>make cleandir</userinput> |
| 5087 |
&prompt.root; <userinput>cd /usr/src/libexec/named-xfer</userinput> |
| 5088 |
&prompt.root; <userinput>make cleandir</userinput></screen> |
| 5089 |
|
| 5090 |
<calloutlist> |
| 5091 |
<callout arearefs="clean-cruft"> |
| 5092 |
<para>This step has been reported to fail occasionally. If this |
| 5093 |
happens to you, then issue the command:</para> |
| 5094 |
|
| 5095 |
<screen>&prompt.root; <userinput>cd /usr/src && make cleandir && make cleandir</userinput></screen> |
| 5096 |
|
| 5097 |
<para>and delete your <filename>/usr/obj</filename> tree:</para> |
| 5098 |
|
| 5099 |
<screen>&prompt.root; <userinput>rm -fr /usr/obj && mkdir /usr/obj</userinput></screen> |
| 5100 |
|
| 5101 |
<para>This will clean out any <quote>cruft</quote> from your |
| 5102 |
source tree, and retrying the steps above should then work.</para> |
| 5103 |
</callout> |
| 5104 |
</calloutlist> |
| 5105 |
</listitem> |
| 5106 |
|
| 5107 |
<listitem> |
| 5108 |
<para>Make a <devicename>dev/null</devicename> that |
| 5109 |
<application>named</application> can see and write to:</para> |
| 5110 |
|
| 5111 |
<screen>&prompt.root; <userinput>cd /etc/namedb/dev && mknod null c 2 2</userinput> |
| 5112 |
&prompt.root; <userinput>chmod 666 null</userinput></screen> |
| 5113 |
</listitem> |
| 5114 |
|
| 5115 |
<listitem> |
| 5116 |
<para>Symlink <filename> /var/run/ndc</filename> to |
| 5117 |
<filename>/etc/namedb/var/run/ndc</filename>:</para> |
| 5118 |
|
| 5119 |
<screen>&prompt.root; <userinput>ln -sf /etc/namedb/var/run/ndc /var/run/ndc</userinput></screen> |
| 5120 |
|
| 5121 |
<note> |
| 5122 |
<para>This simply avoids having to specify the |
| 5123 |
<option>-c</option> option to &man.ndc.8; every time you |
| 5124 |
run it. Since the contents of /var/run are deleted on boot, |
| 5125 |
if this is something that you find useful you |
| 5126 |
may wish to add this command to root's crontab, making use |
| 5127 |
of the <option>@reboot</option> option. See |
| 5128 |
&man.crontab.5; for more information regarding |
| 5129 |
this.</para> |
| 5130 |
</note> |
| 5131 |
|
| 5132 |
</listitem> |
| 5133 |
|
| 5134 |
<listitem> |
| 5135 |
<para>Configure &man.syslogd.8; to create an extra |
| 5136 |
<devicename>log</devicename> socket that |
| 5137 |
<application>named</application> can write to. To do this, |
| 5138 |
add <literal>-l /etc/namedb/dev/log</literal> to the |
| 5139 |
<varname>syslogd_flags</varname> variable in |
| 5140 |
<filename>/etc/rc.conf</filename>.</para> |
| 5141 |
</listitem> |
| 5142 |
|
| 5143 |
<listitem> |
| 5144 |
<para>Arrange to have <application>named</application> start |
| 5145 |
and <command>chroot</command> itself to the sandbox by |
| 5146 |
adding the following to |
| 5147 |
<filename>/etc/rc.conf</filename>:</para> |
| 5148 |
|
| 5149 |
<programlisting>named_enable="YES" |
| 5150 |
named_flags="-u bind -g bind -t /etc/namedb /etc/named.conf"</programlisting> |
| 5151 |
|
| 5152 |
<note> |
| 5153 |
<para>Note that the configuration file |
| 5154 |
<replaceable>/etc/named.conf</replaceable> is denoted by a full |
| 5155 |
pathname <emphasis>relative to the sandbox</emphasis>, i.e. in |
| 5156 |
the line above, the file referred to is actually |
| 5157 |
<filename>/etc/namedb/etc/named.conf</filename>.</para> |
| 5158 |
</note> |
| 5159 |
</listitem> |
| 5160 |
</itemizedlist> |
| 5161 |
|
| 5162 |
<para>The next step is to edit |
| 5163 |
<filename>/etc/namedb/etc/named.conf</filename> so that |
| 5164 |
<application>named</application> knows which zones to load and |
| 5165 |
where to find them on the disk. There follows a commented |
| 5166 |
example (anything not specifically commented here is no |
| 5167 |
different from the setup for a DNS server not running in a |
| 5168 |
sandbox):</para> |
| 5169 |
|
| 5170 |
<programlisting>options { |
| 5171 |
directory "/";<co id="directory"> |
| 5172 |
named-xfer "/bin/named-xfer";<co id="named-xfer"> |
| 5173 |
version ""; // Don't reveal BIND version |
| 5174 |
query-source address * port 53; |
| 5175 |
}; |
| 5176 |
// ndc control socket |
| 5177 |
controls { |
| 5178 |
unix "/var/run/ndc" perm 0600 owner 0 group 0; |
| 5179 |
}; |
| 5180 |
// Zones follow: |
| 5181 |
zone "localhost" IN { |
| 5182 |
type master; |
| 5183 |
file "master/named.localhost";<co id="master"> |
| 5184 |
allow-transfer { localhost; }; |
| 5185 |
notify no; |
| 5186 |
}; |
| 5187 |
zone "0.0.127.in-addr.arpa" IN { |
| 5188 |
type master; |
| 5189 |
file "master/localhost.rev"; |
| 5190 |
allow-transfer { localhost; }; |
| 5191 |
notify no; |
| 5192 |
}; |
| 5193 |
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.int" { |
| 5194 |
type master; |
| 5195 |
file "master/localhost-v6.rev"; |
| 5196 |
allow-transfer { localhost; }; |
| 5197 |
notify no; |
| 5198 |
}; |
| 5199 |
zone "." IN { |
| 5200 |
type hint; |
| 5201 |
file "master/named.root"; |
| 5202 |
}; |
| 5203 |
zone "private.example.net" in { |
| 5204 |
type master; |
| 5205 |
file "master/private.example.net.db"; |
| 5206 |
allow-transfer { 192.168.10.0/24; }; |
| 5207 |
}; |
| 5208 |
zone "10.168.192.in-addr.arpa" in { |
| 5209 |
type slave; |
| 5210 |
masters { 192.168.10.2; }; |
| 5211 |
file "slave/192.168.10.db";<co id="slave"> |
| 5212 |
};</programlisting> |
| 5213 |
|
| 5214 |
<calloutlist> |
| 5215 |
<callout arearefs="directory"> |
| 5216 |
<para>The |
| 5217 |
<literal>directory</literal> statement is specified as |
| 5218 |
<filename>/</filename>, since all files that |
| 5219 |
<application>named</application> needs are within this |
| 5220 |
directory (recall that this is equivalent to a |
| 5221 |
<quote>normal</quote> user's |
| 5222 |
<filename>/etc/namedb</filename>.</para> |
| 5223 |
</callout> |
| 5224 |
|
| 5225 |
<callout arearefs="named-xfer"> |
| 5226 |
<para>Specifies the full path |
| 5227 |
to the <command>named-xfer</command> binary (from |
| 5228 |
<application>named</application>'s frame of reference). This |
| 5229 |
is necessary since <application>named</application> is |
| 5230 |
compiled to look for <command>named-xfer</command> in |
| 5231 |
<filename>/usr/libexec</filename> by default.</para> |
| 5232 |
</callout> |
| 5233 |
<callout arearefs="master"><para>Specifies the filename (relative |
| 5234 |
to the <literal>directory</literal> statement above) where |
| 5235 |
<application>named</application> can find the zonefile for this |
| 5236 |
zone.</para> |
| 5237 |
</callout> |
| 5238 |
<callout arearefs="slave"><para>Specifies the filename |
| 5239 |
(relative to the <literal>directory</literal> statement above) |
| 5240 |
where <application>named</application> should write a copy of |
| 5241 |
the zonefile for this zone after successfully transferring it |
| 5242 |
from the master server. This is why we needed to change the |
| 5243 |
ownership of the directory <filename>slave</filename> to |
| 5244 |
<groupname>bind</groupname> in the setup stages above.</para> |
| 5245 |
</callout> |
| 5246 |
</calloutlist> |
| 5247 |
|
| 5248 |
<para>After completing the steps above, either reboot your |
| 5249 |
server or restart &man.syslogd.8; and start &man.named.8;, making |
| 5250 |
sure to use the new options specified in |
| 5251 |
<varname>syslogd_flags</varname> and |
| 5252 |
<varname>named_flags</varname>. You should now be running a |
| 5253 |
sandboxed copy of <application>named</application>!</para> |
| 5254 |
|
| 5255 |
</sect2> |
| 5256 |
|
| 5257 |
<sect2> |
| 5258 |
<title>Security</title> |
| 5259 |
|
| 5260 |
<para>Although BIND is the most common implementation of DNS, |
| 5261 |
there is always the issue of security. Possible and |
| 5262 |
exploitable security holes are sometimes found. |
| 5263 |
</para> |
| 5264 |
|
| 5265 |
<para> |
| 5266 |
It is a good idea to subscribe to <ulink |
| 5267 |
url="http://www.cert.org/">CERT</ulink> and |
| 5268 |
<ulink url="../handbook/eresources.html#ERESOURCES-MAIL">freebsd-security-notifications</ulink> |
| 5269 |
to stay up to date with the current Internet and FreeBSD security |
| 5270 |
issues. |
| 5271 |
</para> |
| 5272 |
|
| 5273 |
<tip><para>If a problem arises, keeping sources up to date and having a |
| 5274 |
fresh build of named would not hurt.</para></tip> |
| 5275 |
</sect2> |
| 5276 |
|
| 5277 |
<sect2> |
| 5278 |
<title>Further Reading</title> |
| 5279 |
<para> |
| 5280 |
BIND/named manual pages: &man.ndc.8; &man.named.8; &man.named.conf.5; |
| 5281 |
</para> |
| 5282 |
|
| 5283 |
<itemizedlist> |
| 5284 |
<listitem> |
| 5285 |
<para><ulink |
| 5286 |
url="http://www.isc.org/products/BIND/">Official ISC Bind |
| 5287 |
Page</ulink></para> |
| 5288 |
</listitem> |
| 5289 |
|
| 5290 |
<listitem> |
| 5291 |
<para><ulink |
| 5292 |
url="http://www.nominum.com/getOpenSourceResource.php?id=6"> |
| 5293 |
BIND FAQ</ulink></para> |
| 5294 |
</listitem> |
| 5295 |
|
| 5296 |
<listitem> |
| 5297 |
<para><ulink url="http://www.oreilly.com/catalog/dns4/">O'Reilly |
| 5298 |
DNS and BIND 4th Edition</ulink></para> |
| 5299 |
</listitem> |
| 5300 |
|
| 5301 |
<listitem> |
| 5302 |
<para><ulink |
| 5303 |
url="ftp://ftp.isi.edu/in-notes/rfc1034.txt">RFC1034 |
| 5304 |
- Domain Names - Concepts and Facilities</ulink></para> |
| 5305 |
</listitem> |
| 5306 |
|
| 5307 |
<listitem> |
| 5308 |
<para><ulink |
| 5309 |
url="ftp://ftp.isi.edu/in-notes/rfc1035.txt">RFC1035 |
| 5310 |
- Domain Names - Implementation and Specification</ulink></para> |
| 5311 |
</listitem> |
| 5312 |
</itemizedlist> |
| 5313 |
</sect2> |
| 5314 |
</sect1> |
| 5315 |
|
| 5316 |
<sect1 id="network-ntp"> |
| 5317 |
<sect1info> |
| 5318 |
<authorgroup> |
| 5319 |
<author> |
| 5320 |
<firstname>Tom</firstname> |
| 5321 |
<surname>Hukins</surname> |
| 5322 |
<contrib>Contributed by </contrib> |
| 5323 |
</author> |
| 5324 |
</authorgroup> |
| 5325 |
</sect1info> |
| 5326 |
<title>NTP</title> |
| 5327 |
|
| 5328 |
<indexterm><primary>NTP</primary></indexterm> |
| 5329 |
|
| 5330 |
<sect2> |
| 5331 |
<title>Overview</title> |
| 5332 |
|
| 5333 |
<para>Over time, a computer's clock is prone to drift. As time |
| 5334 |
passes, the computer's clock becomes less accurate. NTP |
| 5335 |
(Network Time Protocol) is one way to ensure your clock is |
| 5336 |
right.</para> |
| 5337 |
|
| 5338 |
<para>Many Internet services rely on, or greatly benefit from, |
| 5339 |
computers' clocks being accurate. For example, a Web server |
| 5340 |
may receive requests to send a file if it has modified since a |
| 5341 |
certain time. Services such as &man.cron.8; run commands at a |
| 5342 |
given time. If the clock is inaccurate, these commands may |
| 5343 |
not run when expected.</para> |
| 5344 |
|
| 5345 |
<indexterm> |
| 5346 |
<primary>NTP</primary> |
| 5347 |
<secondary>ntpd</secondary> |
| 5348 |
</indexterm> |
| 5349 |
<para>FreeBSD ships with the &man.ntpd.8; NTP server which can |
| 5350 |
be used to query other NTP servers to set the clock on your |
| 5351 |
machine or provide time services to others.</para> |
| 5352 |
</sect2> |
| 5353 |
|
| 5354 |
<sect2> |
| 5355 |
<title>Choosing Appropriate NTP Servers</title> |
| 5356 |
|
| 5357 |
<indexterm> |
| 5358 |
<primary>NTP</primary> |
| 5359 |
<secondary>choosing servers</secondary> |
| 5360 |
</indexterm> |
| 5361 |
|
| 5362 |
<para>In order to synchronize your clock, you will need to find |
| 5363 |
one or more NTP servers to use. Your network administrator or |
| 5364 |
ISP may have setup an NTP server for this purpose—check |
| 5365 |
their documentation to see if this is the case. There is a |
| 5366 |
<ulink |
| 5367 |
url="http://www.eecis.udel.edu/~mills/ntp/servers.html">list of |
| 5368 |
publicly accessible NTP servers</ulink> which you can use to |
| 5369 |
find an NTP server near to you. Make sure you are aware of |
| 5370 |
the policy for any servers you choose, and ask for permission |
| 5371 |
if required.</para> |
| 5372 |
|
| 5373 |
<para>Choosing several unconnected NTP servers is a good idea in |
| 5374 |
case one of the servers you are using becomes unreachable or |
| 5375 |
its clock is unreliable. &man.ntpd.8; uses the responses it |
| 5376 |
receives from other servers intelligently—it will favor |
| 5377 |
unreliable servers less than reliable ones.</para> |
| 5378 |
</sect2> |
| 5379 |
|
| 5380 |
<sect2> |
| 5381 |
<title>Configuring Your Machine</title> |
| 5382 |
|
| 5383 |
<indexterm> |
| 5384 |
<primary>NTP</primary> |
| 5385 |
<secondary>configuration</secondary> |
| 5386 |
</indexterm> |
| 5387 |
|
| 5388 |
<sect3> |
| 5389 |
<title>Basic Configuration</title> |
| 5390 |
<indexterm><primary>ntpdate</primary></indexterm> |
| 5391 |
|
| 5392 |
<para>If you only wish to synchronize your clock when the |
| 5393 |
machine boots up, you can use &man.ntpdate.8;. This may be |
| 5394 |
appropriate for some desktop machines which are frequently |
| 5395 |
rebooted and only require infrequent synchronization, but |
| 5396 |
most machines should run &man.ntpd.8;.</para> |
| 5397 |
|
| 5398 |
<para>Using &man.ntpdate.8; at boot time is also a good idea |
| 5399 |
for machines that run &man.ntpd.8;. &man.ntpd.8; changes the |
| 5400 |
clock gradually, whereas &man.ntpdate.8; sets the clock, no |
| 5401 |
matter how great the difference between a machine's current |
| 5402 |
clock setting and the correct time.</para> |
| 5403 |
|
| 5404 |
<para>To enable &man.ntpdate.8; at boot time, add |
| 5405 |
<programlisting>ntpdate_enable="YES"</programlisting> to |
| 5406 |
<filename>/etc/rc.conf</filename>. You will also need to |
| 5407 |
specify all servers you wish to synchronize with and any |
| 5408 |
flags to be passed to &man.ntpdate.8; in |
| 5409 |
<varname>ntpdate_flags</varname>.</para> |
| 5410 |
</sect3> |
| 5411 |
|
| 5412 |
<sect3> |
| 5413 |
<indexterm> |
| 5414 |
<primary>NTP</primary> |
| 5415 |
<secondary>ntp.conf</secondary> |
| 5416 |
</indexterm> |
| 5417 |
|
| 5418 |
<title>General Configuration</title> |
| 5419 |
|
| 5420 |
<para>NTP is configured by the |
| 5421 |
<filename>/etc/ntp.conf</filename> file in the format |
| 5422 |
described in &man.ntp.conf.5;. Here is a simple |
| 5423 |
example:</para> |
| 5424 |
|
| 5425 |
<programlisting>server ntplocal.example.com prefer |
| 5426 |
server timeserver.example.org |
| 5427 |
server ntp2a.example.net |
| 5428 |
|
| 5429 |
driftfile /var/db/ntp.drift</programlisting> |
| 5430 |
|
| 5431 |
<para>The <literal>server</literal> option specifies which |
| 5432 |
servers are to be used, with one server listed on each line. |
| 5433 |
If a server is specified with the <literal>prefer</literal> |
| 5434 |
argument, as with <hostid |
| 5435 |
role="fqdn">ntplocal.example.com</hostid>, that server is |
| 5436 |
preferred over other servers. A response from a preferred |
| 5437 |
server will be discarded if it differs significantly from |
| 5438 |
other servers' responses, otherwise it will be used without |
| 5439 |
any consideration to other responses. The |
| 5440 |
<literal>prefer</literal> argument is normally used for NTP |
| 5441 |
servers that are known to be highly accurate, such as those |
| 5442 |
with special time monitoring hardware.</para> |
| 5443 |
|
| 5444 |
<para>The <literal>driftfile</literal> option specifies which |
| 5445 |
file is used to store the system clock's frequency offset. |
| 5446 |
&man.ntpd.8; uses this to automatically compensate for the |
| 5447 |
clock's natural drift, allowing it to maintain a reasonably |
| 5448 |
correct setting even if it is cut off from all external time |
| 5449 |
sources for a period of time.</para> |
| 5450 |
|
| 5451 |
<para>The <literal>driftfile</literal> option specifies which |
| 5452 |
file is used to store information about previous responses |
| 5453 |
from the NTP servers you are using. This file contains |
| 5454 |
internal information for NTP. It should not be modified by |
| 5455 |
any other process.</para> |
| 5456 |
</sect3> |
| 5457 |
|
| 5458 |
<sect3> |
| 5459 |
<title>Controlling Access to Your Server</title> |
| 5460 |
|
| 5461 |
<para>By default, your NTP server will be accessible to all |
| 5462 |
hosts on the Internet. The <literal>restrict</literal> |
| 5463 |
option in &man.ntp.conf.5; allows you to control which |
| 5464 |
machines can access your server.</para> |
| 5465 |
|
| 5466 |
<para>If you want to deny all machines from accessing your NTP |
| 5467 |
server, add the following line to |
| 5468 |
<filename>/etc/ntp.conf</filename></para> |
| 5469 |
|
| 5470 |
<programlisting>restrict default ignore</programlisting> |
| 5471 |
|
| 5472 |
<para>If you only want to |
| 5473 |
allow machines within your own network to synchronize their |
| 5474 |
clocks with your server, but ensure they are not allowed to |
| 5475 |
configure the server or used as peers to synchronize |
| 5476 |
against, add</para> |
| 5477 |
|
| 5478 |
<programlisting>restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap</programlisting> |
| 5479 |
|
| 5480 |
<para>instead, where <hostid role="ipaddr">192.168.1.0</hostid> is |
| 5481 |
an IP address on your network and <hostid |
| 5482 |
role="netmask">255.255.255.0</hostid> is your network's |
| 5483 |
netmask.</para> |
| 5484 |
|
| 5485 |
<para><filename>/etc/ntp.conf</filename> can contain multiple |
| 5486 |
<literal>restrict</literal> options. For more details, see |
| 5487 |
the <literal>Access Control Support</literal> subsection of |
| 5488 |
&man.ntp.conf.5;.</para> |
| 5489 |
</sect3> |
| 5490 |
</sect2> |
| 5491 |
|
| 5492 |
<sect2> |
| 5493 |
<title>Running the NTP Server</title> |
| 5494 |
|
| 5495 |
<para>To ensure the NTP server is started at boot time, add the |
| 5496 |
line <programlisting>xntpd_enable="YES"</programlisting> to |
| 5497 |
<filename>/etc/rc.conf</filename>. If you wish to pass |
| 5498 |
additional flags to &man.ntpd.8; edit the |
| 5499 |
<varname>xntpd_flags</varname> parameter in |
| 5500 |
<filename>/etc/rc.conf</filename>.</para> |
| 5501 |
|
| 5502 |
<para>To start the server without rebooting your machine, run |
| 5503 |
<command>ntpd</command> being sure to specify any additional |
| 5504 |
parameters from <varname>xntpd_flags</varname> in |
| 5505 |
<filename>/etc/rc.conf</filename>. For example:</para> |
| 5506 |
<screen>&prompt.root; <userinput>ntpd -p /var/run/ntpd.pid</userinput></screen> |
| 5507 |
</sect2> |
| 5508 |
|
| 5509 |
<sect2> |
| 5510 |
<title>Using &man.ntpd.8; with a Temporary Internet |
| 5511 |
Connection</title> |
| 5512 |
|
| 5513 |
<para><command>ntpd</command> does not need a permanent |
| 5514 |
connection to the Internet to function properly. However, if |
| 5515 |
you have a temporary connection that is configured to dial out |
| 5516 |
on demand, it is a good idea to prevent NTP traffic from |
| 5517 |
triggering a dial out or keeping the connection alive. If you |
| 5518 |
are using user PPP, you can use <literal>filter</literal> |
| 5519 |
directives in <filename>/etc/ppp/ppp.conf</filename>. For |
| 5520 |
example:</para> |
| 5521 |
|
| 5522 |
<programlisting> set filter dial 0 deny udp src eq 123 |
| 5523 |
# Prevent NTP traffic from initiating dial out |
| 5524 |
set filter dial 1 permit 0 0 |
| 5525 |
set filter alive 0 deny udp src eq 123 |
| 5526 |
# Prevent incoming NTP traffic from keeping the connection open |
| 5527 |
set filter alive 1 deny udp dst eq 123 |
| 5528 |
# Prevent outgoing NTP traffic from keeping the connection open |
| 5529 |
set filter alive 2 permit 0/0 0/0</programlisting> |
| 5530 |
|
| 5531 |
<para>For more details see the <literal>PACKET |
| 5532 |
FILTERING</literal> section in &man.ppp.8; and the examples in |
| 5533 |
<filename>/usr/share/examples/ppp/</filename>.</para> |
| 5534 |
|
| 5535 |
<note> |
| 5536 |
<para>Some Internet access providers block low-numbered ports, |
| 5537 |
preventing NTP from functioning since replies never |
| 5538 |
reach your machine.</para> |
| 5539 |
</note> |
| 5540 |
</sect2> |
| 5541 |
|
| 5542 |
<sect2> |
| 5543 |
<title>Further Information</title> |
| 5544 |
|
| 5545 |
<para>Documentation for the NTP server can be found in |
| 5546 |
<filename>/usr/share/doc/ntp/</filename> in HTML |
| 5547 |
format.</para> |
| 5548 |
</sect2> |
| 5549 |
</sect1> |
| 5550 |
|
| 5551 |
<sect1 id="network-natd"> |
| 5552 |
<sect1info> |
| 5553 |
<authorgroup> |
| 5554 |
<author> |
| 5555 |
<firstname>Chern</firstname> |
| 5556 |
<surname>Lee</surname> |
| 5557 |
<contrib>Contributed by </contrib> |
| 5558 |
</author> |
| 5559 |
</authorgroup> |
| 5560 |
</sect1info> |
| 5561 |
<title>Network Address Translation</title> |
| 5562 |
|
| 5563 |
<sect2 id="network-natoverview"> |
| 5564 |
<title>Overview</title> |
| 5565 |
<indexterm> |
| 5566 |
<primary><application>natd</application></primary> |
| 5567 |
</indexterm> |
| 5568 |
<para>FreeBSD's Network Address Translation daemon, commonly known as |
| 5569 |
&man.natd.8; is a daemon that accepts incoming raw IP packets, |
| 5570 |
changes the source to the local machine and re-injects these packets |
| 5571 |
back into the outgoing IP packet stream. natd does this by changing |
| 5572 |
the source IP address and port such that when data is received back, |
| 5573 |
it is able to determine the original location of the data and forward |
| 5574 |
it back to its original requester.</para> |
| 5575 |
<indexterm><primary>Internet connection sharing</primary></indexterm> |
| 5576 |
<indexterm><primary>IP masquerading</primary></indexterm> |
| 5577 |
<para>The most common use of NAT is to perform what is commonly known as |
| 5578 |
Internet Connection Sharing.</para> |
| 5579 |
</sect2> |
| 5580 |
|
| 5581 |
<sect2 id="network-natsetup"> |
| 5582 |
<title>Setup</title> |
| 5583 |
<para>Due to the diminishing IP space in IPv4, and the increased number |
| 5584 |
of users on high-speed consumer lines such as cable or DSL, people are |
| 5585 |
increasingly in need of an Internet Connection Sharing solution. The |
| 5586 |
ability to connect several computers online through one connection and |
| 5587 |
IP address makes &man.natd.8; a reasonable choice.</para> |
| 5588 |
|
| 5589 |
<para>Most commonly, a user has a machine connected to a cable or DSL |
| 5590 |
line with one IP address and wishes to use this one connected computer to |
| 5591 |
provide Internet access to several more over a LAN.</para> |
| 5592 |
|
| 5593 |
<para>To do this, the FreeBSD machine on the Internet must act as a |
| 5594 |
gateway. This gateway machine must have two NICs--one for connecting |
| 5595 |
to the Internet router, the other connecting to a LAN. All the |
| 5596 |
machines on the LAN are connected through a hub or switch.</para> |
| 5597 |
|
| 5598 |
<mediaobject> |
| 5599 |
<imageobject> |
| 5600 |
<imagedata fileref="advanced-networking/natd"> |
| 5601 |
</imageobject> |
| 5602 |
|
| 5603 |
<textobject> |
| 5604 |
<literallayout class="monospaced"> _______ __________ ________ |
| 5605 |
| | | | | | |
| 5606 |
| Hub |-----| Client B |-----| Router |----- Internet |
| 5607 |
|_______| |__________| |________| |
| 5608 |
| |
| 5609 |
____|_____ |
| 5610 |
| | |
| 5611 |
| Client A | |
| 5612 |
|__________|</literallayout> |
| 5613 |
</textobject> |
| 5614 |
|
| 5615 |
<textobject> |
| 5616 |
<phrase>Network Layout</phrase> |
| 5617 |
</textobject> |
| 5618 |
</mediaobject> |
| 5619 |
|
| 5620 |
<para>A setup like this is commonly used to share an Internet |
| 5621 |
connection. One of the <acronym>LAN</acronym> machines is |
| 5622 |
connected to the Internet. The rest of the machines access |
| 5623 |
the Internet through that <quote>gateway</quote> |
| 5624 |
machine.</para> |
| 5625 |
</sect2> |
| 5626 |
|
| 5627 |
<sect2 id="network-natdkernconfiguration"> |
| 5628 |
<indexterm> |
| 5629 |
<primary>kernel</primary> |
| 5630 |
<secondary>configuration</secondary> |
| 5631 |
</indexterm> |
| 5632 |
<title>Configuration</title> |
| 5633 |
<para>The following options must be in the kernel configuration |
| 5634 |
file:</para> |
| 5635 |
<programlisting>options IPFIREWALL |
| 5636 |
options IPDIVERT</programlisting> |
| 5637 |
|
| 5638 |
<para>Additionally, at choice, the following may also be suitable:</para> |
| 5639 |
<programlisting>options IPFIREWALL_DEFAULT_TO_ACCEPT |
| 5640 |
options IPFIREWALL_VERBOSE</programlisting> |
| 5641 |
|
| 5642 |
<para>The following must be in <filename>/etc/rc.conf</filename>:</para> |
| 5643 |
|
| 5644 |
<programlisting>gateway_enable="YES" |
| 5645 |
firewall_enable="YES" |
| 5646 |
firewall_type="OPEN" |
| 5647 |
natd_enable="YES" |
| 5648 |
natd_interface="<replaceable>fxp0</replaceable>" |
| 5649 |
natd_flags=""</programlisting> |
| 5650 |
|
| 5651 |
<informaltable frame="none"> |
| 5652 |
<tgroup cols="2"> |
| 5653 |
<tbody> |
| 5654 |
<row> |
| 5655 |
<entry>gateway_enable="YES"</entry> |
| 5656 |
<entry>Sets up the machine to act as a gateway. Running |
| 5657 |
<command>sysctl net.inet.ip.forwarding=1</command> |
| 5658 |
would have the same effect.</entry> |
| 5659 |
</row> |
| 5660 |
<row><entry>firewall_enable="YES"</entry> |
| 5661 |
<entry>Enables the firewall rules in |
| 5662 |
<filename>/etc/rc.firewall</filename> at boot.</entry> |
| 5663 |
</row> |
| 5664 |
<row><entry>firewall_type="OPEN"</entry> |
| 5665 |
<entry>This specifies a predefined firewall ruleset that |
| 5666 |
allows anything in. See |
| 5667 |
<filename>/etc/rc.firewall</filename> for additional |
| 5668 |
types.</entry> |
| 5669 |
</row> |
| 5670 |
<row> |
| 5671 |
<entry>natd_interface="fxp0"</entry> |
| 5672 |
<entry>Indicates which interface to forward packets through |
| 5673 |
(the interface connected to the Internet).</entry> |
| 5674 |
</row> |
| 5675 |
<row> |
| 5676 |
<entry>natd_flags=""</entry> |
| 5677 |
<entry>Any additional configuration options passed to |
| 5678 |
&man.natd.8; on boot.</entry> |
| 5679 |
</row> |
| 5680 |
</tbody> |
| 5681 |
</tgroup> |
| 5682 |
</informaltable> |
| 5683 |
|
| 5684 |
<para>Having the previous options defined in |
| 5685 |
<filename>/etc/rc.conf</filename> would run |
| 5686 |
<command>natd -interface fxp0</command> at boot. This can also |
| 5687 |
be run manually.</para> |
| 5688 |
|
| 5689 |
<para>Each machine and interface behind the LAN should be |
| 5690 |
assigned IP address numbers in the private network space as |
| 5691 |
defined by <ulink |
| 5692 |
url="ftp://ftp.isi.edu/in-notes/rfc1918.txt">RFC 1918</ulink> |
| 5693 |
and have a default gateway of the natd machine's internal IP |
| 5694 |
address.</para> |
| 5695 |
|
| 5696 |
<para>For example, client <hostid>a</hostid> and |
| 5697 |
<hostid>b</hostid> behind the LAN have IP addresses of <hostid |
| 5698 |
role="ipaddr">192.168.0.2</hostid> and <hostid |
| 5699 |
role="ipaddr">192.168.0.3</hostid>, while the natd machine's |
| 5700 |
LAN interface has an IP address of <hostid |
| 5701 |
role="ipaddr">192.168.0.1</hostid>. Client <hostid>a</hostid> |
| 5702 |
and <hostid>b</hostid>'s default gateway must be set to that |
| 5703 |
of the natd machine, <hostid |
| 5704 |
role="ipaddr">192.168.0.1</hostid>. The natd machine's |
| 5705 |
external, or Internet interface does not require any special |
| 5706 |
modification for natd to work.</para> |
| 5707 |
</sect2> |
| 5708 |
|
| 5709 |
<sect2 id="network-natdport-redirection"> |
| 5710 |
<title>Port Redirection</title> |
| 5711 |
|
| 5712 |
<para>The drawback with natd is that the LAN clients are not accessible |
| 5713 |
from the Internet. Clients on the LAN can make outgoing connections to |
| 5714 |
the world but cannot receive incoming ones. This presents a problem |
| 5715 |
if trying to run Internet services on one of the LAN client machines. |
| 5716 |
A simple way around this is to redirect selected Internet ports on the |
| 5717 |
natd machine to a LAN client. |
| 5718 |
</para> |
| 5719 |
|
| 5720 |
<para>For example, an IRC server runs on Client A, and a web server runs |
| 5721 |
on Client B. For this to work properly, connections received on ports |
| 5722 |
6667 (IRC) and 80 (web) must be redirected to the respective machines. |
| 5723 |
</para> |
| 5724 |
|
| 5725 |
<para>The <command>-redirect_port</command> must be passed to |
| 5726 |
&man.natd.8; with the proper options. The syntax is as follows:</para> |
| 5727 |
<para><programlisting> -redirect_port proto targetIP:targetPORT[-targetPORT] |
| 5728 |
[aliasIP:]aliasPORT[-aliasPORT] |
| 5729 |
[remoteIP[:remotePORT[-remotePORT]]]</programlisting></para> |
| 5730 |
|
| 5731 |
<para>In the above example, the argument should be: |
| 5732 |
<programlisting> -redirect_port tcp 192.168.0.2:6667 6667 |
| 5733 |
-redirect_port tcp 192.168.0.3:80 80</programlisting> |
| 5734 |
This will redirect the proper <emphasis>tcp</emphasis> ports to the |
| 5735 |
LAN client machines. |
| 5736 |
</para> |
| 5737 |
|
| 5738 |
<para>The -redirect_port argument can be used to indicate port |
| 5739 |
ranges over individual ports. For example, <replaceable>tcp |
| 5740 |
192.168.0.2:2000-3000 2000-3000</replaceable> would redirect |
| 5741 |
all connections received on ports 2000 to 3000 to ports 2000 |
| 5742 |
to 3000 on Client A.</para> |
| 5743 |
|
| 5744 |
<para>These options can be used when directly running |
| 5745 |
&man.natd.8; or placed within the |
| 5746 |
<programlisting>natd_flags=""</programlisting> option in |
| 5747 |
<filename>/etc/rc.conf</filename>.</para> |
| 5748 |
|
| 5749 |
<para>For further configuration options, consult &man.natd.8;</para> |
| 5750 |
</sect2> |
| 5751 |
|
| 5752 |
<sect2 id="network-natdaddress-redirection"> |
| 5753 |
<title>Address Redirection</title> |
| 5754 |
<indexterm><primary>address redirection</primary></indexterm> |
| 5755 |
<para>Address redirection is useful if several IP addresses are |
| 5756 |
available, yet they must be on one machine. With this, |
| 5757 |
&man.natd.8; can assign each LAN client its own external IP address. |
| 5758 |
&man.natd.8; then rewrites outgoing packets from the LAN clients |
| 5759 |
with the proper external IP address and redirects |
| 5760 |
all traffic incoming on that particular IP address back to |
| 5761 |
the specific LAN client. This is also known as static NAT. |
| 5762 |
For example, the IP addresses <hostid role="ipaddr">128.1.1.1</hostid>, |
| 5763 |
<hostid role="ipaddr">128.1.1.2</hostid>, and |
| 5764 |
<hostid role="ipaddr">128.1.1.3</hostid> belong to the natd gateway |
| 5765 |
machine. <hostid role="ipaddr">128.1.1.1</hostid> can be used |
| 5766 |
as the natd gateway machine's external IP address, while |
| 5767 |
<hostid role="ipaddr">128.1.1.2</hostid> and |
| 5768 |
<hostid role="ipaddr">128.1.1.3</hostid> are forwarded back to LAN |
| 5769 |
clients A and B.</para> |
| 5770 |
|
| 5771 |
<para>The -redirect_address syntax is as follows:</para> |
| 5772 |
<para><option> -redirect_address localIP publicIP</option> |
| 5773 |
</para> |
| 5774 |
|
| 5775 |
<informaltable frame="none"> |
| 5776 |
<tgroup cols="2"> |
| 5777 |
<tbody> |
| 5778 |
<row> |
| 5779 |
<entry>localIP</entry> |
| 5780 |
<entry>The internal IP address of the LAN client.</entry> |
| 5781 |
</row> |
| 5782 |
<row> |
| 5783 |
<entry>publicIP</entry> |
| 5784 |
<entry>The external IP address corresponding to the LAN client.</entry> |
| 5785 |
</row> |
| 5786 |
</tbody> |
| 5787 |
</tgroup> |
| 5788 |
</informaltable> |
| 5789 |
|
| 5790 |
<para>In the example, this argument would read:</para> |
| 5791 |
<para><option> -redirect_address 192.168.0.2 128.1.1.2 |
| 5792 |
-redirect_address 192.168.0.3 128.1.1.3</option></para> |
| 5793 |
|
| 5794 |
<para>Like -redirect_port, these arguments are also placed within |
| 5795 |
natd_flags of <filename>/etc/rc.conf</filename>. With address |
| 5796 |
redirection, there is no need for port redirection since all data |
| 5797 |
received on a particular IP address is redirected.</para> |
| 5798 |
|
| 5799 |
<para>The external IP addresses on the natd machine must be active and aliased |
| 5800 |
to the external interface. Look at &man.rc.conf.5; to do so.</para> |
| 5801 |
|
| 5802 |
</sect2> |
| 5803 |
</sect1> |
| 5804 |
|
| 5805 |
<sect1 id="network-inetd"> |
| 5806 |
<sect1info> |
| 5807 |
<authorgroup> |
| 5808 |
<author> |
| 5809 |
<firstname>Chern</firstname> |
| 5810 |
<surname>Lee</surname> |
| 5811 |
<contrib>Contributed by </contrib> |
| 5812 |
</author> |
| 5813 |
</authorgroup> |
| 5814 |
</sect1info> |
| 5815 |
|
| 5816 |
<title>The <application>inetd</application> <quote>Super-Server</quote></title> |
| 5817 |
|
| 5818 |
<sect2 id="network-inetd-overview"> |
| 5819 |
<title>Overview</title> |
| 5820 |
|
| 5821 |
<para>&man.inetd.8; is referred to as the <quote>Internet |
| 5822 |
Super-Server</quote> because it manages connections for several |
| 5823 |
daemons. Programs that provide network service are commonly |
| 5824 |
known as daemons. <application>inetd</application> serves as a |
| 5825 |
managing server for other daemons. When a connection is |
| 5826 |
received by <application>inetd</application>, it determines |
| 5827 |
which daemon the connection is destined for, spawns the |
| 5828 |
particular daemon and delegates the socket to it. Running one |
| 5829 |
instance of <application>inetd</application> reduces the overall |
| 5830 |
system load as compared to running each daemon individually in |
| 5831 |
stand-alone mode.</para> |
| 5832 |
|
| 5833 |
<para>Primarily, <application>inetd</application> is used to |
| 5834 |
spawn other daemons, but several trivial protocols are handled |
| 5835 |
directly, such as <application>chargen</application>, |
| 5836 |
<application>auth</application>, and |
| 5837 |
<application>daytime</application>.</para> |
| 5838 |
|
| 5839 |
<para>This section will cover the basics in configuring |
| 5840 |
<application>inetd</application> through its command-line |
| 5841 |
options and its configuration file, |
| 5842 |
<filename>/etc/inetd.conf</filename>.</para> |
| 5843 |
</sect2> |
| 5844 |
|
| 5845 |
<sect2 id="network-inetd-settings"> |
| 5846 |
<title>Settings</title> |
| 5847 |
|
| 5848 |
<para><application>inetd</application> is initialized through |
| 5849 |
the <filename>/etc/rc.conf</filename> system. The |
| 5850 |
<literal>inetd_enable</literal> option is set to |
| 5851 |
<quote>NO</quote> by default, but is often times turned on by |
| 5852 |
<application>sysinstall</application> with the medium security |
| 5853 |
profile. Placing: |
| 5854 |
<programlisting>inetd_enable="YES"</programlisting> or |
| 5855 |
<programlisting>inetd_enable="NO"</programlisting> into |
| 5856 |
<filename>/etc/rc.conf</filename> can enable or disable |
| 5857 |
<application>inetd</application> starting at boot time.</para> |
| 5858 |
|
| 5859 |
<para>Additionally, different command-line options can be passed |
| 5860 |
to <application>inetd</application> via the |
| 5861 |
<literal>inetd_flags</literal> option.</para> |
| 5862 |
</sect2> |
| 5863 |
|
| 5864 |
<sect2 id="network-inetd-cmdline"> |
| 5865 |
<title>Command-Line Options</title> |
| 5866 |
|
| 5867 |
<para><application>inetd</application> synopsis:</para> |
| 5868 |
|
| 5869 |
<para><option> inetd [-d] [-l] [-w] [-W] [-c maximum] [-C rate] [-a address | hostname] |
| 5870 |
[-p filename] [-R rate] [configuration file]</option></para> |
| 5871 |
|
| 5872 |
<variablelist> |
| 5873 |
<varlistentry> |
| 5874 |
<term>-d</term> |
| 5875 |
|
| 5876 |
<listitem> |
| 5877 |
<para>Turn on debugging.</para> |
| 5878 |
</listitem> |
| 5879 |
</varlistentry> |
| 5880 |
|
| 5881 |
<varlistentry> |
| 5882 |
<term>-l</term> |
| 5883 |
|
| 5884 |
<listitem> |
| 5885 |
<para>Turn on logging of successful connections.</para> |
| 5886 |
</listitem> |
| 5887 |
</varlistentry> |
| 5888 |
|
| 5889 |
<varlistentry> |
| 5890 |
<term>-w</term> |
| 5891 |
|
| 5892 |
<listitem> |
| 5893 |
<para>Turn on TCP Wrapping for external services (on by |
| 5894 |
default).</para> |
| 5895 |
</listitem> |
| 5896 |
</varlistentry> |
| 5897 |
|
| 5898 |
<varlistentry> |
| 5899 |
<term>-W</term> |
| 5900 |
|
| 5901 |
<listitem> |
| 5902 |
<para>Turn on TCP Wrapping for internal services which are |
| 5903 |
built into <application>inetd</application> (on by |
| 5904 |
default).</para> |
| 5905 |
</listitem> |
| 5906 |
</varlistentry> |
| 5907 |
|
| 5908 |
<varlistentry> |
| 5909 |
<term>-c maximum</term> |
| 5910 |
|
| 5911 |
<listitem> |
| 5912 |
<para>Specify the default maximum number of simultaneous |
| 5913 |
invocations of each service; the default is unlimited. |
| 5914 |
May be overridden on a per-service basis with the |
| 5915 |
<option>max-child</option> parameter.</para> |
| 5916 |
</listitem> |
| 5917 |
</varlistentry> |
| 5918 |
|
| 5919 |
<varlistentry> |
| 5920 |
<term>-C rate</term> |
| 5921 |
|
| 5922 |
<listitem> |
| 5923 |
<para>Specify the default maximum number of times a |
| 5924 |
service can be invoked from a single IP address in one |
| 5925 |
minute; the default is unlimited. May be overridden on a |
| 5926 |
per-service basis with the |
| 5927 |
<option>max-connections-per-ip-per-minute</option> |
| 5928 |
parameter.</para> |
| 5929 |
</listitem> |
| 5930 |
</varlistentry> |
| 5931 |
|
| 5932 |
<varlistentry> |
| 5933 |
<term>-R rate</term> |
| 5934 |
|
| 5935 |
<listitem> |
| 5936 |
<para>Specify the maximum number of times a service can be |
| 5937 |
invoked in one minute; the default is 256. A rate of 0 |
| 5938 |
allows an unlimited number of invocations.</para> |
| 5939 |
</listitem> |
| 5940 |
</varlistentry> |
| 5941 |
|
| 5942 |
<varlistentry> |
| 5943 |
<term>-a</term> |
| 5944 |
|
| 5945 |
<listitem> |
| 5946 |
<para>Specify one specific IP address to bind to. |
| 5947 |
Alternatively, a hostname can be specified, in which case |
| 5948 |
the IPv4 or IPv6 address which corresponds to that |
| 5949 |
hostname is used. Usually a hostname is specified when |
| 5950 |
<application>inetd</application> is run inside a |
| 5951 |
&man.jail.8;, in which case the hostname corresponds to |
| 5952 |
the &man.jail.8; environment.</para> |
| 5953 |
|
| 5954 |
<para>When hostname specification is used and both IPv4 |
| 5955 |
and IPv6 bindings are desired, one entry with the |
| 5956 |
appropriate protocol type for each binding is required for |
| 5957 |
each service in <filename>/etc/inetd.conf</filename>. For |
| 5958 |
example, a TCP-based service would need two entries, one |
| 5959 |
using <quote>tcp4</quote> for the protocol and the other using |
| 5960 |
<quote>tcp6</quote>.</para> |
| 5961 |
</listitem> |
| 5962 |
</varlistentry> |
| 5963 |
|
| 5964 |
<varlistentry> |
| 5965 |
<term>-p</term> |
| 5966 |
|
| 5967 |
<listitem> |
| 5968 |
<para>Specify an alternate file in which to store the |
| 5969 |
process ID.</para> |
| 5970 |
</listitem> |
| 5971 |
</varlistentry> |
| 5972 |
</variablelist> |
| 5973 |
|
| 5974 |
<para>These options can be passed to |
| 5975 |
<application>inetd</application> using the |
| 5976 |
<literal>inetd_flags</literal> option in |
| 5977 |
<filename>/etc/rc.conf</filename>. By default, |
| 5978 |
<literal>inetd_flags</literal> is set to <quote>-wW</quote>, |
| 5979 |
which turns on TCP wrapping for |
| 5980 |
<application>inetd</application>'s internal and external |
| 5981 |
services. For novice users, these parameters usually do not need |
| 5982 |
to be modified or even entered in |
| 5983 |
<filename>/etc/rc.conf</filename>.</para> |
| 5984 |
|
| 5985 |
<note> |
| 5986 |
<para>An external service is a daemon outside of |
| 5987 |
<application>inetd</application>, which is invoked when a |
| 5988 |
connection is received for it. On the other hand, an internal |
| 5989 |
service is one that <application>inetd</application> has the |
| 5990 |
facility of offering within itself.</para> |
| 5991 |
</note> |
| 5992 |
|
| 5993 |
</sect2> |
| 5994 |
|
| 5995 |
<sect2 id="network-inetd-conf"> |
| 5996 |
<title><filename>inetd.conf</filename></title> |
| 5997 |
|
| 5998 |
<para>Configuration of <application>inetd</application> is |
| 5999 |
controlled through the <filename>/etc/inetd.conf</filename> |
| 6000 |
file.</para> |
| 6001 |
|
| 6002 |
<para>When a modification is made to |
| 6003 |
<filename>/etc/inetd.conf</filename>, |
| 6004 |
<application>inetd</application> can be forced to re-read its |
| 6005 |
configuration file by sending a HangUP signal to the |
| 6006 |
<application>inetd</application> process as shown:</para> |
| 6007 |
|
| 6008 |
<example id="network-inetd-hangup"> |
| 6009 |
<title>Sending <application>inetd</application> a HangUP Signal</title> |
| 6010 |
|
| 6011 |
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/inetd.pid`</userinput></screen> |
| 6012 |
</example> |
| 6013 |
|
| 6014 |
<para>Each line of the configuration file specifies an |
| 6015 |
individual daemon. Comments in the file are preceded by a |
| 6016 |
<quote>#</quote>. The format of |
| 6017 |
<filename>/etc/inetd.conf</filename> is as follows:</para> |
| 6018 |
|
| 6019 |
<programlisting>service-name |
| 6020 |
socket-type |
| 6021 |
protocol |
| 6022 |
{wait|nowait}[/max-child[/max-connections-per-ip-per-minute]] |
| 6023 |
user[:group][/login-class] |
| 6024 |
server-program |
| 6025 |
server-program-arguments</programlisting> |
| 6026 |
|
| 6027 |
<para>An example entry for the <application>ftpd</application> daemon |
| 6028 |
using IPv4:</para> |
| 6029 |
|
| 6030 |
<programlisting>ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l</programlisting> |
| 6031 |
|
| 6032 |
<variablelist> |
| 6033 |
<varlistentry> |
| 6034 |
<term>service-name</term> |
| 6035 |
|
| 6036 |
<listitem> |
| 6037 |
<para>This is the service name of the particular daemon. |
| 6038 |
It must correspond to a service listed in |
| 6039 |
<filename>/etc/services</filename>. This determines which |
| 6040 |
port <application>inetd</application> must listen to. If |
| 6041 |
a new service is being created, it must be placed in |
| 6042 |
<filename>/etc/services</filename> |
| 6043 |
first.</para> |
| 6044 |
</listitem> |
| 6045 |
</varlistentry> |
| 6046 |
|
| 6047 |
<varlistentry> |
| 6048 |
<term>socket-type</term> |
| 6049 |
|
| 6050 |
<listitem> |
| 6051 |
<para>Either <literal>stream</literal>, |
| 6052 |
<literal>dgram</literal>, <literal>raw</literal>, or |
| 6053 |
<literal>seqpacket</literal>. <literal>stream</literal> |
| 6054 |
must be used for connection-based, TCP daemons, while |
| 6055 |
<literal>dgram</literal> is used for daemons utilizing the |
| 6056 |
UDP transport protocol.</para> |
| 6057 |
</listitem> |
| 6058 |
</varlistentry> |
| 6059 |
|
| 6060 |
<varlistentry> |
| 6061 |
<term>protocol</term> |
| 6062 |
|
| 6063 |
<listitem> |
| 6064 |
<para>One of the following:</para> |
| 6065 |
|
| 6066 |
<informaltable> |
| 6067 |
<tgroup cols="2"> |
| 6068 |
<thead> |
| 6069 |
<row> |
| 6070 |
<entry>Protocol</entry> |
| 6071 |
<entry>Explanation</entry> |
| 6072 |
</row> |
| 6073 |
</thead> |
| 6074 |
<tbody> |
| 6075 |
<row> |
| 6076 |
<entry>tcp, tcp4</entry> |
| 6077 |
<entry>TCP IPv4</entry> |
| 6078 |
</row> |
| 6079 |
<row> |
| 6080 |
<entry>udp, udp4</entry> |
| 6081 |
<entry>UDP IPv4</entry> |
| 6082 |
</row> |
| 6083 |
<row> |
| 6084 |
<entry>tcp6</entry> |
| 6085 |
<entry>TCP IPv6</entry> |
| 6086 |
</row> |
| 6087 |
<row> |
| 6088 |
<entry>udp6</entry> |
| 6089 |
<entry>UDP IPv6</entry> |
| 6090 |
</row> |
| 6091 |
<row> |
| 6092 |
<entry>tcp46</entry> |
| 6093 |
<entry>Both TCP IPv4 and v6</entry> |
| 6094 |
</row> |
| 6095 |
<row> |
| 6096 |
<entry>udp46</entry> |
| 6097 |
<entry>Both UDP IPv4 and v6</entry> |
| 6098 |
</row> |
| 6099 |
</tbody> |
| 6100 |
</tgroup> |
| 6101 |
</informaltable> |
| 6102 |
</listitem> |
| 6103 |
</varlistentry> |
| 6104 |
|
| 6105 |
<varlistentry> |
| 6106 |
<term>{wait|nowait}[/max-child[/max-connections-per-ip-per-minute]]</term> |
| 6107 |
|
| 6108 |
<listitem> |
| 6109 |
<para><option>wait|nowait</option> indicates whether the |
| 6110 |
daemon invoked from <application>inetd</application> is |
| 6111 |
able to handle its own socket or not. |
| 6112 |
<option>dgram</option> socket types must use the wait |
| 6113 |
option, while stream socket daemons, which are usually |
| 6114 |
multi-threaded, should use <option>nowait</option>. |
| 6115 |
<option>wait</option> usually hands off multiple sockets |
| 6116 |
to a single daemon, while <option>nowait</option> spawns a |
| 6117 |
child daemon for each new socket.</para> |
| 6118 |
|
| 6119 |
<para>The maximum number of child daemons |
| 6120 |
<application>inetd</application> may spawn can be set using |
| 6121 |
the <option>max-child</option> option. If a limit of ten |
| 6122 |
instances of a particular daemon is needed, a |
| 6123 |
<literal>/10</literal> would be placed after |
| 6124 |
<option>nowait</option>.</para> |
| 6125 |
|
| 6126 |
<para>In addition to <option>max-child</option>, another |
| 6127 |
option limiting the maximum connections from a single |
| 6128 |
place to a particular daemon can be enabled. |
| 6129 |
<option>max-connections-per-ip-per-minute</option> does |
| 6130 |
just this. A value of ten here would limit any particular |
| 6131 |
IP address connecting to a particular service to ten |
| 6132 |
attempts per minute. This is useful to prevent |
| 6133 |
intentional or unintentional resource consumption and |
| 6134 |
Denial of Service (DoS) attacks to a machine.</para> |
| 6135 |
|
| 6136 |
<para>In this field, <option>wait</option> or |
| 6137 |
<option>nowait</option> is mandatory. |
| 6138 |
<option>max-child</option> and |
| 6139 |
<option>max-connections-per-ip-per-minute</option> are |
| 6140 |
optional.</para> |
| 6141 |
|
| 6142 |
<para>A stream-type multi-threaded daemon without any |
| 6143 |
<option>max-child</option> or |
| 6144 |
<option>max-connections-per-ip-per-minute</option> limits |
| 6145 |
would simply be: <literal>nowait</literal></para> |
| 6146 |
|
| 6147 |
<para>The same daemon with a maximum limit of ten daemons |
| 6148 |
would read: <literal>nowait/10</literal></para> |
| 6149 |
|
| 6150 |
<para>Additionally, the same setup with a limit of twenty |
| 6151 |
connections per IP address per minute and a maximum |
| 6152 |
total limit of ten child daemons would read: |
| 6153 |
<literal>nowait/10/20</literal></para> |
| 6154 |
|
| 6155 |
<para>These options are all utilized by the default |
| 6156 |
settings of the <application>fingerd</application> daemon, |
| 6157 |
as seen here:</para> |
| 6158 |
|
| 6159 |
<programlisting>finger stream tcp nowait/3/10 nobody /usr/libexec/fingerd fingerd -s</programlisting> |
| 6160 |
</listitem> |
| 6161 |
</varlistentry> |
| 6162 |
|
| 6163 |
<varlistentry> |
| 6164 |
<term>user</term> |
| 6165 |
|
| 6166 |
<listitem> |
| 6167 |
<para>The user is the username that the particular daemon |
| 6168 |
should run as. Most commonly, daemons run as the |
| 6169 |
<username>root</username> user. For security purposes, it is |
| 6170 |
common to find some servers running as the |
| 6171 |
<username>daemon</username> user, or the least privileged |
| 6172 |
<username>nobody</username> user.</para> |
| 6173 |
</listitem> |
| 6174 |
</varlistentry> |
| 6175 |
|
| 6176 |
<varlistentry> |
| 6177 |
<term>server-program</term> |
| 6178 |
|
| 6179 |
<listitem> |
| 6180 |
<para>The full path of the daemon to be executed when a |
| 6181 |
connection is received. If the daemon is a service |
| 6182 |
provided by <application>inetd</application> internally, |
| 6183 |
then <option>internal</option> should be |
| 6184 |
used.</para> |
| 6185 |
</listitem> |
| 6186 |
</varlistentry> |
| 6187 |
|
| 6188 |
<varlistentry> |
| 6189 |
<term>server-program-arguments</term> |
| 6190 |
|
| 6191 |
<listitem> |
| 6192 |
<para>This works in conjunction with |
| 6193 |
<option>server-program</option> by specifying the |
| 6194 |
arguments, starting with argv[0], passed to the daemon on |
| 6195 |
invocation. If <application>mydaemon -d</application> is |
| 6196 |
the command line, <literal>mydaemon -d</literal> would be |
| 6197 |
the value of <option>server program arguments</option>. |
| 6198 |
Again, if the daemon is an internal service, use |
| 6199 |
<option>internal</option> here.</para> |
| 6200 |
</listitem> |
| 6201 |
</varlistentry> |
| 6202 |
</variablelist> |
| 6203 |
</sect2> |
| 6204 |
|
| 6205 |
<sect2 id="network-inetd-security"> |
| 6206 |
<title>Security</title> |
| 6207 |
|
| 6208 |
<para>Depending on the security profile chosen at install, many |
| 6209 |
of <application>inetd</application>'s daemons may be enabled by |
| 6210 |
default. If there is no apparent need for a particular daemon, |
| 6211 |
disable it! Place a <quote>#</quote> in front of the daemon in |
| 6212 |
question, and send a <link linkend="network-inetd-hangup">hangup signal |
| 6213 |
to inetd</link>. |
| 6214 |
Some daemons, such as <application>fingerd</application>, may |
| 6215 |
not be desired at all because they provide an attacker with too |
| 6216 |
much information.</para> |
| 6217 |
|
| 6218 |
<para>Some daemons are not security-conscious and have long, or |
| 6219 |
non-existent timeouts for connection attempts. This allows an |
| 6220 |
attacker to slowly send connections to a particular daemon, thus |
| 6221 |
saturating available resources. It may be a good idea to place |
| 6222 |
<option>ip-per-minute</option> and <option>max-child</option> |
| 6223 |
limitations on certain daemons.</para> |
| 6224 |
|
| 6225 |
<para>By default, TCP wrapping is turned on. Consult the |
| 6226 |
&man.hosts.access.5; manual page for more information on placing |
| 6227 |
TCP restrictions on various <application>inetd</application> |
| 6228 |
invoked daemons.</para> |
| 6229 |
</sect2> |
| 6230 |
|
| 6231 |
<sect2 id="network-inetd-misc"> |
| 6232 |
<title>Miscellaneous</title> |
| 6233 |
|
| 6234 |
<para><application>daytime</application>, |
| 6235 |
<application>time</application>, |
| 6236 |
<application>echo</application>, |
| 6237 |
<application>discard</application>, |
| 6238 |
<application>chargen</application>, and |
| 6239 |
<application>auth</application> are all internally provided |
| 6240 |
services of <application>inetd</application>.</para> |
| 6241 |
|
| 6242 |
<para>The <application>auth</application> service provides identity |
| 6243 |
(ident, identd) network services, and is configurable to a certain |
| 6244 |
degree.</para> |
| 6245 |
|
| 6246 |
<para>Consult the &man.inetd.8; manual page for more in-depth |
| 6247 |
information.</para> |
| 6248 |
</sect2> |
| 6249 |
</sect1> |
| 6250 |
|
| 6251 |
<sect1 id="network-plip"> |
| 6252 |
<title>Parallel Line IP (PLIP)</title> |
| 6253 |
|
| 6254 |
<indexterm><primary>PLIP</primary></indexterm> |
| 6255 |
<indexterm><primary>Parallel Line IP</primary></indexterm> |
| 6256 |
|
| 6257 |
<para>PLIP lets us run TCP/IP between parallel ports. It is |
| 6258 |
useful on machines without network cards, or to install on |
| 6259 |
laptops. In this section, we will discuss:</para> |
| 6260 |
|
| 6261 |
<itemizedlist> |
| 6262 |
<listitem> |
| 6263 |
<para>Creating a parallel (laplink) cable.</para> |
| 6264 |
</listitem> |
| 6265 |
|
| 6266 |
<listitem> |
| 6267 |
<para>Connecting two computers with PLIP.</para> |
| 6268 |
</listitem> |
| 6269 |
</itemizedlist> |
| 6270 |
|
| 6271 |
<sect2 id="network-create-parallel-cable"> |
| 6272 |
<title>Creating a Parallel Cable</title> |
| 6273 |
|
| 6274 |
<para>You can purchase a parallel cable at most computer supply |
| 6275 |
stores. If you cannot do that, or you just want to know how |
| 6276 |
it is done, the following table shows how to make one out of a normal parallel |
| 6277 |
printer cable.</para> |
| 6278 |
|
| 6279 |
<table> |
| 6280 |
<title>Wiring a Parallel Cable for Networking</title> |
| 6281 |
|
| 6282 |
<tgroup cols="5"> |
| 6283 |
<thead> |
| 6284 |
<row> |
| 6285 |
<entry>A-name</entry> |
| 6286 |
|
| 6287 |
<entry>A-End</entry> |
| 6288 |
|
| 6289 |
<entry>B-End</entry> |
| 6290 |
|
| 6291 |
<entry>Descr.</entry> |
| 6292 |
|
| 6293 |
<entry>Post/Bit</entry> |
| 6294 |
</row> |
| 6295 |
</thead> |
| 6296 |
|
| 6297 |
<tbody> |
| 6298 |
<row> |
| 6299 |
<entry><literallayout>DATA0 |
| 6300 |
-ERROR</literallayout></entry> |
| 6301 |
|
| 6302 |
<entry><literallayout>2 |
| 6303 |
15</literallayout></entry> |
| 6304 |
|
| 6305 |
<entry><literallayout>15 |
| 6306 |
2</literallayout></entry> |
| 6307 |
|
| 6308 |
<entry>Data</entry> |
| 6309 |
|
| 6310 |
<entry><literallayout>0/0x01 |
| 6311 |
1/0x08</literallayout></entry> |
| 6312 |
</row> |
| 6313 |
|
| 6314 |
<row> |
| 6315 |
<entry><literallayout>DATA1 |
| 6316 |
+SLCT</literallayout></entry> |
| 6317 |
|
| 6318 |
<entry><literallayout>3 |
| 6319 |
13</literallayout></entry> |
| 6320 |
|
| 6321 |
<entry><literallayout>13 |
| 6322 |
3</literallayout></entry> |
| 6323 |
|
| 6324 |
<entry>Data</entry> |
| 6325 |
|
| 6326 |
<entry><literallayout>0/0x02 |
| 6327 |
1/0x10</literallayout></entry> |
| 6328 |
</row> |
| 6329 |
|
| 6330 |
<row> |
| 6331 |
<entry><literallayout>DATA2 |
| 6332 |
+PE</literallayout></entry> |
| 6333 |
|
| 6334 |
<entry><literallayout>4 |
| 6335 |
12</literallayout></entry> |
| 6336 |
|
| 6337 |
<entry><literallayout>12 |
| 6338 |
4</literallayout></entry> |
| 6339 |
|
| 6340 |
<entry>Data</entry> |
| 6341 |
|
| 6342 |
<entry><literallayout>0/0x04 |
| 6343 |
1/0x20</literallayout></entry> |
| 6344 |
</row> |
| 6345 |
|
| 6346 |
<row> |
| 6347 |
<entry><literallayout>DATA3 |
| 6348 |
-ACK</literallayout></entry> |
| 6349 |
|
| 6350 |
<entry><literallayout>5 |
| 6351 |
10</literallayout></entry> |
| 6352 |
|
| 6353 |
<entry><literallayout>10 |
| 6354 |
5</literallayout></entry> |
| 6355 |
|
| 6356 |
<entry>Strobe</entry> |
| 6357 |
|
| 6358 |
<entry><literallayout>0/0x08 |
| 6359 |
1/0x40</literallayout></entry> |
| 6360 |
</row> |
| 6361 |
|
| 6362 |
<row> |
| 6363 |
<entry><literallayout>DATA4 |
| 6364 |
BUSY</literallayout></entry> |
| 6365 |
|
| 6366 |
<entry><literallayout>6 |
| 6367 |
11</literallayout></entry> |
| 6368 |
|
| 6369 |
<entry><literallayout>11 |
| 6370 |
6</literallayout></entry> |
| 6371 |
|
| 6372 |
<entry>Data</entry> |
| 6373 |
|
| 6374 |
<entry><literallayout>0/0x10 |
| 6375 |
1/0x80</literallayout></entry> |
| 6376 |
</row> |
| 6377 |
|
| 6378 |
<row> |
| 6379 |
<entry>GND</entry> |
| 6380 |
|
| 6381 |
<entry>18-25</entry> |
| 6382 |
|
| 6383 |
<entry>18-25</entry> |
| 6384 |
|
| 6385 |
<entry>GND</entry> |
| 6386 |
|
| 6387 |
<entry>-</entry> |
| 6388 |
</row> |
| 6389 |
</tbody> |
| 6390 |
</tgroup> |
| 6391 |
</table> |
| 6392 |
</sect2> |
| 6393 |
|
| 6394 |
<sect2 id="network-plip-setup"> |
| 6395 |
<title>Setting Up PLIP</title> |
| 6396 |
|
| 6397 |
<para>Get a laplink cable.</para> |
| 6398 |
|
| 6399 |
<para>Confirm that both computers have a kernel with &man.lpt.4; driver |
| 6400 |
support.</para> |
| 6401 |
|
| 6402 |
<screen>&prompt.root; <userinput>grep lp /var/run/dmesg.boot</userinput> |
| 6403 |
lpt0 at 0x378-0x37f irq 7 on isa |
| 6404 |
lpt0: Interrupt-driven |
| 6405 |
lp0: TCP/IP capable interface</screen> |
| 6406 |
|
| 6407 |
<para>Plug in the laplink cable into the parallel interface on |
| 6408 |
both computers.</para> |
| 6409 |
|
| 6410 |
<para>Configure the network interface parameters for <devicename>lp0</devicename> on both |
| 6411 |
sites as <username>root</username>. For example, if you want connect |
| 6412 |
the host <hostid>host1</hostid> with <hostid>host2</hostid>:</para> |
| 6413 |
|
| 6414 |
<programlisting> host1 <-----> host2 |
| 6415 |
IP Address 10.0.0.1 10.0.0.2</programlisting> |
| 6416 |
|
| 6417 |
<para>Configure the interface on <hostid>host1</hostid> by doing:</para> |
| 6418 |
|
| 6419 |
<screen>&prompt.root; <userinput>ifconfig lp0 10.0.0.1 10.0.0.2</userinput></screen> |
| 6420 |
|
| 6421 |
<para>Configure the interface on host2 by doing:</para> |
| 6422 |
|
| 6423 |
<screen>&prompt.root; <userinput>ifconfig lp0 10.0.0.2 10.0.0.1</userinput></screen> |
| 6424 |
|
| 6425 |
|
| 6426 |
<para>You now should have a working connection. Please read the |
| 6427 |
manual pages &man.lp.4; and &man.lpt.4; for more details.</para> |
| 6428 |
|
| 6429 |
<para>You should also add both hosts to |
| 6430 |
<filename>/etc/hosts</filename>:</para> |
| 6431 |
|
| 6432 |
<programlisting>127.0.0.1 localhost.my.domain localhost |
| 6433 |
10.0.0.1 host1.my.domain host1 |
| 6434 |
10.0.0.2 host2.my.domain</programlisting> |
| 6435 |
|
| 6436 |
<para>To confirm the connection works, go to each host and ping |
| 6437 |
the other. For example, on <hostid>host1</hostid>:</para> |
| 6438 |
|
| 6439 |
<screen>&prompt.root; <userinput>ifconfig lp0</userinput> |
| 6440 |
lp0: flags=8851<UP,POINTOPOINT,RUNNING,SIMPLEX,MULTICAST> mtu 1500 |
| 6441 |
inet 10.0.0.1 --> 10.0.0.2 netmask 0xff000000 |
| 6442 |
&prompt.root; <userinput>netstat -r</userinput> |
| 6443 |
Routing tables |
| 6444 |
|
| 6445 |
Internet: |
| 6446 |
Destination Gateway Flags Refs Use Netif Expire |
| 6447 |
host2 host1 UH 4 127592 lp0 |
| 6448 |
&prompt.root; <userinput>ping -c 4 host2</userinput> |
| 6449 |
PING host2 (10.0.0.2): 56 data bytes |
| 6450 |
64 bytes from 10.0.0.2: icmp_seq=0 ttl=255 time=2.774 ms |
| 6451 |
64 bytes from 10.0.0.2: icmp_seq=1 ttl=255 time=2.530 ms |
| 6452 |
64 bytes from 10.0.0.2: icmp_seq=2 ttl=255 time=2.556 ms |
| 6453 |
64 bytes from 10.0.0.2: icmp_seq=3 ttl=255 time=2.714 ms |
| 6454 |
|
| 6455 |
--- host2 ping statistics --- |
| 6456 |
4 packets transmitted, 4 packets received, 0% packet loss |
| 6457 |
round-trip min/avg/max/stddev = 2.530/2.643/2.774/0.103 ms</screen> |
| 6458 |
|
| 6459 |
</sect2> |
| 6460 |
</sect1> |
| 6461 |
|
| 6462 |
<sect1 id="network-ipv6"> |
| 6463 |
<sect1info> |
| 6464 |
<authorgroup> |
| 6465 |
<author> |
| 6466 |
<firstname>Aaron</firstname> |
| 6467 |
<surname>Kaplan</surname> |
| 6468 |
<contrib>Originally Written by </contrib> |
| 6469 |
</author> |
| 6470 |
</authorgroup> |
| 6471 |
<authorgroup> |
| 6472 |
<author> |
| 6473 |
<firstname>Tom</firstname> |
| 6474 |
<surname>Rhodes</surname> |
| 6475 |
<contrib>Restructured and Added by </contrib> |
| 6476 |
</author> |
| 6477 |
</authorgroup> |
| 6478 |
</sect1info> |
| 6479 |
|
| 6480 |
<title>IPv6</title> |
| 6481 |
<para>IPv6 (also know as IPng <quote>IP next generation</quote>) is |
| 6482 |
the new version of the well known IP protocol (also know as |
| 6483 |
<acronym>IPv4</acronym>). Like the other current *BSD systems, |
| 6484 |
FreeBSD includes the <acronym>KAME</acronym> IPv6 reference implementation. |
| 6485 |
So your FreeBSD system comes with all you will need to experiment with IPv6. |
| 6486 |
This section focuses on getting IPv6 configured and running.</para> |
| 6487 |
|
| 6488 |
<para>In the early 1990s, people became aware of the rapidly |
| 6489 |
diminishing address space of IPv4. Given the expansion rate of the |
| 6490 |
Internet there were two major concerns:</para> |
| 6491 |
|
| 6492 |
<itemizedlist> |
| 6493 |
<listitem> |
| 6494 |
<para>Running out of addresses. Today this is not so much of a concern |
| 6495 |
anymore since private address spaces |
| 6496 |
(<hostid role="ipaddr">10.0.0.0/8</hostid>, |
| 6497 |
<hostid role="ipaddr">192.168.0.0/24</hostid>, |
| 6498 |
etc.) and Network Address Translation (<acronym>NAT</acronym>) are |
| 6499 |
being employed.</para> |
| 6500 |
</listitem> |
| 6501 |
|
| 6502 |
<listitem> |
| 6503 |
<para>Router table entries were getting too large. This is |
| 6504 |
still a concern today.</para> |
| 6505 |
</listitem> |
| 6506 |
</itemizedlist> |
| 6507 |
|
| 6508 |
<para>IPv6 deals with these and many other issues:</para> |
| 6509 |
|
| 6510 |
<itemizedlist> |
| 6511 |
<listitem> |
| 6512 |
<para>128 bit address space. In other words theoretically there are |
| 6513 |
340,282,366,920,938,463,463,374,607,431,768,211,456 addresses |
| 6514 |
available. This means there are approximately |
| 6515 |
6.67 * 10^27 IPv6 addresses per square meter on our planet.</para> |
| 6516 |
</listitem> |
| 6517 |
|
| 6518 |
<listitem> |
| 6519 |
<para>Routers will only store network aggregation addresses in their routing |
| 6520 |
tables thus reducing the average space of a routing table to 8192 |
| 6521 |
entries.</para> |
| 6522 |
</listitem> |
| 6523 |
</itemizedlist> |
| 6524 |
|
| 6525 |
<para>There are also lots of other useful features of IPv6 such as:</para> |
| 6526 |
|
| 6527 |
<itemizedlist> |
| 6528 |
<listitem> |
| 6529 |
<para>Address autoconfiguration (RFC2462)</para> |
| 6530 |
</listitem> |
| 6531 |
|
| 6532 |
<listitem> |
| 6533 |
<para>Anycast addresses (<quote>one-out-of many</quote>)</para> |
| 6534 |
</listitem> |
| 6535 |
|
| 6536 |
<listitem> |
| 6537 |
<para>Mandatory multicast addresses</para> |
| 6538 |
</listitem> |
| 6539 |
|
| 6540 |
<listitem> |
| 6541 |
<para>IPsec (IP security)</para> |
| 6542 |
</listitem> |
| 6543 |
|
| 6544 |
<listitem> |
| 6545 |
<para>Simplified header structure</para> |
| 6546 |
</listitem> |
| 6547 |
|
| 6548 |
<listitem> |
| 6549 |
<para>Mobile <acronym>IP</acronym></para> |
| 6550 |
</listitem> |
| 6551 |
|
| 6552 |
<listitem> |
| 6553 |
<para>IPv4-to-IPv6 transition mechanisms</para> |
| 6554 |
</listitem> |
| 6555 |
</itemizedlist> |
| 6556 |
|
| 6557 |
|
| 6558 |
<para>For more information see:</para> |
| 6559 |
|
| 6560 |
<itemizedlist> |
| 6561 |
<listitem> |
| 6562 |
<para>IPv6 overview at <ulink url="http://www.sun.com">Sun.com</ulink></para> |
| 6563 |
</listitem> |
| 6564 |
|
| 6565 |
<listitem> |
| 6566 |
<para><ulink url="http://www.ipv6.org">IPv6.org</ulink></para> |
| 6567 |
</listitem> |
| 6568 |
|
| 6569 |
<listitem> |
| 6570 |
<para><ulink url="http://www.kame.net">KAME.net</ulink></para> |
| 6571 |
</listitem> |
| 6572 |
|
| 6573 |
<listitem> |
| 6574 |
<para><ulink url="http://www.6bone.net">6bone.net</ulink></para> |
| 6575 |
</listitem> |
| 6576 |
</itemizedlist> |
| 6577 |
|
| 6578 |
<sect2> |
| 6579 |
<title>Background on IPv6 Addresses</title> |
| 6580 |
<para>There are different types of IPv6 addresses: Unicast, Anycast and |
| 6581 |
Multicast.<para> |
| 6582 |
|
| 6583 |
<para>Unicast addresses are the well known addresses. A packet sent |
| 6584 |
to a unicast address arrives exactly at the interface belonging to |
| 6585 |
the address.</para> |
| 6586 |
|
| 6587 |
<para>Anycast addresses are syntactically indistinguishable from unicast |
| 6588 |
addresses but they address a group of interfaces. The packet destined for |
| 6589 |
an anycast address will arrive at the nearest (in router metric) |
| 6590 |
interface. Anycast addresses may only be used by routers.</para> |
| 6591 |
|
| 6592 |
<para>Multicast addresses identify a group of interfaces. A packet destined |
| 6593 |
for a multicast address will arrive at all interfaces belonging to the |
| 6594 |
multicast group.</para> |
| 6595 |
|
| 6596 |
<note><para>The IPv4 broadcast address (usually xxx.xxx.xxx.255) is expressed |
| 6597 |
by multicast addresses in IPv6.</para></note> |
| 6598 |
|
| 6599 |
<para>Reserved IPv6 addresses:</para> |
| 6600 |
|
| 6601 |
<screen>ipv6-address prefixlength(Bits) description Notes |
| 6602 |
|
| 6603 |
:: 128 Bits unspecified cf. 0.0.0.0 in IPv4 address |
| 6604 |
::1 128 Bits loopback address cf. 127.0.0.1 in IPv4 |
| 6605 |
::00:xx:xx:xx:xx 96 Bits embedded IPv4 The lower 32 bits are the |
| 6606 |
address IPv4 address. Also called |
| 6607 |
<quote>IPv4 compatible IPv6 |
| 6608 |
address</quote> |
| 6609 |
::ff:xx:xx:xx:xx 96 Bits IPv4 mapped The lower 32 bits are the |
| 6610 |
IPv6 address IPv4 address. For hosts |
| 6611 |
which do not support IPv6 |
| 6612 |
fe80:: - feb:: 10 Bits link-local cf. loopback address in |
| 6613 |
IPv4 |
| 6614 |
fec0:: - fef:: 10 Bits site-local |
| 6615 |
ff:: 8 Bits multicast |
| 6616 |
001 (base 2) 3 Bits global unicast All global unicast |
| 6617 |
addresses are assigned from |
| 6618 |
this pool. The first 3 Bits |
| 6619 |
are <quote>001</quote>.</screen> |
| 6620 |
|
| 6621 |
</sect2> |
| 6622 |
|
| 6623 |
<sect2> |
| 6624 |
<title>Reading IPv6 Addresses</title> |
| 6625 |
<para>The canonical form is represented as: x:x:x:x:x:x:x:x, each |
| 6626 |
<quote>x</quote> being a 16 Bit hex value. For example |
| 6627 |
<hostid role="ip6addr">FEBC:A574:382B:23C1:AA49:4592:4EFE:9982</hostid></para> |
| 6628 |
|
| 6629 |
<para>Often an address will have long substrings of all zeros |
| 6630 |
therefore each such substring can be abbreviated by <quote>::</quote>. |
| 6631 |
For example <hostid role="ip6addr">fe80::1</hostid> |
| 6632 |
corresponds to the canonical form |
| 6633 |
<hostid role="ip6addr">fe80:0000:0000:0000:0000:0000:0000:0001</hostid></para> |
| 6634 |
|
| 6635 |
<para>A third form is to write the last 32 Bit part in the |
| 6636 |
well known (decimal) IPv4 style with dots <quote>.</quote> |
| 6637 |
as separators. For example |
| 6638 |
<hostid role="ip6addr">2002::10.0.0.1</hostid> |
| 6639 |
corresponds to the (hexadecimal) canonical representation |
| 6640 |
<hostid role="ip6addr">2002:0000:0000:0000:0000:0000:0a00:0001</hostid> |
| 6641 |
which in turn is equivalent to |
| 6642 |
writing <hostid role="ip6addr">2002::a00:1</hostid></para> |
| 6643 |
|
| 6644 |
<para>By now the reader should be able to understand the following:</para> |
| 6645 |
|
| 6646 |
<screen>&prompt.root; <userinput>ifconfig</userinput></screen> |
| 6647 |
|
| 6648 |
<programlisting>rl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 |
| 6649 |
inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255 |
| 6650 |
inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1 |
| 6651 |
ether 00:00:21:03:08:e1 |
| 6652 |
media: Ethernet autoselect (100baseTX ) |
| 6653 |
status: active</programlisting> |
| 6654 |
|
| 6655 |
<para><hostid role="ip6addr">fe80::200:21ff:fe03:8e1%rl0</hostid> |
| 6656 |
is an auto configured link-local address. It includes the |
| 6657 |
scrambled Ethernet MAC as part of the auto configuration.</para> |
| 6658 |
|
| 6659 |
<para>For further information on the structure of IPv6 addresses |
| 6660 |
see RFC2373.</para> |
| 6661 |
</sect2> |
| 6662 |
|
| 6663 |
<sect2> |
| 6664 |
<title>Getting Connected</title> |
| 6665 |
|
| 6666 |
<para>Currently there are four ways to connect to other IPv6 hosts and networks:</para> |
| 6667 |
|
| 6668 |
<itemizedlist> |
| 6669 |
<listitem> |
| 6670 |
<para>Join the experimental 6bone</para> |
| 6671 |
</listitem> |
| 6672 |
|
| 6673 |
<listitem> |
| 6674 |
<para>Getting an IPv6 network from your upstream provider. Talk to your |
| 6675 |
Internet provider for instructions.</para> |
| 6676 |
</listitem> |
| 6677 |
|
| 6678 |
<listitem> |
| 6679 |
<para>Tunnel via 6-to-4</para> |
| 6680 |
</listitem> |
| 6681 |
|
| 6682 |
<listitem> |
| 6683 |
<para>Use the freenet6 port if you are on a dial-up connection.</para> |
| 6684 |
</listitem> |
| 6685 |
</itemizedlist> |
| 6686 |
|
| 6687 |
<para>Here we will talk on how to connect to the 6bone since it currently seems |
| 6688 |
to be the most popular way.</para> |
| 6689 |
|
| 6690 |
<para>First take a look at the 6bone site and find a 6bone connection nearest to |
| 6691 |
you. Write to the responsible person and with a little bit of luck you |
| 6692 |
will be given instructions on how to set up your connection. Usually this |
| 6693 |
involves setting up a GRE (gif) tunnel.</para> |
| 6694 |
|
| 6695 |
<para>Here is a typical example on setting up a &man.gif.4; tunnel:</para> |
| 6696 |
|
| 6697 |
<screen>&prompt.root; <userinput>ifconfig gif0 create</userinput> |
| 6698 |
&prompt.root; <userinput>ifconfig gif0</userinput> |
| 6699 |
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 |
| 6700 |
&prompt.root; <userinput>ifconfig gif0 tunnel <replaceable>MY_IPv4_ADDR</replaceable> <replaceable>HIS_IPv4_ADDR</replaceable></userinput> |
| 6701 |
&prompt.root; <userinput>ifconfig gif0 inet6 alias <replaceable>MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR</replaceable></userinput></screen> |
| 6702 |
|
| 6703 |
<para>Replace the capitalized words by the information you received from the |
| 6704 |
upstream 6bone node.</para> |
| 6705 |
|
| 6706 |
<para>This establishes the tunnel. Check if the tunnel is working by &man.ping6.8; |
| 6707 |
'ing ff02::1%gif0. You should receive two ping replies.</para> |
| 6708 |
|
| 6709 |
<note><para>In case you are intrigued by the address ff02:1%gif0, this is a |
| 6710 |
multicast address. %gif0 states that the multicast address at network |
| 6711 |
interface gif0 is to be used. Since we <command>ping</command> a multicast address the |
| 6712 |
other endpoint of the tunnel should reply as well).</para></note> |
| 6713 |
|
| 6714 |
<para>By now setting up a route to your 6bone uplink should be rather |
| 6715 |
straightforward:</para> |
| 6716 |
|
| 6717 |
<screen>&prompt.root; <userinput>route add -inet6 default -interface gif0</userinput> |
| 6718 |
&prompt.root; <userinput>ping6 -n <replaceable>MY_UPLINK</replaceable></userinput></screen> |
| 6719 |
|
| 6720 |
<screen>&prompt.root; <userinput>traceroute6 www.jp.FreeBSD.org</userinput> |
| 6721 |
(3ffe:505:2008:1:2a0:24ff:fe57:e561) from 3ffe:8060:100::40:2, 30 hops max, 12 byte packets |
| 6722 |
1 atnet-meta6 14.147 ms 15.499 ms 24.319 ms |
| 6723 |
2 6bone-gw2-ATNET-NT.ipv6.tilab.com 103.408 ms 95.072 ms * |
| 6724 |
3 3ffe:1831:0:ffff::4 138.645 ms 134.437 ms 144.257 ms |
| 6725 |
4 3ffe:1810:0:6:290:27ff:fe79:7677 282.975 ms 278.666 ms 292.811 ms |
| 6726 |
5 3ffe:1800:0:ff00::4 400.131 ms 396.324 ms 394.769 ms |
| 6727 |
6 3ffe:1800:0:3:290:27ff:fe14:cdee 394.712 ms 397.19 ms 394.102 ms</screen> |
| 6728 |
|
| 6729 |
<para>This output will differ from machine to machine. By now you should be |
| 6730 |
able to reach the IPv6 site <ulink url="http://www.kame.net">www.kame.net</ulink> |
| 6731 |
and see the dancing tortoise - that is if you have a IPv6 enabled browser such as |
| 6732 |
<filename role="package">mozilla</filename>.</para> |
| 6733 |
|
| 6734 |
</sect2> |
| 6735 |
|
| 6736 |
<sect2> |
| 6737 |
<title>DNS in the IPv6 World</title> |
| 6738 |
<para>There are two new types of DNS records for IPv6:</para> |
| 6739 |
|
| 6740 |
<itemizedlist> |
| 6741 |
<listitem> |
| 6742 |
<para>AAAA records,</para> |
| 6743 |
</listitem> |
| 6744 |
|
| 6745 |
<listitem> |
| 6746 |
<para>A6 records</para> |
| 6747 |
</listitem> |
| 6748 |
</itemizedlist> |
| 6749 |
|
| 6750 |
<para>Using AAAA records is straightforward. Assign your hostname to the new |
| 6751 |
IPv6 address you just got by adding:</para> |
| 6752 |
|
| 6753 |
<programlisting>MYHOSTNAME AAAA MYIPv6ADDR</programlisting> |
| 6754 |
|
| 6755 |
<para>To your primary zone DNS file. In case you do not serve your own |
| 6756 |
<acronym>DNS</acronym> zones ask your <acronym>DNS</acronym> provider. |
| 6757 |
Current versions of <application>bind</application> (version 8.3 and 9) |
| 6758 |
support AAAA records.</para> |
| 6759 |
</sect2> |
| 6760 |
</sect1> |
| 6761 |
</chapter> |
| 6762 |
|
| 6763 |
<!-- |
| 6764 |
Local Variables: |
| 6765 |
mode: sgml |
| 6766 |
sgml-declaration: "../chapter.decl" |
| 6767 |
sgml-indent-data: t |
| 6768 |
sgml-omittag: nil |
| 6769 |
sgml-always-quote-attributes: t |
| 6770 |
sgml-parent-document: ("../book.sgml" "part" "chapter") |
| 6771 |
End: |
| 6772 |
--> |
| 6773 |
<!-- LocalWords: config mnt www --> |