Practice Exercises: Basic Computer Networking Lab using Linux netstat
Command
Introduction
Welcome to the Basic Computer Networking Lab! In this lab, you will learn how to use the netstat
command on a Linux server to explore various networking aspects. This hands-on lab is designed to help future Site Reliability Engineers (SREs) gain practical experience in troubleshooting network connections, monitoring network statistics, and understanding network activities on a Linux server.
Prerequisites
Before you begin this lab, you should have the following:
- Access to a Linux server (e.g., Ubuntu, CentOS)
- Basic knowledge of Linux command-line interface (CLI)
- SSH access to the Linux server
- Administrative privileges or sudo access on the server
Scenario
You are a future Site Reliability Engineer (SRE) responsible for ensuring the availability and reliability of online services. You will be using your Linux server to test connections to external servers on the internet and troubleshoot networking issues. The netstat
command will be your primary tool for monitoring network activities.
Task 1: Viewing Active Network Connections
Objective: Learn how to use netstat
to view active network connections.
Procedure:
- Log in to your Linux server using SSH.
- Open a terminal window.
- Run the following command to display all active network connections:
netstat -tuln
Task 2: Displaying Network Interfaces
Objective: Learn how to use netstat
to display network interface statistics.
Procedure:
- Run the following command to display network interfaces:
netstat -i
Task 3: Monitoring Listening Ports
Objective: Learn how to use netstat
to monitor listening ports.
Procedure:
- Run the following command to display listening ports:
netstat -tuln | grep LISTEN
Task 4: Displaying Network Routing Table
Objective: Learn how to use netstat
to display the network routing table.
Procedure:
- Run the following command to display the network routing table:
netstat -r
Task 5: Monitoring Network Statistics
Objective: Learn how to use netstat
to monitor network statistics.
Procedure:
- Run the following command to display network statistics:
netstat -s
Task 6: Displaying Network Services and Ports
Objective: Learn how to use netstat
to display network services and associated ports.
Procedure:
- Run the following command to display network services and their associated ports:
netstat -l
Task 7: Filtering netstat
Output
Objective: Learn how to use netstat
with filters to display specific information.
Procedure:
- Run the following command to display only the IPv4 network connections:
netstat -tuln -4
- Run the following command to display only the IPv6 network connections:
netstat -tuln -6
Task 8: Displaying Network Traffic by Protocol
Objective: Learn how to use netstat
to display network traffic statistics by protocol.
Procedure:
- Run the following command to display network traffic statistics by protocol:
netstat -s | grep -i "UDP|TCP"
Task 9: Monitoring Network Interface Speed
Objective: Learn how to use netstat
to monitor network interface speed.
Procedure:
- Run the following command to display network interface speed:
ethtool <interface_name>
- Explain how to interpret the output to determine the network interface speed.
Task 10: Investigating Established Connections
Objective: Learn how to use netstat
to investigate established network connections.
Procedure:
- Run the following command to display established connections:
netstat -tuln | grep ESTABLISHED