Linux Network Monitoring

LinuxLinuxBeginner
Practice Now

Introduction

Welcome to the future - the year is 2150, and you are an esteemed explorer of Aspharion, an underground city known for its advanced technologies and thriving cyber community. Cut off from the surface because of harsh environmental conditions, Aspharion has evolved independently, developing unique networking infrastructures essential for the survival of its inhabitants.

As a trailblazer of this subterranean society, your mission is to ensure the stability and security of Aspharion's networks. You must master the artful dance of monitoring network connections and services to prevent any disruptions that could endanger the community living beneath the earth's surface. Your primary tool for this quest is netstat, a powerful command-line utility that depicts the network in its most raw form - a tableau of protocols, addresses, and statuses.

The goal of this lab is to empower you with the skills to use netstat proficiently. By the end of your exploration, you will unveil the veiled intricacies of the Aspharion networks, ensuring that this underground realm thrives for years to come.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/RemoteAccessandNetworkingGroup(["`Remote Access and Networking`"]) linux/RemoteAccessandNetworkingGroup -.-> linux/netstat("`Network Monitoring`") subgraph Lab Skills linux/netstat -.-> lab-271343{{"`Linux Network Monitoring`"}} end

Exploring Active Connections with netstat

In this step, you will begin your journey by exploring the active network connections within Aspharion. You will use netstat to list all active connections and listen to ports. This will give you a real-time overview of the networking landscape in this subterranean city.

Please open a zsh terminal and navigate to the /home/labex/project directory.

In the terminal, execute the following command to display all active connections:

netstat -nat > connections.txt

This command will generate an output showing a list of active connections, the state of each connection, and the corresponding ports. The -n flag shows numerical addresses instead of trying to determine symbolic host, port or user names. The -a flag shows both listening and non-listening sockets. The -t flag restricts the output to TCP connections.

The connections would be written down in file connections.txt.

The expected output should resemble the following:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN
tcp        0      0 192.168.1.100:443       185.199.108.133:52698   ESTABLISHED

Monitoring Network Services

After identifying the active connections, it's crucial to determine what services are currently running and listening for incoming connections in Aspharion. netstat can also provide information about listening ports and the services associated with these ports.

Within the same terminal, run the following command to list all services listening on TCP and UDP ports:

netstat -natu | grep LISTEN > listening_services.txt

This will output a list of listening services and their ports, with the TCP or UDP protocol details. The -u flag includes UDP connections in the output. Make sure to filter the output with grep to only show ports in the LISTEN state.

Your findings would be written down in file listening_services.txt.

Your output should look similar to this:

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN

Displaying the Network Interface Statistics

In this step, the goal is to review the network interface statistics in Aspharion. These statistics can reveal a lot about the traffic handling and performance of the network interfaces.

Use the following command to display network interface statistics:

netstat -i > interface_stats.txt

The output will provide you with a list of network interfaces and key statistics such as MTU (Maximum Transmission Unit), RX-OK (received packages), TX-OK (transmitted packages), and errors.

The output would be written down in file interface_stats.txt.

Example output:

Kernel Interface table
Iface   MTU  RX-OK RX-ERR RX-DRP RX-OVR  TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0    1500 10072      0      0 0      9260      0      0      0 BMRU
lo      65536 2022046   0      0 0      2022046   0      0      0 LRU

Summary

In this lab, you've embarked on an exploration of network monitoring in a futuristic underground city using the netstat command. The carefully designed steps led you through understanding active connections, monitoring network services, and inspecting network interface statistics. My design logic focused on crafting straightforward yet comprehensive tasks to offer you robust foundational skills necessary for effective network management.

This tour inside Aspharion's networks has not only enhanced your grasp of the netstat utility but has also equipped you with the knowledge to sustain and protect the unseen but vital arteries of the city. Through your adventure and achievements, you have become an integral part of Aspharion's echelon of network explorers.

Other Linux Tutorials you may like