TCP/IP is the most commonly used communications protocol suite in the world. It powers the Internet, home networks, and everything in between. So it's an important topic for computer technicians and anyone who uses a computer. It's the basis for most of what we perform on today's computer networks.
Check out the video below and read on for more about TCP/IP and Linux.
- Debian Server
- Debian Client
What is a Computer Network?
Before getting into TCP/IP, let's step back and discuss what a computer network is. We'll keep it simple.
Pretty simple definition, huh? We could go into much more depth, but for the purposes of this article, I'm attempting to keep it concise. Want more blunt, to-the-point statements? Try this:
Mind-blowing! But true. From a computer networking perspective, all of our desktop computers, laptops, smartphones, tablets, IoT devices, and everything else, are just moving data back and forth. That's it. Whether for business or pleasure, it's the data that we are concerned with—always.
Let's give an example of a basic computer network. Take a look at the following figure.
In Figure 1-1 you see a typical local area network (LAN). In the center is a switch. This connects everything: PCs, laptops, printers, mobile devices (indirectly via a wireless access point), and whatever else the network needs. As you can see, the term "computers" is something I use loosely. More accurately, it could be any system or device that has an IP address associated with it and can communicate on the network. Any host, per se.
Transmission Control Protocol/Internet Protocol (TCP/IP) is a suite of protocols used by computers to communicate with each other. It includes the protocols TCP, and IP, but also many others, such as ICMP, ARP, HTTP, FTP, POP, SMTP, DNS, DHCP, and so on. IP addresses are used by each computer that runs TCP/IP to identify them and to facilitate the communication of packets of data.
A typical example of an IP network is 192.168.1.0. In a network such as this, you might have a system that uses the IP address 192.168.1.58. In this case, the network portion of the address is 192.168.1. The host portion is .58. It's the host portion that differentiates between systems on the same network. Take a look at the following figure where we revisit our Local Area Network but this time, we add some IP addresses.
For example, one computer might have the IP address 192.168.1.73. Another might have 192.168.1.142. And the gateway might use 192.168.1.1. It's that last octet, that last number that sets each system apart. Other IP networks can have a larger host portion. For example, in the 172.17.0.0 network, the network portion is 172.17, and the host portion is 0.0. So, a system on the 172.17 network might have an address such as 172.17.51.3. "51.3" would be the host portion of the IP address.
It's also important to understand the difference between static and dynamic IP addresses. A static IP address is one that has been typed into the system manually. A dynamic IP address is one that has been obtained automatically by a computer.
The great bulk of computer systems out there will obtain their IP addresses from a DHCP server—somewhere. For example, your SOHO router might hand out IP addresses automatically. Or it could be something more advanced. The important thing is that the process is automated. It would be silly to manually input IP addresses to every system on a network. Think of the time and effort required to do that, not to mention the risk of error and duplicate IP addresses. No, dynamic addressing is the way to go for client systems. However, systems such as servers, switches, routers, wireless access points, and printers, are often configured with a static address. This way, it is known that the address won't change over time, as is potentially the case with dynamic addresses.
As mentioned, in Figure 2 you see that two PCs have IP addresses ending in .73 and .142. Those are most likely obtained automatically from a DHCP server. On the other hand, the router (gateway) might use 192.168.1.1, which is most likely assigned manually. Be sure to understand the difference between static and dynamic IP addresses and when to use each of them.
Lab: TCP/IP Example in Linux
In this example we use the ip a command in Linux. In the console (or terminal) we can type
ip a and view the results. Here's an example of a Debian Linux system:
In Example 1 we see that there are three network interfaces on this system: lo — which is the local loopback adapter; enp1s0 — which is the main network adapter; and docker0 — which is a virtual adapter placed on the system by the Docker container system. The one we are interested in is enp1s0.
If you look at the fourth line of that adapter you will see "inet 10.0.2.52/24". "inet" is short for "Internet". That tells us the Internet address or simply, the IP address of the computer.
More accurately, our system uses the IPv4 address 10.0.2.52. The /24 tells us the netmask that the IP address uses. /24 is equivalent to 255.255.255.0. This means that the network portion of the IP address is 10.0.2 and the host portion is .52. Therefore, this system can communicate with other systems on the same 10.0.2.0 network. You now know more about Linux and TCP/IP than the average bear.
See this article on classful and classless IP networks.
This is just the tip of the iceberg when it comes to the ip command. We'll discuss and demonstrate that command more as we continue through these lessons. But for now, try using it to analyze any Linux system you come across. The more you run it, the more you will learn about TCP/IP in Linux.
In addition, this is just the beginning of TCP/IP. It is a vast subject that you could spend a lifetime becoming an expert on. Remember that just about everything we do in computer networking has its basis in TCP/IP.
- TCP/IP Tutorial:
Click the drop-down arrow to the right of each question to display the answer.
1. What does TCP/IP stand for?
Transmission Control Protocol/Internet Protocol. Those are the two original protocols within the TCP/IP suite, though today there are hundreds more.
2. What command can you use in the Linux Terminal to find out the IP address?
ip a (the full command is ip address show)
3. What type of address would a router usually have—static, or dynamic?
4. What is the default network portion of the IP address 192.168.1.58?
By default, the network portion is 192.168.1, and the host portion would be .58. That is assuming that the netmask is /24.
Bonus! What is the 4-octet equivalent of /24?
In binary, that number would be
If you add up the 1s, you get 24! yes!
Whether you are browsing the web, sending an email, or connecting via SSH to your beloved Linux servers, TCP/IP is at the core of your work. Computers of all kinds communicate with each other using IP addresses and TCP/IP protocols.
The TCP/IP suite is massive. It has a multitude of protocols. It is beyond formidable. It is a fantastic work of technology created by the geniuses of our time.
And if you're wondering how long I've been working with TCP/IP (and computers in general), here's a nice little image for you.
Actually, my roots go back way before this, but these were good times. Some of my best TCP/IP work was performed in this system, however, it required in-depth knowledge of the TCP/IP stack. While today's systems make it much easier to work with TCP/IP, the core principles remain the same.
Become proficient in IP addressing and TCP/IP protocols and you will have a serious advantage over the competition!