60 Linux Networking commands and scripts
Recently, I wanted to test network throughput via command line with at least 3 tools. For the life of me, I could not remember iperf. Not being able to remember previously used command line tools is frustrating and something we can all relate to. So I created a go-to list of network tools for myself. Then, I thought, why not turn this list into a blog post? So I spent another hour or two compiling this ongoing list of Linux Networking Commands and Scripts. I look forward mostly to suggestions because I know there’s always something missing or new scripts out there to try.
Table of Contents
Linux Networking commands and scripts
iperf command example/screenshot
This list of Linux Networking commands and scripts will receive ongoing updates:
- aria2 – downloading just about everything. Torrents included.
- arpwatch – Ethernet Activity Monitor.
- bmon – bandwidth monitor and rate estimator.
- bwm-ng – live network bandwidth monitor.
- curl – transferring data with URLs. (or try httpie)
- darkstat – captures network traffic, usage statistics.
- dhclient – Dynamic Host Configuration Protocol Client
- dig – query DNS servers for information and obtain various types of DNS records.
- dstat – replacement for vmstat, iostat, mpstat, netstat and ifstat.
- ethtool – utility for controlling network drivers and hardware.
- gated – gateway routing daemon.
- host – DNS lookup utility.
- hping – TCP/IP packet assembler/analyzer.
- ibmonitor – shows bandwidth and total data transferred.
- ifstat – report network interfaces bandwidth.
- iftop – display bandwidth usage.
- ifconfig command – manage network interfaces, display information, and configure settings.
- ip (PDF file) – a command with more features that ifconfig (net-tools).
- iperf3 – network bandwidth measurement tool. (above screenshot Stacklinux VPS)
- iproute2 – collection of utilities for controlling TCP/IP.
- iptables – take control of network traffic.
- IPTraf – An IP Network Monitor.
- iputils – set of small useful utilities for Linux networking.
- iw – a new nl80211 based CLI configuration utility for wireless devices.
- jwhois – client for the whois service.
- “lsof -i” – reveal information about your network sockets.
- mtr – network diagnostic tool.
- net-tools – utilities include: arp, hostname, ifconfig, netstat, rarp, route, plipconfig, slattach, mii-tool, iptunnel and ipmaddr.
- ncat – improved re-implementation of the venerable netcat.
- netcat – networking utility for reading/writing network connections.
- nethogs – a small ‘net top’ tool.
- Netperf – Network bandwidth testing.
- netplan – Netplan is a utility for easily configuring networking on a Linux system.
- netsniff-ng – Swiss army knife for daily Linux network plumbing.
- netstat command – provides network statistics, routing tables, and connection information. Part of net-tools, largely replaced by ‘ss‘.
- netwatch – monitoring Network Connections.
- ngrep – grep applied to the network layer.
- nload – display network usage.
- nmap – network discovery and security auditing.
- nmcli – a command-line tool for controlling NetworkManager and reporting network status.
- nmtui – provides a text interface to configure networking by controlling NetworkManager.
- nslookup – query Internet name servers interactively.
- ping – send ICMP echo_request to network hosts.
- route – show / manipulate the IP routing table.
- slurm – network load monitor.
- snort – Network Intrusion Detection and Prevention System.
- smokeping – keeps track of your network latency.
- socat – establishes two bidirectional byte streams and transfers data between them.
- speedometer – Measure and display the rate of data across a network.
- speedtest-cli – test internet bandwidth using speedtest.net
- ss – utility to investigate sockets.
- ssh – secure system administration and file transfers over insecure networks.
- tcpdump – command-line packet analyzer.
- tcptrack – Displays information about TCP connections on a network interface.
- telnet – user interface to the TELNET protocol.
- tracepath – very similar function to traceroute.
- traceroute – print the route packets trace to network host.
- vnStat – network traffic monitor.
- websocat – Connection forwarder from/to web sockets to/from usual sockets, in style of socat.
- wget – retrieving files using HTTP, HTTPS, FTP and FTPS.
- Wireless Tools for Linux – includes iwconfig, iwlist, iwspy, iwpriv and ifrename.
- Wireshark – network protocol analyzer.
Read also:
- 100 Top Observability Tools (+ Server Monitoring and APM solutions).
- 25 Best CDN Providers,
- Choosing the Best Linux Server Distro.
- 90 Linux Commands frequently used by Linux Sysadmins.
- Linux benchmark scripts and tools.
Network Fundamentals
You can’t work with computer networks without understanding the basics. These are the foundation of all networking and include:
- Network Protocols: The rules and standards that govern data transmission over a network. TCP/IP for reliable communication, HTTP for web traffic, FTP for file transfers.
- Network Topologies: The physical and logical arrangement of devices on a network. Bus, star, ring and more.
- Network Devices: The hardware that makes up a network, routers, switches, firewalls. Each device has a specific job to manage and direct traffic.
- Network Media: The physical material used to transmit data, copper cables, fiber optic cables, wireless signals. The choice of media affects the speed and reliability of the network.
Now you have a foundation to build upon for more advanced networking and technologies to build, manage and troubleshoot.
Network Connectivity
Network connectivity is the lifeblood of any network, devices communicate and share resources. There are several ways to get network connectivity:
- Wired Connections: Use physical cables, Ethernet, to connect devices. Wired connections are reliable and fast, great for stable high-speed networks.
- Wireless Connections: Use wireless signals, Wi-Fi, to connect devices. Wireless connections are flexible and mobile, devices can connect without the physical constraints of cables.
- Virtual Private Networks (VPNs): VPNs use encryption and other security measures to create secure private connections over public networks. This is for protecting sensitive data and privacy when accessing remote networks.
Network connectivity is used for:
- Internet Access: Connect to the global network of computers to access online resources.
- File Sharing: Devices to share files and data over a network.
- Communication: Real-time communication through email, instant messaging and video conferencing.
Understanding and managing network connectivity, so devices can communicate efficiently and securely.
IP Addresses and DNS
IP addresses and DNS (Domain Name System) are the foundation of network connectivity, devices can locate and communicate with each other:
- IP Addresses: Unique numerical addresses assigned to each device on a network. They are identifiers, devices send and receive data accurately. There are two types of IP addresses, IPv4 and IPv6, IPv6 has a larger address space.
- DNS: This system translates human-readable domain names (www.example.com) into IP addresses. This is important because humans find domain names easier to remember, computers use IP addresses to route data.
When you type a domain name in a web browser, the DNS system translates it into an IP address and directs your request to the correct server. This is what makes browsing the internet so intuitive and easy.
Network Info and Stats
Monitoring network performance is key to a healthy and efficient network. Here are some key stats:
- Network Traffic: The amount of data being transmitted over the network at any given time. Monitoring traffic helps to identify congestion and optimize bandwidth.
- Network Latency: The delay between sending and receiving data. High latency affects real-time applications like video conferencing and online gaming.
- Network Packet Loss: The number of data packets lost during transmission. High packet loss means there’s a network issue that needs to be fixed.
- Network Throughput: The rate of data transmitted over the network. This is a key performance and capacity indicator.
By looking at these metrics, network admins can see how the network is performing, identify issues and take corrective action to ensure smooth and efficient network operation.
Linux Network Commands
Linux has a lot of commands to manage and troubleshoot network connections. Here are some essential Linux network commands:
- ifconfig: Used to configure and manage network interfaces. You can assign IP addresses, enable or disable interfaces and more.
- ip: A more powerful command to manage IP addresses and routing tables. Preferred for modern network configurations.
- ping: Used to test network connectivity by sending ICMP echo requests to a host. Helps to diagnose network issues by measuring round-trip time and packet loss.
- traceroute: Traces the path of data packets to a network host, shows each hop along the way. Useful to identify where delays or failures occur in the network.
- netstat: Shows network stats and connections, gives insights to active connections, routing tables and interface stats.
These commands are a must have for anyone working with Linux networks, powerful tools to configure, manage and troubleshoot network connections.
Security
Network security is key to preventing unauthorized access and cyber threats. Here:
- Firewalls: Devices that control incoming and outgoing network traffic based on security rules, a barrier between trusted and untrusted networks.
- Encryption: Converts plaintext data into unreadable ciphertext, so it can’t be accessed during transmission.
- Access Control: Measures that determine who can access the network and what they can do, so only authorized users can interact with network resources.
- Intrusion Detection and Prevention Systems (IDPS): Systems that monitor network traffic for unauthorized access or malicious activity, to detect and prevent security breaches.
Protecting your data and network resources is key to implementing network security. By securing against threats you secure your network.
Published: January 31st, 2020 | Last updated: November 10th, 2024
There is a lot here to look over. I will have to check into this more when I have time. I used to do this a lot. Loved working with commands and scripts and trying different things out.
Great list. I’ve used smokeping in my early years with Linux to monitor my wan interface. It was great but I recently moved to uptimeKuma to monitor my internet and other docker apps.
I also used snort via pfsense but man, things were always being blocked, so I only placed it in monitoring mode
Also consider these: