Summary

Linux is a network-enabled OS, and it relies on its networking features more than most OSs do. This networking is built around TCP/IP, so you should understand the basics of this protocol stack, including IP addresses, hostnames, and routing. Most Linux distributions provide tools to configure networking during system installation, but if you want to temporarily or permanently change your settings, you can do so. Tools such as ifconfig and route can temporarily change your network configuration, and editing critical files or running distribution specific utilities enables you to make your changes permanent.

FAQ

What information is needed to configure a computer on a static IP network?

Four pieces of information are important: the IP address, the netmask (aka the network mask or subnet mask), the network’s gateway address, and the address of at least one DNS server. The first two are required, but if you omit either or both of the latter two, basic networking will function, but you won’t be able to connect to the Internet or use most DNS hostnames.

When to use /etc/hosts rather than DNS?

The /etc/hosts file provides a static mapping of hostnames to IP addresses on a single computer. Therefore, maintaining this file on a handful of computers for a small local network is fairly straightforward, but when the number of computers rises beyond a few or when IP addresses change frequently, running a DNS server to handle local name resolution makes more sense.

What tools are used to translate between hostnames and IP addresses?

The nslookup program can perform these translations in both directions using either command-line or interactive modes, but this program has been deprecated. You’re better off using host for simple lookups or dig for more complex tasks.

What is the function of network ports?

Network ports enable packets to be directed to specific programs; each network-enabled program attaches itself to one or more ports, sending data from that port and receiving data directed to the port. Certain ports are assigned to be used by specific servers, enabling client programs to contact servers by directing requests at specific port numbers on the server computers.

When to use static IP addresses or DHCP?

Static IP address configuration involves manually entering the IP address and other information and is used when a network lacks a Dynamic Host Configuration Protocol (DHCP) server or when a computer shouldn’t be configured by that server (say, because the computer is the DHCP server). DHCP configuration is easier to set up on the client but works only if the network has a DHCP server system.

What does the route command accomplish?

The route command displays or modifies the routing table, which tells Linux how to direct packets based on their destination IP addresses.

What are basic network diagnostic tools?

The ping program tests basic network connectivity, and traceroute and tracepath perform similar but more complex tests that can help you localize where on a route between two systems a problem exists. The netstat utility is a general-purpose network status tool that can report a wide variety of information about your network configuration. Packet sniffers such as tcpdump provide detailed information about the network packets “seen” by a computer, which can be a useful way to verify that certain packet types are actually being sent or received.