Linux Networking Tutorial

Do you need help in learning the Networking concepts in Linux Operating Systems? If that is the case, you have landed in the right place. This tutorial covers a detailed explanation of Networking concepts in Linux. By the end of this guide, you will gain a clear understanding of Linux Network Administration and its working.

Linux has been used as one of the most popular tools for server deployments, OS servers, and other applications. Thanks to its security, performance, and stability. But working on a single Linux system is easy, but when we have to exchange information with multiple machines, we need an efficient network so that we can easily share the information. In this detailed article, we will learn about Networking in Linux so that we do not face any issues in our development lifecycles. So, let us start without any delay.

Table of Contents

What is Linux

Simply, Linux is an Operating System that is used in many applications, environments, embedded systems, etc. Linus Torvalds Finnish-American software engineer developed it as kernel software. The main reason behind this was that POSIX was not freely available. It has many distributions such as Ubuntu, CentOS, and Debian. The main feature of Linux is the multiuser and multitasking capabilities to execute multiple processes. It also supports networking protocols for deployment and cloud environments. 

Elevate your career with Mindmajix's Linux Networking Training! Whether you're new or experienced, our comprehensive program prepares you to thrive in this dynamic field. Join us to excel in Linux Networking!

Networking Basics

After getting an idea of Linux, let us understand the basic networking concepts in Computer Systems. Networking is about how computers exchange information, what rules and conventions they use to share the information, and how they are organized to share the data. The various terminologies in Computer Networks are described below.

MindMajix Youtube Channel

Network Layers

Network layers refer to the conceptual divisions within a network architecture that organize communication between devices. The OSI (Open Systems Interconnection) model and the TCP/IP model are two widely used frameworks that define these layers.

Generally, these layers include the physical layer, data link layer, network layer, transport layer, session layer, presentation layer, and application layer. Each layer plays a specific role in ensuring efficient communication and data exchange between devices

Broadcasting

It allows the computers to transmit the message so that the nodes in the network can receive it. A single sender transmits data, and all devices on the network receive and process the information. It allows us to update and share the resources within a confined network. The types of Broadcasting include the following: 

Unicast: It sends data from one machine to another machine. It is a point-to-point method that allows us to send information to a single device. 
Multicast: In the Multicast method, the computer sends information to multiple devices within a network.
Broadcast: It enables the computer to send the information to all the devices within a network. 
Anycast: In this method, the machine sends the data from the machine to the nearest machine. Thus, it chooses the optimal path using routing methods.
Geocast: We can say that it’s just like broadcasting. The only factor is the geographical area within which the data is sent. 

Types of Networks

Types of Networks refer to the capability and range of a particular network. The following types of networks are generally seen within a network. 

Types of Computer Networks 
LAN: It stands for Local Area Network which is limited to the geographical area such as home or office. 
MAN: Metropolitan Area Network covers larger areas such as cities or towns. It acts as a connection between multiple LANs. 
WAN: Wide Area Network connects the MANs and covers the entire country or continent. 

Protocols 

Everyting process in the computer has some rules or policies that need to be followed during the process. Thus, Protocols are a set of rules for the exchange of data between devices in a network. They define how data is formatted, transmitted, received, and acknowledged by the receiver.  The various network protocols include TCP/IP (Transmission Control Protocol/Internet Protocol), HTTP (Hypertext Transfer Protocol), FTP (File Transfer Protocol), and SMTP (Simple Mail Transfer Protocol).

Check Out: Linux Interview Questions

DNS (Domain Name System)

The computers in the network have an IP address that is mapped to the domain names. The reason behind this is that domain names such as google.com are easier to remember than the IP address of the form 192.168.0.1. 

Working of Domain Name System in Networking 
So, translates human-readable domain names into IP addresses. This helps us to identify the resources on the internet. When you type a URL into a web browser, DNS translates that domain name into the corresponding IP address so that the browser can connect to the desired server. Hence., the DNS plays a crucial role in enabling users to access websites.

Routing

The computer can send the message to other machines through multiple paths. So, Routing helps us to select the optimal path from the source to the destination in a network. It is implemented using the Router devices that operate at the network layer. The various routing algorithms allow us to find the most efficient path. Working of Routing Concepts

These algorithms depend on multiple parameters such as distance, network traffic, and reliability. Along with this, the Dynamic routing protocols, such as OSPF (Open Shortest Path First) and RIP (Routing Information Protocol) ensure the accurate data transfer.

Overview of Networking in Linux

Linux Network Interfaces

The network interface is like the medium of interaction between the computers so that they can exchange information with each other. The Network Interfaces can be in physical form such as an Ethernet Card or loopback interface. Linux uses two methods to name the network interfaces eth0, eth1, and wlan0. Along with this, it uses new naming conventions such as enp3s0 and wlp2s0. These are based on the hardware conventions. 

