Bookmark this page

Chapter 7.  Linux Networking and System Resources

Abstract

Goal

Describe fundamental concepts of networking, verify network settings, and monitor system resources.

Sections
  • Networking Basics (and Quiz)

  • Transferring Files Remotely (and Guided Exercise)

  • Viewing Linux Processes (and Guided Exercise)

Lab
  • Linux Networking and System Resources

Networking Basics

Objectives

  • Describe networking concepts and view network configuration information.

Networking Basics

A network is a connection between two or more computers. Historically, connected computers were considered to be either a server or a client. A server monitored communication for incoming requests, and a client was any computer that made requests to a server. In modern computing, these definitions have expanded. Today, any computer that is prepared to answer incoming requests can be considered a server. Any computer that makes a request to another computer can be considered a client. In fact, the same computer can act as a server for some computers, and a client to others.

Communication between computers requires three components:

Infrastructure

The medium over which communication occurs.

Protocol

A common language that is used for communication.

Addresses

A means to find and identify other computers to communicate with.

Infrastructure

Historically, computer networks were formed over the existing worldwide network of telephone lines. Today, telephone lines are still in use, although they are gradually being supplanted by fiber cables, which use light to send data at faster rates than the copper wires of telephone lines. For small local networks, radio waves are a common networking medium, which is called wifi. When you join a wifi network, you join it through an access point such as a router.

TCP/IP Protocol

After a computer connects to a network, it can use the Transmission Control Protocol (TCP) and Internet Protocol (IP) to send messages over the network. There are other protocols for communication, such as the User Datagram Protocol (UDP) and Real-time Transport Protocol (RTP), but TCP is designed for reliability. After a message is sent over TCP, the computer that receives the data sends an acknowledgment that it received the message. If the sender does not get acknowledgment back within a specific time frame, then the computer sends the data again.

Data is sent in pieces and then reassembled on the receiving side. TCP handles the fragmentation and assembly of data. The Internet Protocol (IP) transports each chunk of data across the network. Together, these two protocols are known as TCP/IP. The TCP/IP combination serves as the foundational technology of modern networking, including the internet. The internet was named after the portmanteau of "interconnected networks" because it connects small local networks into one big network.

IP Addresses

For communication to reach its intended destination, or to even have an intended destination, computers on a network must be able to identify one another. The Dynamic Host Configuration Protocol (DHCP) assigns each computer on a local network an IP address. Each local network, as defined by a router, is assigned a global IP address.

When you use one computer to send data to another computer on your local network, you use local IP addresses. When you use a computer to send data to another computer on the internet, you use the global IP address of the destination network, and the router that defines that network locates the individual computer. In both cases, you might not be aware that you are using an IP address at all. Many organizations use shortcuts to IP addresses in the form of a hostname for an individual computer, and a domain name as the address of the computer or router that serves as the gateway into a network.

Identifying IP Addresses

On small networks, like the ones that many people use at home or at small businesses, a DHCP server that is embedded in the network router assigns an IP address to each device that joins the network. On large networks at major corporations or data centers, a dedicated DHCP server assigns IP addresses. If you are on a network, then you have an IP address. On Linux, knowing your IP address makes it possible for you to log in to your computer from a different computer.

On the GNOME desktop, you can find your IP address in the Settings application. Launch Settings, and select Network in the left column. Your active and inactive networks are listed in the right panel. On the lab computers, the Wired network is the only active one, so click the gear icon to the right of the Wired field on the Network pane.

In the Wired dialog, the number to the right of the IPv4 Address label is your local IP address.

Figure 7.1: GNOME network information example

To find your external or global IP address, you must query another computer on the internet so that it can report the address that your request comes from. There are servers online dedicated to this task, so open a web browser and navigate to the https://www.ifconfig.me site. The IP address that the web page displays is your global IP address.

Figure 7.2: Global IP address example

On the command line, retrieve your IP address by using the ip command with the addr and show subcommands.

[user@host ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:d6:80:6d brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    altname ens3
    inet 172.25.250.9/24 brd 172.25.250.255 scope global dynamic noprefixroute enp1s0
       valid_lft 3578sec preferred_lft 3578sec
    inet6 fe80::5254:ff:fed6:806d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

On every Linux system, the lo device represents an internal communication channel for the operating system. The IP address for the lo device is always 127.0.0.1, and this address is only useful to the computer's internal routing system.

Listings after the lo device are network connections, which vary depending on the computer's configuration. On the lab computers, the second device is eth0, which is a wired connection to a router. The IP address for the eth0 device is listed to the right of the inet (not inet6) entry. In this example, the local IP address is 172.25.250.9.

To identify your global IP address, query the https://www.ifconfig.me website by using the curl command.

[user@host ~]$ curl ifconfig.me
72.32.49.67[user@host ~]$

Contacting a Network Host with Ping

If you know the IP address of another computer on your network, then you can test whether you can reach it by using the ping command and the IP address as an argument. Use the ping command -c option to limit the number of pings to send. The ping command uses the Internet Control Message Protocol (ICMP) to request an echo response from another computer.

[user@host ~]$ ping -c 1 172.25.250.10
PING 172.25.250.10 (172.25.250.10) 56(84) bytes of data.
64 bytes from 172.25.250.10: icmp_seq=1 ttl=64 time=347 ms

--- 172.25.250.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 346.990/346.990/346.990/0.000 ms

You can also ping a domain name over the internet to test whether you are online.

[user@host ~]$ ping -c 1 google.com
64 bytes from syd09s23-in-f14.1e100.net (142.250.66.206): icmp_seq=1 ttl=116 time=52.1 ms

--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 52.110/52.110/52.110/0.000 ms

A failed ping returns an error.

[user@host ~]$ ping -c 1 example.fake
ping: example.fake: Name or service not known

References

curl(1), ip(1), and ping(1) man pages

For more information about TCP, refer to the Specification of Internet Transmission Control Program (RFC 675) at https://datatracker.ietf.org/doc/html/rfc675

Revision: rh104-9.1-3d1f2bc