![]()
Linux for Newbies, Part 12:
Home Networking, Part 1
by Gene Wilburn
(The Computer Paper, July 2000. Copyright © Wilburn Communications Ltd. All rights reserved)
This beginners series, based on Red Hat Linux 6.x, has alternated between system setup information and the basic Unix knowledge needed to make your use of Linux more enjoyable and interesting. We've gone through setup and connecting to the Internet, and we've looked at essential Linux utilities, basic system administration, and fundamental security issues.
As we close out the first year of the column, we'll begin to move on to more intermediate and advanced topics. The next three installments (starting with this one) will focus on home networking. This month we'll cover the basics. Next month we'll focus on Samba (creating a Linux server that can be seen in Windows Network Neighborhood), and the month after we'll look at connecting your entire home network to the Internet using IP Masquerading and firewall rules.
It's common these days to have two or more computers per household, especially in homes that have kids using computers for homework and for Internet communications. When you purchased a new PC, you may have kept the old one around. You may have a mixed PC/Mac environment, and you might even have a portable you bring home from the office.
Whenever you have more than one PC in the home environment, it makes sense to think in terms of networking them together to be able to share resources such as printers and disk space, and to be able to move files easily from one system to another.
Linux can easily participate in a home network, and in fact it can become the central server for the entire home. With Samba, Linux can look like an NT server to Windows PCs. With Netatalk, it can participate in a Macintosh environment. And, of course, it can do both at the same time. You can also do this with an expensive NT server, but Linux generally has better performance and the cost is right. All the software you need either comes on your Linux CD-ROM, or is available for download, for free.
Networking Hardware
The basic hardware you need for a home network is a hub, some network interface cards, or NICs, and some twisted-pair Ethernet cables. You need one NIC for each workstation (and possibly two NICs for your server, as we'll see in the third installment). Many new PCs and Macs come with a NIC already installed. A couple of years ago, 10Base-T (10 Mbit/sec) NICs and hubs were standard. Today the industry is moving towards broad acceptance of 100Base-T (100 Mbit/sec). Most current cards are 10/100 and can work on both types of networks.
For a home network, you are unlikely to need anything faster than 10Base-T, but if you're purchasing a new NIC, you might as well get 10/100 to allow you to move to a faster network sometime in the future.
NICs, for Intel PCs, come in a variety of types and generations. Older PCs require ISA NICs, while new ones generally use PCI NICs. If you have acquired an older server, it might even be EISA based, requiring an EISA NIC. Most portables use PCMCIA network adapters.
Before purchasing a NIC, you should check the hardware compatibility guide at www.redhat.com/support. Linux supports a broad range of NICs but some are better supported than others. If you choose a well-supported brand and model, it makes integration easier.
I've used a variety of NICs in Linux boxes and have had good luck with most of them. Intel EtherExpress Pro NICs are a good match for busy servers, but for home machines cards such as those made by D-Link or the SMC EZ series work well and are reasonably priced.
For a home network you can use one of the little 10Mbit minihubs you find in computer stores for under $50. Minihubs tend to come in 5- or 8-port models.
Unless you want to invest in good crimping tools, purchase pre-made lengths of twisted-pair Ethernet cables with RJ45 connectors already attached. They come in a variety of pre-made lengths but you should always get them a little longer than the distance from your PC or Mac to the hub so you have a little slack for putting the cable behind furniture or changing the location of your workstations.
The hub is the centre of your home network. If you have a couple of workstations in the same room, all you need to do is connect each workstation's NIC to the hub and you'll have the hardware part done (assuming you've eliminated any IRQ conflicts, etc., with the NICs.)
If you want to connect computers in different rooms in your home, you will have to investigate drawing cable through your house, or investigate wireless solutions. Wireless is tidy but somewhat expensive and generally slower than cable.
TCP/IP Network Addressing
When you've got the hardware bits installed and the wires connected, you're ready to begin adjusting your operating system software. The first thing you need to do is lay out the organization of your home network.
Almost all networking today is TCP/IP based and probably everyone has seen a typical IP address, such as 192.168.45.33. The way IP works, certain ranges of IP addresses define a "network" and every node on the network has a unique number (IP address).
There are connectivity rules and methods that allow individual networks to be connected to other individual networks, allowing a user on one network to communicate with a user on another network. Multiply these connection points by thousands upon thousands and you've got an extremely large shared network called the Internet.
When IP addressing was first invented, it seemed there were so many numbers allocated initially that they would never run out. Then came the explosion of Internet usage and now official IP numbers, reserved for registered domains, are in short supply.
That, however, is a problem for businesses and ISPs, not for homes. Fortunately the standards bodies also reserved a few series of "private" IP numbers that were designated as numbers that would never be used in public. There are three classes of these private numbers: A, B and C. In this column we'll only concentrate on Class C, the most popular class for small networks (any good network book will explain the difference in TCP/IP network classes).
The Internet standards bodies have reserved 192.168.0.0-192.168.255.255 for private use. That means that for your home network you can choose any range from 192.168.0.0 to 192.168.255.0. That's 256 choices (0-255). Within each of these networks, you can have 256 devices attached. Actually it's only 254 choices because the first and last number of the range are almost always reserved.
If you've not set up a home network before then just follow this recipe: your home network is going to be 192.168.0.0-255. The address 192.168.0.0 is reserved as your "network" address and 192.168.0.255 is reserved as your "broadcast" address. By convention, you should also reserve 192.168.0.1 as your gateway address. Make this the address of your Linux box, or the Linux box you intend to use to connect to the Internet if you have more than one Linux machine.
In a Class C network, the subnet mask is 255.255.255.0. I'm going to skip the mathematics involved with subnet masking. You can look it up in a networking book if you are interested (and it really is quite interesting, if you enjoy knowing how things work).
So, let's say your home network consists of a Linux box, a Win95 PC and a WinNT workstation. Make Linux 192.168.0.1. Assign Win95 192.168.0.2 and WinNT 192.168.0.3. All have the subnet mask 255.255.255.0. (You can do this with Macintosh too, but I don't have a Mac so can't offer the details.)
For Red Hat Linux, you can enter the IP number and subnet mask via the X Window Control Panel, by Linuxconf, or by the command-line program netconfig. (Once you get to know networking better you can do this by hand by editing the networking scripts directly.)
For Windows, use Control Panel, Networking to set the fixed IP Address and subnet mask. You should give your network a bogus domain name--something that would never be recognized as valid on the Internet. For example I call my private domain "mynet.all" and my boxes are given names such as "darwin.mynet.all", "wallace.mynet.all", "austen.mynet.all" and "gamer.mynet.all".
We'll assume, at this point that you're not yet on the Internet with your entire network, so leave DNS server blank. You also don't have a DHCP server (at least not yet).
Once you've filled in these values a few times, it becomes second nature.
Fixed vs. Dynamic IP
After you've gained some experience with home networking, you may want to experiment with DHCP, or the automatic assigning of IP numbers to your non-Linux systems. Linux comes with an excellent DHCP server that eliminates the need to hard-code IP addresses onto all the workstations.
For a home network, hard coding IP addresses is really not a big deal, but having DHCP can be very beneficial if you have a portable PC from work that you want to plug into your home network. It makes your home network very versatile, particularly if you plan to connect your home network to the Internet.
Connecting it all together
Once you have all the hardware connected and all the IP addresses entered, your home network should look similar to this diagram. Now for the magic moment. Reboot all your systems so that the networking information is active. Now log into your Linux box. If your Windows PC has been assigned 192.168.0.2, type the following from Linux:
$ ping 192.168.0.2Perhaps no thrill in computing is as great as the one you get when you first see the machines on your home network successfully ping one another.
Now go to your Windows PC, open a command prompt and type
C:\>ping 192.168.0.1Congratulations! You have connectivity.
Unless you want to create a DNS (Domain Name Service) on your Linux box to study DNS (a perfectly fine goal), you can keep name resolution simple by adding host tables to the workstations on your network.
In Linux, the host table is /etc/hosts. If your PC is named "charlie" and your Linux machine is named "parker", edit /etc/hosts and add the following:
192.168.0.1 parker parker.mynet.all 192.168.0.2 charlie charlie.mynet.allIf you have more than two machines, add an entry in the hosts table for each workstation on your network.
For Windows 95 or 98, add an identically configured text file called HOSTS in your \windows directory. On NT add it to \winnt\system32\drivers\etc.
Once you have this in place you can now ping any address machines by name. The hosts table converts names back to IP addresses:
$ ping charlieThat's a great start. Once the hardware infrastructure is in place and the IP numbers are assigned, you're ready for some fun. In the next installment, we'll take a look at Samba, a Linux networking service that makes Linux look like an NT to your Windows workstations. Samba can be used for file sharing and printer sharing.
Gene Wilburn (gene@wilburn.ca) is a Toronto-based IT specialist, musician and writer who operates a small farm of Linux servers.
-30-