The Linux users can view or manipulate the network interfaces using the ‘ifconfig’ or ‘ip’  command. Also, you can use configuration files such as ‘/etc/network/interfaces’ or ‘/etc/sysconfig/network-scripts/ifcfg-eth0’ to configure the Network Interfaces in the Linux Environment.  Type the command ‘ifconfig -a’ to list out all the Network Interfaces in the Linux as shown below.

linux network interfaces

MAC Address

MAC (Media Access Control) is a unique identifier for the identification of the network interface. In other words, it is the address of the hardware of the machine within the network. The important fact is that the MAC address is assigned by the manufacturer of the device. It is part of the Data Link Layer and follows the format of the six-digit hexadecimal digits that are unique for each machine. 

This ensures that no two devices share the same identifier and data packet can be delivered without any conflict. For example, the device can have the MAC address as ‘ 00:1A:2B:3C:4D:5E’ to know the physical address of the device.

 IP Address

IP (Internet Protocol) Address is a numerical string that locates a device in the network. It is different from the MAC Address as it is assigned by the Internet Service Provider to determine how the machines are connected to the network. IP Address can be of two types namely IPv4 and IPv6. In the Linux System, both types are supported. The length of the IPv4 is 32-bit for example, 192.168.1.1. On the other hand, the length of the IPv6 is 128-bit like the IP address ‘2001:0db8:85a3:0000:0000:8a2e:0370:7334’  

In addition to this, if the IP address is static in the Linux System we cannot change it. A static IP address is manually configured with fields such as specific IP address, subnet mask, gateway, and DNS server. But this consumes time. So, using the Dynamic Host Configuration Protocol (DHCP), the Dynamic IP Addresses are assigned to machines when they are connected to the network. 

Related Article: Linux Advanced Functions And Commands

Network Configuration

Linux stores the configuration settings for the network interface settings, IP addresses, subnet masks, gateways, and DNS server in the file named ‘/etc/network/interfaces’ in Debian-based systems. However, the Red Hat-based systems use the ‘/etc/sysconfig/network-scripts/ifcfg-eth0’ file for this purpose. 

For identifying the path within the network, Linux uses the Routing Tables that are configured using the ‘route’ or ‘ip route’ command. Moreover, network address translation (NAT) helps us to control the network traffic. It is demonstrated as shown below.

network configuration

Linux Networking Commands 

We have gained sufficient information about Linux Networking. Now, it is time to implement the Network Configuration in Linux Environment. This will help you to easily use your Linux Environment for various applications. 

ifconfig 

The ifconfig (interface configuration) command configures, displays, and manages network interfaces. It provides information about the current network configuration of the system, like the IP addresses, MAC addresses, etc. Hence, this command allows administrators to view and modify the configuration of network interfaces, set IP addresses, enable or disable interfaces, and more. The implementation of this command is shown below.

Linux Networking Commands

IP 

Linux Experts use the ip command to configure network interfaces, routing tables, tunneling, and managing networking in Linux. It is similar to the ‘ifconfig’ command but it provides more functionality.. With ip, administrators can assign IP addresses, manage routing tables, configure tunnels, and perform a wide range of network-related tasks. Suppose you want to show the IP address of the server, you can use this command as demonstrated below.

Linux Networking Commands ip

traceroute

You can use this command If you want to trace the route of the packets from the local system to a destination IP address or hostname. It provides a detailed view of the network path and shows each hop along with the corresponding round-trip time. For example, if you want to trace the route paths for google.com, you can use it as illustrated below.

Linux Networking Commands traceroute

trace path

This Linux Network command is similar to traceroute as it shows the network path to a destination. But it provides a simplified output compared to traceroute. Therefore, it is more efficient. It helps identify network bottlenecks and latency between the source and destination. A simple implementation of this command is shown below:

Linux Networking Commands trace path

netstat 

The ‘netstat’ is a command-line tool that displays information about network connections, routing tables, interface statistics, masquerade connections, and more. It provides a comprehensive view of network-related activities that enable us to troubleshoot and monitor network performance. 

In other words, it shows the statistical data about the open sockets, routing tables, and connection information. In the following example, we are fetching the information about the ports in our Linux Environment.

Linux Networking Commands netstat

ss(Socket Statistics)

Socket is like the end-point through which the programs communicate with each other. It shows the information about the sockets, just like the ‘netstat’ command shows about the network. For example, if you want to get the information of all the sockets available on the server, you can use this command as shown below.

Linux Networking Commands ss(Socket Statistics)

dig 

DIG means ‘Domain Information Grouper.’ Thus, this command retrieves the information about the DNS Name Servers. Simply, Linux users use this command to get information about the website like where it is located, mail servers, IP address, etc. The use of this Linux Networking Command is shown below:

linux networking commands dig

nslookup

It is similar to the ‘dig’ command and shows the DNS-related information to the Linux Users. The difference is that it is less customizable than the ‘dig’ command.’ Also, it shows less information about the domain name system. The following example shows the ‘nslookup’ command in Linux System.

linux networking commands nslookup

route

