Before getting into how you configure Linux for a network, let s take a step back. Think about the physical layout of your network. While this is a book on Linux, most network problems are actually physical. Loose wires, unconnected cables, dust in hubs or routers, and similar issues are the most common causes of network problems. Based on the OSI model discussed in Chapter 20 , you need to consider five categories of hardware on a LAN:
Physical-level transmission media
Your computer sends your data as 1s and 0s over transmission media . The data may be electrical impulses through copper wires, light pulses through fiber- optic cables, or even radio waves through the air. Transmission media work at the Physical layer of the OSI model.
Whatever means you use to transmit signals, there is a range limit. For example, an Ethernet network may not work as well as you hope if the length of twisted-pair copper cable between a computer and a hub is greater than the specified maximum cable length of 328 feet (100 meters ). Briefly, here are some things to watch out for with physical media such as copper wires or fiber-optic cables:
Connections Check your connections. Many networks fail because cables are not properly plugged in.
Length Networks have a range. The standard Category 5 network cable may not allow your Fast Ethernet network to perform up to capacity if your cables are longer than 100 meters.
Installation Don t bend your cables too much. Severe bends can stretch parts of a cable, reducing their ability to carry data.
A hub is the center of most modern LANs. Wired hubs are essentially boxes with sockets. With the right cable, you can connect a computer to each socket. When multiple computers are connected to a hub, the configuration looks like the spokes coming out of the center of a wheel, which is known as a star configuration. (I don t know why it isn t called a hub-and-spoke-configuration.)
Digital signals degrade with distance. A hub can rebuild a digital signal and retransmit it at its original strength. Because they just work with the 1s and 0s of computer communication, hubs also work at the Physical layer of the OSI model.
A switch is often used to split a larger LAN into two or more different logical network segments. Switches keep a database of hardware addresses on a LAN; in other words, they work at layer 2 of the OSI model.
Once first contact is made between two computers, they continue their conversation with their hardware addresses. Since switches know the hardware addresses on a LAN, they can retransmit every message (like a hub) and direct it toward the destination computer.
Older switches are sometimes known as bridges. Both are designed at the Data-Link layer (2) of the OSI model.
Routers transmit data between two or more LANs. A router has a network card on each of these LANs. In a TCP/IP network, each network card has an IP address. Thus, routers work at the Network layer of the OSI model.
In many cases, the gateway address that you configure in a file such as /etc/sysconfig/network should be the IP address of a router connected to your network.
Alternatively, you can configure a Linux computer as a router. First you need two or more network cards, connected to different networks. Then you must enable IP Forwarding in the kernel. It s easy to do with an IPv4 configuration by changing a setting in the /proc directory:
# echo 1 > /proc/sys/net/ipv4/ip_forward
You can configure a router within a LAN, if needed, and it will perform the same functions as a switch or even a hub. To make sure this change is still there the next time you boot Linux, open the /etc/sysctl.conf file and verify that the following variable is set to 1:
net.ipv4.ip_forward = 1
For most purposes, Linux assumes that routers and gateways are functionally equivalent. For example, if your network is connected to an outside network though an Ethernet network card eth0 via a router, you can specify its connection to your LAN in the ifcfg-eth0 file in the /etc/sysconfig/networking/devices directory as your GATEWAY IP address.
However, a gateway serves a different purpose, because it can connect LANs using different protocol stacks such as TCP/IP and IPX/SPX. It works at the OSI Application layer.