Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1338 / 49 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 17:

Configuring the local network

< Лекция 16 || Лекция 17: 12345 || Лекция 18 >
Аннотация: In this chapter: Network configuration with sysinstall. Manual network configuration: Automatic configuration with DHCP; Configuring PC Card networking cards; Setting up wireless networking. Routing; ISP’sroute setup. Looking at the routing tables; Packet forwarding. Configuration summary.
Ключевые слова: Basic, BSD, networking, this, chapter, AND, look, configure, network, First, still, Ethernet, require, issue, set, additional, information, DESCRIBE, ITS, configuration, system, initialization routine, include, significant, portion, network environment, addition, standard, IP, define, if, CAN, log in, AS, SEE, Menu, entire, real, network board, list, board, hardware, used, choose, GET, question, book, answer, NEXT, DHCP, server, ALL, Internet, network configuration, filling, VALUES, Local, host, tab, field, domain, call, Full, VIA, running, NUMERIC, form, global, go, ONE, leave, empty, NOT, course, difference, class, net, fill, CASE, configuration information, startup, interface, section, perform, function, mailing list, foot, moment, manual, TIME, find, summary, DCO, network mask, abbreviate, broadcast address, theoretical, loopback interface, boot time, system requirements, negotiation, full duplex, parallel port, summarization, laptop, FROM, concept, default, FAR, client, recognizer, pc card, interface card, system operation, network card, bypassing, static routing, hang, sleeve, SSID, BSS, power consumption, power saving, WEP, unchangeable, link layer, direct connection, back, example, problem, MET, data packet, with, deliver, routing table, implementation, available, WHERE, routing decision, very, output, previous, base address, counterpart, hidden, corner, isp, even, choice, environment, default route, congestion, routed protocols, address range, receive data, prepend, option, column, keyword, second, path, destination, Unix, pointer, SEQUENCE, Last, MOST, important, gateway, MAN, table, best fit, first fit, Entry, ignore, Command, e-intermediary, desired, convenience, local addressing

In "Networks and the Internet" we looked at the basic concepts surrounding BSD networking. In this chapter and the following two, we’ll look at what we need to do to configure a network, first manually, then automatically. Configuring PPP is still a whole lot more difficult than configuring an Ethernet, and they require more prerequisites, so we’ll dedicate "Configuring PPP" , to that issue.

In this chapter, we’ll first look at example.org in the reference network on page 294, since it’s the easiest to set up. After that, we’ll look at what additional information is needed to configure machines on example.net.

Network configuration with sysinstall

To configure a network, you must describe its configuration to the system. The system initialization routines that we discussed on page 528 include a significant portion that sets up the network environment. In addition, the system contains a number of standard IP configuration files that define your system’s view of the network. If you didn’t configure the network when you installed your system, you can still do it now. Log in as root and start sysinstall. Select the Index, then Network Interfaces. You will see the menu of Figure 17-1 , which is the same as in Figure 6-4 on page 97. On a standard 80x25 display it requires scrolling to see the entire menu. The only real network board on this list is xl0, the Ethernet board. The others are standard hardware that can also be used as network interfaces.

Network setup menu

Рис. 17.1. Network setup menu

Choose the Ethernet board, xl0 You get a question about whether you want to use IPv6 configuration. In this book we doesn’t d discuss IPv6, so answer No. Next you get a question about DHCP configuration. We discuss DHCP configuration on page 302. If you already have a DHCP server set up, you may prefer to answer yes to this question, which is all you need to do. If you answer No, the next menu asks us to set the internet parameters. Figure 17-2 shows the network configuration menu after filling in the values.

Network configuration menu

Рис. 17.2. Network configuration menu

Specify the fully qualified local host name. When you tab to the Domain: field, the domain is filled in automatically. We have chosen to call this machine presto, and the domain is example.org. In other words, the full name of the machine is presto.example.org. Its IP address is 223.147.37.2. In this configuration, all access to the outside world goes via gw.example.org, which has the IP address 223.147.37.5. The name server is located on the same host, presto.example.org. If the name server isn’t running when this information is needed, we must specify all addresses in numeric form, as shown.

What happens if you don’t have a domain name? If you’re connecting to the global Internet, you should go out and get one-see page 318. But in the meantime, don’t fake it. Just leave the fields empty. If you’re not connecting to the Internet, of course, it doesn’t make much difference what name you choose.

As is usual for a class C network, the net mask is 255.255.255.0. You don’t need to fill in this informationif you leave this field without filling it in, sysinstall inserts it for you. Normally, as in this case, you wouldn’t need any additional options to ifconfig

sysinstall saves configuration information in /etc/rc.conf. When the system starts the startup scripts use this information to configure the network. It also optionally starts the interface immediately. In the next section we’ll look at the commands it uses to perform this function.

Manual network configuration

Usually FreeBSD configures your network automatically when it boots. To do so, it uses the configuration files in/etc. So why do it manually? There are several reasons:

  • It makes it easier to create and maintain the configuration files if you know what’s going on behind the scenes.
  • It makes it easier to modify something "on the fly" you don’t have to reboot just because you have changed your network configuration.
  • With this information, you can edit the configuration files directly rather than use the menu interface, which saves a lot of time.
We spend a lot of time discussing this point on the FreeBSD mailing lists. One thing’s for sure: neither method of configuration is perfect. Both menu-based and text-file-based configuration schemes offer you ample opportunity to shoot yourself in the foot. But at the moment, the configuration file system is easier to check if you understand what’s going on.That’s the reason for the rest of this chapter.

In this section, we’ll look at the manual way to do things first, and then we’ll see how to put it in the configuration files so that it gets done automatically next time. You can find a summary of the configuration files and their contents on page 551.

Describing your network

We saw that systems connect to networks via network interfaces. The kernel detects the interfaces automatically when it starts, but you still need to tell it what interfaces are connected to which networks, and even more importantly, which address your system has on each network. In addition, if the network is a broadcast network, such as an Ethernet, you need to specify a range of addresses that can be reached directly on that network, network mask.

Ethernet interfaces

Once we have understood these concepts, it’s relatively simple to use the ifconfig program to set them. For example, for the Ethernet interface on system gw, with IP address 223.147.37.5, we need to configure interface dcO. The network mask is the standard value for a class C network, 255.255.255.0. That’sall we need to know:

# ifconfig dc0 inet 223.147.37.5 net mask 255.255.255.0 up

In fact, this is more than you usually need. The inet tells the interface to use Internet protocol Version 4 (the default), and up tells it to bring it up (which it does anyway). In addition, this is a class C network address, so the net mask defaults to 255.255.255.0. As a result, you can abbreviate this to:

# ifconfig dc0 223.147.37.5

Note that this is different from what Linux requires. With Linux you must supply explicit net mask and broadcast address specifications.

As we saw on page 290, it has become typical to abbreviate net masks to the character / followed by the number of 1 bits set in the network mask. ifconfig understands this usage, so if you wanted to set a non-standard network mask of, say, 255.255.255.240, which has 28 bits set, you could write:

# ifconfig dc0 223.147.37.5/28
< Лекция 16 || Лекция 17: 12345 || Лекция 18 >