[ Pobierz całość w formacie PDF ]
.When setting up the network all by yourself, you have toassign IP addresses yourself as described below.Hosts within a local network should usually share addresses from the same logical IP net-work.Hence you have to assign an IP network address.If you have several physical net-works, you either have to assign them di erent network numbers, or use subnetting to splityour IP address range into several subnetworks.If your network is not connected to the Internet, you are free to choose any legalnetwork address.You only have to make sure to choose one from classes A, B, or C, elsethings will most likely not work properly.However, if you intend to get on the Internet inthe near future, you should obtain an o cial IP address now.The best way to proceed isto ask your network service provider to help you.If you want to obtain a network numberjust in case you might get on the Internet someday, request a Network Address ApplicationForm from hostmaster@internic.net.To operate several Ethernets or other networks, once a driver is available , you haveto split your network into subnets.Note that subnetting is required only if you have morethan one broadcast network; point-to-point links don't count.For instance, if you have oneEthernet, and one or more SLIP links to the outside world, you don't need to subnet yournetwork.The reason for this will be explained in chapter 7.As an example, the brewery's network manager applies to the NIC for a class B networknumber, and is given 191.72.To accomodate the two Ethernets, she decides to useeight bits of the host part as additional subnet bits.This leaves another eight bits for thehost part, allowing for 254 hosts on each of the subnets.She then assigns subnet number1 to the brewery, and gives the winery number 2.Their respective network addresses are5.6.Writing hosts and networks Files 84191 72 0 0191 72 1 0 191 72 2 0Brewery Subnet Gateway Winery SubnetFigure 5.1: Virtual Brewery and Virtual Winery the two subnets.thus 191.72.1.0 and 191.72.2.The subnet mask is 255.255.255.vlager, which is the gateway between the two networks, is assigned a host number of 1on both of them, which gives it the IP addresses 191.72.1.1 and 191.72.2.1, respectively.Figure 5.1 shows the two subnets, and the gateway.Note that in this example I am using a class B network to keep things simple; a class Cnetwork would be more realistic.With the new networking code, subnetting is not limited tobyte boundaries, so even a class C network may be split into several subnets.For instance,you could use 2 bits of the host part for the netmask, giving you four possible subnets with64 hosts on each.15.6 Writing hosts and networks FilesAfter you have subnetted your network, you should prepare for some simple sort of hostnameresolution using the etc hosts le.If you are not going to use DNS or NIS for addressresolution, you have to put all hosts in the hosts le.Even if you want to run DNS or NIS during normal operation, you want to have somesubset of all hostnames in etc hosts nevertheless.For one, you want to have some sort ofname resolution even when no network interfaces are running, for example during boot time.This is not only a matter of convenience, but also allows you to use symbolic hostnames in1The last number on each subnet is reserved as the broadcast address, so it's in fact 63 hosts per subnet.5.6.Writing hosts and networks Files 85your rc.inet scripts.Thus, when changing IP addresses, you only have to copy an updatedhosts le to all machines and reboot, rather than having to edit a large number of rc lesseparately.Usually, you will put all local hostnames and addresses in hosts, adding thoseof any gateways and NIS servers if used.2Also, during intial testing, you should make sure your resolver only uses information fromthe hosts le.Your DNS or NIS software may come with sample les that may producestrange results when being used.To make all applications use etc hosts exclusively whenlooking up the IP address of a host, you have to edit the etc host.conf le.Comment outany lines that begin with the keyword order by preceding them with a hash sign, and insertthe lineorder hostsThe con guration of the resolver library will be covered in detail in chapter 6.The hosts le contains one entry per line, consisting of an IP address, a hostname, andan optional list of aliases for the hostname.The elds are separated by spaces or tabs, andthe address eld must begin in column one.Anything following a hash sign is regardedas a comment and is ignored.Hostnames can be either fully quali ed, or relative to the local domain.For vale, youwould usually enter the the fully quali ed name, vale.vbrew.com, and vale by itself inthe hosts le, so that it is known by both its o cial name and the shorter local name.This is an example how a hosts le at the Virtual Brewery might look.Two specialnames are included, vlager-if1 and vlager-if2 that give the addresses for both interfacesused on vlager.Hosts file for Virtual Brewery Virtual WineryIP local fully qualified domain name127.1 localhost191.72.1.1 vlager vlager.vbrew.com191.72.1.1 vlager-if1191.72.1.2 vstout vstout.vbrew.com191.72.1.3 vale vale.vbrew.com2You will need the address of any NIS servers only if you use Peter Eriksson's NYS.Other NIS imple-mentations locate their servers at run-time only by using ypbi nd.5.7.Interface Con guration for IP 86191.72.2.1 vlager-if2191.72.2.2 vbeaujolais vbeaujolais.vbrew.com191.72.2.3 vbardolino vbardolino.vbrew.com191.72.2.4 vchianti vchianti.vbrew.comJust as with a host's IP address, you sometimes would like to use a symbolic name fornetwork numbers, too.Therefore, the hosts le has a companion called etc networks thatmaps network names to network numbers and vice versa.At the Virtual Brewery, we mightinstall a networks le like this:3etc networks for the Virtual Brewerybrew-net 191.72.1.0wine-net 191.72.2.05.7 Interface Con guration for IPAfter setting up your hardware as explained in the previous chapter, you have to makethese devices known to the kernel networking software.A couple of commands are used tocon gure the network interfaces, and initialize the routing table.These tasks are usuallyperformed from the rc.inet1 script each time the system is booted.The basic tools for thisare called ifcon g where if" stands for interface , and route.ifcon g is used to make an interface accessible to the kernel networking layer.Thisinvolves the assignment of an IP address and other parameters, and activating the interface,also known as taking up." Being active here means that the kernel will send and receiveIP datagrams through the interface.The simplest way to invoking it isifconfig interface ip-addresswhich assigns ip-address to interface and activates it.All other parameters are set todefault values.For instance, the default subnet mask is derived from the network class ofthe IP address, such as 255.255.0 for a class B address.ifcon g is described in detail atthe end of this chapter.route allows you to add or remove routes from the kernel routing table.It can be invokedasroute add| del targetwhere the add and del arguments determine whether to add or delete the route to target.3Note that names in networks must not collide with hostnames from the hosts le, else some programsmay produce strange results.5.7.Interface Con guration for IP 875.7.1 The Loopback InterfaceThe very rst interface to be activated is the loopback interface:ifconfig lo 127.1Occasionally, you will also see the dummy hostname localhost being used instead of theIP address.ifcon g will look up the name in the hosts le where an entry should declare itas the hostname for 127
[ Pobierz całość w formacie PDF ]