Linux All-in-One For Dummies, 5th Edition (2014)
Book III. Networking
Chapter 2. Setting Up a Local Area Network
In This Chapter
Understanding TCP/IP networks
Setting up an Ethernet local area network
Discovering how to configure TCP/IP networking
Connecting a LAN to the Internet
Linux comes with built-in support for Transmission Control Protocol/Internet Protocol (TCP/IP) networking, as do most modern operating systems from Windows to Mac OS. You can have TCP/IP networking over many different physical interfaces, such as Ethernet cards, serial ports, and parallel ports.
Typically, you use an Ethernet network for your local area network (LAN) — at your office or even your home (if you happen to have two or more systems at home) — with wireless (the subject of the next chapter) gaining in popularity in most locations.
This chapter describes how to set up an Ethernet network. Even if you have a single PC, you may need to set up an Ethernet network interface so that you can connect to high-speed Internet access (that uses a DSL or cable modem somewhere along the way.)
You can understand TCP/IP networking best if you think in terms of a four-layer model, with each layer responsible for performing a particular task. The layered model describes the flow of data between the physical connection to the network and the end-user application. Figure 2-1shows the four-layer network model for TCP/IP.
In this four-layer model, information always moves from one layer to the next. For example, when an application sends data to another application, the data goes through the layers in this order: application⇒transport⇒network⇒physical. At the receiving end, the data goes up from physical⇒network⇒transport⇒application.
Figure 2-1: You can understand TCP/IP using the four-layer network model.
Each layer has its own set of protocols — conventions — for handling and formatting the data. If you think of sending data as something akin to sending letters through the postal service, a typical protocol is a preferred sequence of actions for a task, such as addressing an envelope (first the name, then the street address, and then the city, state, and zip or other postal code).
These four layers, depending on what reference you look at, might have different names. For example, if you look at the old DOD model, the transport is called host-to-host, network is called internetwork or Internet, application is process/application, and physical is network access.
Here’s what each of the four layers does, top to bottom:
· Application: Runs the applications that users use, such as e-mail readers, file transfers, and web browsers. Application-level protocols are Simple Mail Transfer Protocol (SMTP) and Post Office Protocol (POP) for e-mail, HyperText Transfer Protocol (HTTP) for the web, and File Transfer Protocol (FTP) for file transfers. Application-level protocols also have a port number that you can think of as an identifier for a specific application. For example, port 80 is associated with HTTP or the web server.
· Transport: Sends data from one application to another. The two most important protocols in this layer are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). TCP guarantees delivery of data; UDP just sends the data without ensuring that it actually reaches the destination.
· Network: This layer is responsible for getting data packets from one network to another. If the networks are far apart, the data packets are routed from one network to the next until they reach their destination. The primary protocol in this layer is the Internet Protocol (IP).
· Physical: Refers to the physical networking hardware (such as an Ethernet card or token ring card) that carries the data packets in a network.
The beauty of the layered model is that each layer takes care of only its specific task, leaving the rest to the other layers. The layers can mix and match — you can have TCP/IP network over any type of physical network medium, from Ethernet to radio waves (in a wireless network). The software is modular as well; each layer can be implemented in different modules. For example, typically the transport and network layers already exist as part of the operating system, and any application can make use of these layers.
TCP/IP and the Internet
TCP/IP has become the protocol of choice on the Internet — the network of networks that evolved from ARPANET. The U.S. Government’s Advanced Research Projects Agency (ARPA) initiated research in the 1970s on a new way of sending information, using packets of data sent over a network. The result was ARPANET: a national network of linked computers. Subsequently, ARPA acquired a Defense prefix and became DARPA. Under the auspices of DARPA, the TCP/IP protocols emerged as a popular collection of protocols for internetworking — communication among networks.
TCP/IP has flourished because the protocol is open. That means the technical descriptions of the protocol appear in public documents, so anyone can implement TCP/IP on specific hardware and software.
TCP/IP also made great inroads because stable, working software was available. Instead of a paper description of network architecture and protocols, the TCP/IP protocols started out as working software — and who can argue with what’s already working? These days, as a result, TCP/IP rules the Internet.
When you have many computers on a network, you need a way to identify each one uniquely. In TCP/IP networking, the address of a computer is the IP address. Because TCP/IP deals with internetworking, the address is based on the concepts of a network address and a host address. You may think of the idea of a network address and a host address as having to provide two add-resses to identify a computer uniquely:
· Network address indicates the network on which the computer is located.
· Host address indicates a specific computer on that network.
The network and host addresses together constitute an IP address, and it’s a 4-byte (32-bit) value. The convention is to write each byte as a decimal value and to put a dot (.) after each number. Thus you see network addresses such as 18.104.22.168. This way of writing IP addresses is known as dotted-decimal or dotted-quad notation.
What about IP (IPv6)?
When the 4-byte IP address was created, the number of available addresses seemed adequate. Now, however, the 4-byte addresses are running out. The Internet Engineering Task Force (IETF) recognized the potential for running out of IP addresses in 1991 and began work on the next-generation IP addressing scheme. They called it IPng (for Internet Protocol Next Generation) and intended for it to eventually replace the old 4-byte addressing scheme (called IPv4, for IP version 4).
Several alternative addressing schemes for IPng were proposed and debated. The final contender, with a 128-bit (16-byte) address, was dubbed IPv6 (for IP version 6). On September 18, 1995, the IETF declared the core set of IPv6 addressing protocols to be an IETF Proposed Standard. By now, there are many RFCs (Request for Comments) dealing with various aspects of IPv6, from IPv6 over PPP for the transmission of IPv6 packets over Ethernet.
IPv6 is designed to be an evolutionary step from IPv4. The proposed standard provides direct interoperability between hosts using the older IPv4 addresses and any new IPv6 hosts. The idea is that users can upgrade their systems to use IPv6 when they want and that network operators are free to upgrade their network hardware to use IPv6 without affecting current users of IPv4. Sample implementations of IPv6 are being developed for many operating systems, including Linux. For more information about IPv6 in Linux, consult the Linux IPv6 HOWTO at www.tldp.org/HOWTO/Linux+IPv6-HOWTO. For information about IPv6 in general, visit the IPv6 home page atwww.ipv6.org.
The IPv6 128-bit addressing scheme allows for a total of 2128 or 340,282,366,920,938,463,463,374,607,431,768,211,456 theoretically assignable addresses. That should last us for a while!
In decimal notation, a byte (which has 8 bits) can have a value between 0 and 255. Thus a valid IP address can use only the numbers between 0 and 255 in the dotted-decimal notation.
Internet services and port numbers
The TCP/IP protocol suite has become the lingua franca of the Internet because many standard services are available on any system that supports TCP/IP. These services make the Internet tick by facilitating the transfer of mail, news, and web pages. These services go by well-known names such as the following:
· DHCP (Dynamic Host Configuration Protocol) is for dynamically configuring TCP/IP network parameters on a computer. DHCP is primarily used to assign dynamic IP addresses and other networking information (such as name server, default gateway, and domain names) needed to configure TCP/IP networks. The DHCP server listens on port 67.
· FTP (File Transfer Protocol) is used to transfer files between computers on the Internet. FTP uses two ports — data is transferred on port 20, and control information is exchanged on port 21.
· DNS (Domain Name System) is used to translate domain names into IP addresses. This service runs on port 53.
· HTTP (HyperText Transfer Protocol) is a protocol for sending documents from one system to another. HTTP is the underlying protocol of the World Wide Web. By default, the web server and client communicate on port 80. When combined with SSL/TLS, the protocol becomes HTTPS and the port changes to 443.
· SMTP (Simple Mail Transfer Protocol) is for exchanging e-mail messages between systems. SMTP uses port 25 for information exchange.
· POP3 (Post Office Protocol version 3) is used by the client to receive mail and it uses port 110. When combined with SSL/TLS for security, the port changes to 995.
· IMAP (Internet Message Access Protocol) can also be used by clients to interact with mail (in place of POP3) and it uses port 143. When combined with SSL/TLS for security, the port changes to 993.
· NNTP (Network News Transfer Protocol) is for distribution of news articles in a store-and-forward fashion across the Internet. NNTP uses port 119.
· NetBIOS is used by Windows for networking and it utilizes a number of ports, the most common of which is 139 which is used for the session.
· SSH (Secure Shell) is a protocol for secure remote login and other secure network services over an insecure network. SSH uses port 22.
· TELNET is used when a user on one system logs in to another system on the Internet. (The user must provide a valid user ID and password to log in to the remote system.) TELNET uses port 23 by default, but the TELNET client can connect to any port.
· SNMP (Simple Network Management Protocol) is for managing all types of network devices on the Internet. Like FTP, SNMP uses two ports: 161 and 162.
· Rendezvous Directory Service (used by Cisco) uses port 465.
· TFTP (Trivial File Transfer Protocol) is for transferring files from one system to another. (It’s typically used by X terminals and diskless workstations to download boot files from another host on the network.) TFTP data transfer takes place on port 69.
· NFS (Network File System) is for sharing files among computers. NFS uses Sun’s Remote Procedure Call (RPC) facility, which exchanges information through port 111.
A well-known port is associated with each of these services. The TCP protocol uses each such port to locate a service on any system. (A server process — a special computer program running on a system — provides each service.)
Setting Up an Ethernet LAN
Ethernet is a standard way to move packets of data between two or more computers connected to a single hub, router, or switch. (You can create larger networks by connecting multiple Ethernet segments with gateways.) To set up an Ethernet LAN, you need an Ethernet card for each PC. Linux supports a wide variety of Ethernet cards for the PC.
Ethernet is a good choice for the physical data-transport mechanism for the following reasons:
· Ethernet is a proven technology that has been in use since the early 1980s.
· Ethernet provides good data-transfer rates: typically 10 million bits per second (10 Mbps), although 100-Mbps Ethernet and Gigabit Ethernet (1,000 Mbps) are now common.
· Ethernet hardware is often built into the PC or can be installed at a relatively low cost. (PC Ethernet cards cost about $10–20.)
· With wireless Ethernet, you can easily connect laptop PCs to your Ethernet LAN without having to run wires all over the place. (Go to Chapter 3 of this minibook for more information on wireless Ethernet.)
How Ethernet works
So what makes Ethernet tick? In essence, it’s the same thing that makes any conversation work: listening and taking turns.
In an Ethernet network, all systems in a segment are connected to the same wire. A protocol is used for sending and receiving data because only one data packet can exist on the single wire at any time. An Ethernet LAN uses a data-transmission protocol known as Carrier-Sense Multiple Access/Collision Detection (CSMA/CD) to share the single transmission cable among all the computers. Ethernet cards in the computers follow the CSMA/CD protocol to transmit and receive Ethernet packets.
The idea behind the CSMA/CD protocol is similar to the way in which you have a conversation at a party. You listen for a pause (that’s sensing the carrier) and talk when no one else is speaking. If you and another person begin talking at the same time, both of you realize the problem (that’s collision detection) and pause for a moment; then one of you starts speaking again. As you know from experience, everything works out.
In an Ethernet LAN, each Ethernet card checks the cable for signals — that’s the carrier-sense part. If the signal level is low, the Ethernet card sends its packets on the cable; the packet contains information about the sender and the intended recipient. All Ethernet cards on the LAN listen to the signal, and the recipient receives the packet. If two cards send out a packet simultaneously, the signal level in the cable rises above a threshold, and the cards know a collision has occurred. (Two packets have been sent out at the same time.) Both cards wait for a random amount of time before sending their packets again.
Ethernet was invented in the early 1970s at the Xerox Palo Alto Research Center (PARC) by Robert M. Metcalfe. In the 1980s, Ethernet was standardized by the cooperative effort of three companies: Digital Equipment Corporation (DEC), Intel, and Xerox. Using the first initials of the company names, that Ethernet standard became known as the DIX standard. Later, the DIX standard was included in the 802-series standards developed by the Institute of Electrical and Electronics Engineers (IEEE). The final Ethernet specification is formally known as IEEE 802.3 CSMA/CD, but people continue to call it Ethernet.
Ethernet sends data in packets (discrete chunks also known as frames). You don’t have to hassle much with the innards of Ethernet packets, except to note the 6-byte source and destination addresses. Each Ethernet controller has a unique 6-byte (48-bit) address at the physical layer; every packet must have one.
Any time you hear experts talking about Ethernet, you’ll also hear some bewildering terms used for the cables that carry the data. Here’s a quick rundown.
The original Ethernet standard used a thick coaxial cable, nearly half an inch in diameter. This wiring is called thicknet, thickwire, or just thick Ethernet although the IEEE 802.3 standard calls it 10Base5. That designation means several things: The data-transmission rate is 10 megabits per second (10 Mbps); the transmission is baseband (which simply means that the cable’s signal-carrying capacity is devoted to transmitting Ethernet packets only), and the total length of the cable can be no more than 500 meters. Thickwire was expensive, and the cable was rather unwieldy. Unless you’re a technology history buff, you don’t have to care one whit about 10Base5 cables.
Nowadays, several other forms of Ethernet cabling are more popular. An alternative to thick Ethernet cable is thinwire, or 10Base2, which uses a thin, flexible coaxial cable. A thinwire Ethernet segment can be, at most, 185 meters long. The other, more recent, alternative is Ethernet over unshielded twisted-pair cable (UTP), known as 10BaseT. More recent Ethernet cabling options that support higher transmission rates include 100BaseT4, 100BaseT2, and 100BaseTX for 100-Mbps Ethernet and 1000BaseT for Gigabit Ethernet. The Electronic Industries Association/Telecommunications Industries Association (EIA/TIA) defines the following five categories of shielded and unshielded twisted-pair cables:
· Category 1 (Cat 1): Traditional telephone cable.
· Category 2 (Cat 2): Cable certified for data transmissions up to 4 Mbps.
· Category 3 (Cat 3): Cable that can carry signals up to a frequency of 16 MHz. Cat 3 is the most common type of wiring in old corporate networks, and it normally contains four pairs of wire. Now considered obsolete.
· Category 4 (Cat 4): Cable that can carry signals up to a frequency of 20 MHz. Cat 4 wires aren’t common. Now considered obsolete.
· Category 5 (Cat 5): Cable that can carry signals up to a frequency of 100 MHz. Cat 5 cables normally have four pairs of copper wire. Cat 5 UTP is the most popular cable used in new installations today. This category of cable is being superseded by Category 5e (enhanced Cat 5).
· Category 5e (Cat 5e): Similar to Cat 5 but with improved technical parameters, such as near-end cross talk and attenuation. Cat 5e cables support 10BaseT, 100BaseT4, 100BaseT2, and 100BaseTX and 1000BaseT Ethernet. Nowadays, Cat 5e is the minimum acceptable wiring.
· Category 6 (Cat 6): Similar to Cat 5e but capable of carrying signals up to a frequency of 250 MHz. Cat 6 cables can support all existing Ethernet standards and also support Gigabit Ethernet standard 1000BaseTX, which uses two pairs of wires in each direction (as opposed to all four pairs for 1000BaseT Ethernet over Cat 5e cables).
To set up a 10BaseT or 100BaseT Ethernet network, you need an Ethernet hub — a hardware box with RJ-45 jacks. (This type of jack looks like a big telephone jack.) You build the network by running twisted-pair wires (usually Category 5 cables) from each PC’s Ethernet card to this hub. You can get a 4-port 10BaseT/100BaseT hub for about $40. Figure 2-2 shows a typical small 10BaseT/100BaseT Ethernet LAN that you may set up at a small office or your home.
When you install any of the Linux distributions from this book’s companion DVD-ROM on a PC connected with an Ethernet card, the Linux kernel automatically detects the Ethernet card and installs the appropriate drivers. The installer also lets you set up TCP/IP networking.
The Linux kernel loads the driver for the Ethernet card every time it boots. To verify that the Ethernet driver is loaded, type the following command in a terminal window:
dmesg | grep eth0
On one of my Linux PCs, I get the following output when I type that command:
eth0: RealTek RTL8139 at 0xf0e20000, 00:0c:76:f4:38:b3, IRQ 161
eth0: Identified 8139 chip type ‘RTL-8101’
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
eth0: no IPv6 routers present
You should see something similar, showing the name of your Ethernet card and other related information.
Figure 2-2: You can use an Ethernet hub to set up a 10BaseT or 100BaseT Ethernet LAN.
Configuring TCP/IP Networking
When you set up TCP/IP networking during Linux installation, the installation program prepares all appropriate configuration files using the information you provide. This means that you typically never have to manually configure the network. However, most Linux distributions come with GUI tools to configure the network devices, just in case something needs changing. For all distributions, the steps are similar.
In Ubuntu, for example, you can use the graphical network configuration tool. To start the GUI network configuration tool, choose System Settings⇒Network. The network configuration tool displays a dialog box, as shown in Figure 2-3. You can then configure your network through the choices that appear in the dialog box including settings for wired and wireless. The Airplane Mode toggle makes it convenient to temporarily disable the network.
Clicking the Options button displays a dialog box similar to the one shown in Figure 2-4. From here, you can configure everything from the security to the settings for the each protocol to use. On the General tab (shown in Figure 2-5), you can configure whether the connection will always try to be established — and whether all users can use the network.
Figure 2-3: Move through the dialog box choices to configure the connection.
Figure 2-4: The Options button allows you to configure your connections.
In most cases, you can set the network card so it can automatically obtain an IP address (which is the case when the Ethernet card is connected to DSL or cable modem) by using DHCP. If your network doesn’t have a DHCP server (which is typically built into routers), you have to specify an IP address for the network card. If you are running a private network, you may use IP addresses in the 192.168.0.0 to 192.168.255.255 range. (Other ranges of addresses are reserved for private networks, but this range suffices for most needs.)
Figure 2-5: The General tab allows you to configure the connection to always attempt to be available.
Connecting Your LAN to the Internet
If you have a LAN with several PCs, you can connect the entire LAN to the Internet by using DSL or a cable modem. Basically, you can share the high-speed DSL or cable modem connection with all the PCs in the LAN.
Chapter 1 of this minibook explains how to set up a DSL or cable modem. In this section, I briefly explain how to connect a LAN to the Internet so all the PCs can access the Internet.
The most convenient way to connect a LAN to the Internet via DSL or cable modem is to buy a hardware device called DSL/cable modem NAT router with a 4- or 8-port Ethernet hub. NAT stands for Network Address Translation, and the NAT router can translate many private IP addresses into a single, externally known IP address. The Ethernet hub part appears to you as a number of RJ-45 Ethernet ports where you can connect the PCs to set up a LAN. In other words, you need only one extra box besides the DSL or cable modem.
Figure 2-6 shows how you might connect your LAN to the Internet through a NAT router with a built-in Ethernet hub. You need a DSL or cable modem hookup for this scenario to work, and you have to sign up with a DSL provider (for DSL service) or with a cable provider for cable Internet service.
When you connect a LAN to the Internet, the NAT router acts as a gateway for your LAN. The NAT router also dynamically provides IP addresses to the PCs in your LAN. Therefore, on each PC, you have to set up the networking options to obtain the IP address dynamically.
Figure 2-6: Connect your LAN to the Internet through a NAT router with a built-in Ethernet hub.
If you are using DSL and incurring speeds slower than you should (2 Mbps when it should be 5 Mbps, for example), try a different phone cord. Make sure that the phone cord that runs from the modem to the wall jack is no longer than 10 feet and does not go through a filter, surge protector, or splitter (which can attenuate the signal). All other phone devices (fax machines, for example) should go through a filter or surge protector.
Your LAN can mix and match all kinds of computers: Some may be running Linux, and some may be running Microsoft Windows or any other operating system that supports TCP/IP. When configuring the network settings, remember to select the option that enables Linux to automatically obtain IP add-ress settings and DNS information with DHCP.