Aim :
Learn how to use netstat commands to display active network connections and listening ports on a Linux system.
netstat Commands: A Step-by-Step Guide
netstat is a command-line tool that provides information about network connections, routing tables, interface statistics, masquerade connections, and more. Follow these steps to use netstat for network analysis on your Linux system.
Guidance on How to Use:
Prerequisite:
Ensure that netstat is installed on your Linux system. You can install it using the package manager specific to your distribution.
netstat Commands:
- Show listening ports with process information:
This command displays all listening ports along with the associated processes and their PIDs.netstat -nlpt
- List all listening ports:
netstat -tuln
- Show all established connections:
netstat -tn
- Display network statistics for all interfaces:
netstat -s
- Show detailed information about all connections and listening ports:
netstat -a
- Display routing table information:
netstat -r
- Show listening ports with process information:
netstat -tulpn
- Display only IPv4 connections:
netstat -4
- Display only IPv6 connections:
netstat -6
- Show PID and program name for each connection:
netstat -tp
Verification:
Verify the active connections and listening ports by running various netstat commands based on your requirements.