Routing is the method of choosing the best path for delivering the data packet from source to destination. So, this command lets us view or modify the routing table. For example, the Administrators can add or delete routes using this command. You can use this command as shown below.

linux networking commands route

host

If you want to get the DNS information about the host machine, use this command. We can get the hostname using the IP address or we can get the IP Address using the domain name. For example, to get the DNS information about the google.com, we can use this command as below.

linux networking commands host

arp

ARP means Address Resolution Protocol which is used to map the MAC address of a device to the IP address. Thus, this command allows us to modify the addresses on the local network. The use of this command is demonstrated below.

linux networking commands arp

iwconfig 

iwconfig is used to configure wireless network interfaces in Linux. It displays information about wireless interfaces, including details about the current connection, signal strength, encryption, and more as shown below.

linux networking commands iwcofig

hostname

It allows us to display the hostname of a system so that we can identify the system on a network. Also, we can change the hostname using this command which is demonstrated as below. The important point is that it does not set the hostname as permanent. The host name is restored to the original when the system shuts down

linux networking commands hostname

curl 

In case you want to make the HTTP requests, this command will help you. You can use this to retrieve or send data to a server so that you can easily interact with the web services. Suppose you want to interact with google.com, you can use it as follows.

linux networking commands curl

ping 

It is one of the most basic commands that help us to check the network connectivity. It stands for ‘Packet InterNet Groper’ and ensures the connectivity between the server and the hosts. An example of this command is given below.

linux networking commands ping

mtr

mtr (My TraceRoute) is a network diagnostic tool that combines the functionality of ping and traceroute. It continuously traces the route to a destination and provides real-time statistics about packet loss and latency for each hop.

linux networking commands mtr

whois

The whois command provides information about domain registrations, including details about the domain registrar, registration date, and contact information. It is useful for obtaining information about a domain owner.

linux networking commands whois

ifplugstatus

It is the command to check whether Ethernet interfaces are connected or plugged into the system or not. Thus, it is a tool for verifying the physical connectivity of the network. Syntax of this command is shown below.

linux networking commands ifplugstatus

iftop

The bandwidth of the network plays a crucial role in data transfer across the system. So the iftop (Interface TOP) command is used to get information about the bandwidth statistics. When you type the command ‘sudo iftop,’ the output is shown below.

linux networking commands iftop

nmcli

It is a scripting command that shows the status of the network and controls the network manager. Here, we are using it to view the network devices as mentioned below.

linux networking commands nmcli

nmap

It scans the various hosts and services on a computer network. It also provides information about the open ports, services, and vulnerabilities as illustrated below.

linux networking commands nmap

ethtool

This command changes or retrieve the information about the Ethernet device settings. You can also view the configuration settings for an ethernet device within the network. It is demonstrated as shown below.

linux networking commands ethtool

Frequently Asked Questions

1. What is TCP/IP in Networking?

TCP (Transfer Control Protocol) and IP (Internet Protocol) are the network protocols. In simple words, they are the set of conventions or rules that allow a systematic exchange of information among the devices. Defense Advanced Research Projects Office (DARBA) developed it in 1970 to enhance the network communication in the ARPANET Project. It has various features such as shared data transfer, multiplexing, etc. for efficient networking. 

2. How to find an IP Address in Linux?
You can use the ‘ifconfig,’ or ‘ip link show’ command to find the IP address in our network. Along with this, if you want to display information about a specific network interface, you can use ‘ip addr show eth0’ where eth0 is the name of the network interface.

3. What is the solution for commands not found in Linux? 
There might be a possibility that the networking commands are not installed or configured in your Linux Environment Properly. In this case, you should try to reinstall the command using the ‘sudo apt install <command_name>’ in the Linux Terminal. 

4. What is the use of bmon command in the Linux Network?
This command allows us to get information about real-time bandwidth consumption. The syntax of this command is ‘bmon.’ we can monitor as well as debug the network statistics in an interactive manner. 

5. How to find all the network interfaces in the Linux System?
Type and execute the command ‘ip link show’ in the Linux Terminal. All the network interfaces in the Linux will be visible in the terminal.

Conclusion

In a nutshell, Linux Networking concepts play a crucial role in our career journey as a Linux Administrator. The Networking Concepts in Linux include concepts such as MAC Address, IP Address, and Networking Configurations. Linux provides various commands using which we can view, modify, configure, or update the configuration of Linux machines within the computer network. You have gained sufficient information about Linux Networking and Administration. You can easily manage your Linux Networking Environment.

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
Linux Networking TrainingNov 19 to Dec 04View Details
Linux Networking TrainingNov 23 to Dec 08View Details
Linux Networking TrainingNov 26 to Dec 11View Details
Linux Networking TrainingNov 30 to Dec 15View Details
Last updated: 09 Mar 2024
About Author

Soujanya is a Senior Writer at Mindmajix with tons of content creation experience in the areas of cloud computing, BI, Perl Scripting. She also creates content on Salesforce, Microstrategy, and Cobit. Connect with her via LinkedIn and Twitter.

read less