In the world of computer networks, network commands play a crucial role in managing and troubleshooting network connectivity. These commands, often used in command-line interfaces, allow us to interact with network devices, diagnose network issues, and perform various network-related tasks. They provide a powerful set of tools for administrators, engineers, and enthusiasts to configure, monitor, and analyze network connections.
Network commands enable us to perform a wide range of tasks, such as checking network connectivity to a specific IP address or hostname, tracing the path taken by packets to a destination, configuring IP addresses and network interfaces, retrieving DNS information, monitoring active network connections and listening ports, managing firewall rules, and much more. These commands provide insights into the network’s state, reveal valuable statistics, and help troubleshoot and debug network-related problems.
With these network commands at our disposal, we can diagnose and resolve issues related to network connectivity, performance, security, and configuration. Whether it’s checking if a remote server is reachable, investigating network latency, analyzing network traffic, or configuring network settings, these commands serve as indispensable tools in the realm of networking.
It’s important to note that different operating systems and network devices may have their own set of commands, although many core commands have similarities across platforms. Whether you’re working with Windows, Unix-based systems like Linux or macOS, or networking equipment like routers and switches, understanding and utilizing these network commands can greatly enhance your ability to effectively manage and troubleshoot network infrastructures.
In this guide, we will explore and explain a variety of network commands, providing you with a comprehensive understanding of their functionality and usage. By familiarizing yourself with these commands, you’ll be equipped with the knowledge and tools to navigate the intricate world of computer networks and overcome network-related challenges with confidence. So let’s dive in and discover the power of network commands!
Contents
List of network commands
Command | Description |
---|---|
ping <IP/hostname> | Sends ICMP echo requests to a specified IP address or hostname to check network connectivity and measure round-trip time. |
tracert <IP/hostname> | Traces the network route to a destination by sending ICMP echo requests to intermediate routers and displays the path taken by packets. |
ipconfig | Displays IP configuration information on Windows systems, including IP address, subnet mask, default gateway, and DNS servers. |
ifconfig | Displays network interface configuration information on Unix-based systems, including IP address, subnet mask, and interface status. |
nslookup <hostname> | Performs DNS lookup for a given hostname, retrieves the corresponding IP address(es), and displays additional DNS information. |
netstat | Displays network statistics and active network connections on the system, including listening ports and established connections. |
arp -a | Displays the ARP cache table, showing the IP-to-MAC address mappings for devices on the local network. |
route print | Prints the IP routing table on Windows systems, showing the routing entries for network destinations and associated gateway information. |
ifup <interface> | Brings up a specific network interface on Unix-based systems, activating it and enabling network connectivity. |
ifdown <interface> | Brings down a specific network interface on Unix-based systems, deactivating it and disabling network connectivity. |
dig <hostname> | Performs DNS queries and retrieves various DNS records associated with a hostname, such as A, MX, CNAME, and TXT records. |
telnet <IP/hostname> | Initiates a Telnet session with a specified IP address or hostname, establishing a remote terminal connection. |
ssh <IP/hostname> | Initiates an SSH (Secure Shell) session with a specified IP address or hostname, providing secure remote command-line access. |
netcat <IP/hostname> | Establishes TCP or UDP connections to a specified IP address or hostname, facilitating network communication. |
curl <URL> | Sends HTTP requests to a specified URL and displays the server’s response, allowing file transfers and interaction with web services. |
wget <URL> | Downloads files from a specified URL and saves them to the local system, supporting recursive downloads and mirroring of websites. |
nmap <IP> | Performs network scanning and host discovery on a specified IP address, providing information about open ports and running services. |
tcpdump | Captures and analyzes network traffic on a specified interface, allowing packet-level inspection and analysis. |
wireshark | A graphical network protocol analyzer that captures and analyzes network traffic in real-time, providing detailed protocol information. |
netcat -l -p <port> | Sets up a listening TCP socket on a specified port, allowing incoming connections and data transfer. |
iptables | A powerful firewall administration utility on Linux systems, used for configuring and managing netfilter firewall rules. |
route add | Adds a new route to the IP routing table, specifying the network destination, subnet mask, and gateway. |
route delete | Deletes a route from the IP routing table based on the network destination and subnet mask. |
ip route show | Displays the IP routing table on Linux systems, showing the routes for network destinations and associated gateway information. |
netsh interface | A Windows command-line utility for managing network interfaces, including configuration, settings, and statistics. |
traceroute <IP/hostname> | Traces the network route to a destination using ICMP echo requests, displaying the IP addresses of routers along the path. |
ifconfig -a | Displays configuration information for all network interfaces, including IP addresses and interface status, on Unix-based systems. |
ssh-keygen | A utility for generating SSH key pairs used for authentication when establishing SSH connections. |
ip link show | Displays information about network interfaces, including their state, MAC addresses, and MTU values, on Linux systems. |
ip address add | Adds an IP address to a network interface on Linux systems, associating the IP address with the interface. |
arp -d <IP> | Deletes an entry from the ARP cache, removing the IP-to-MAC address mapping for a specific IP address. |
hostname | Retrieves the hostname of the current system, which represents its name in a network environment. |
ping -c <count> <IP/hostname> | Sends a specified number of ICMP echo requests to a target IP address or hostname and displays the round-trip statistics. |
netstat -r | Displays the IP routing table along with associated network interface and gateway information on the system. |
dig +short <hostname> | Performs a DNS lookup for a given hostname and displays only the resulting IP address(es) in a short format. |
nslookup -type=mx <domain> | Retrieves the MX (Mail Exchanger) records for a domain, which specify the mail server(s) responsible for handling email for the domain. |
ifconfig <interface> | Displays configuration information for a specific network interface, including IP address, subnet mask, and interface status. |
arp -s <IP> <MAC> -i <interface> | Manually adds an IP-to-MAC mapping to the ARP cache for a specific interface, associating a specific IP address with a MAC address. |
ssh <user>@<IP/hostname> | Initiates an SSH session with a specified username and IP address or hostname, providing secure remote command-line access. |
curl -I <URL> | Sends an HTTP HEAD request to a specified URL and displays the server’s response headers, including information such as content type. |
wget -r -np <URL> | Recursively downloads files from a specified URL, following links and preserving the directory structure, while not ascending to parent. |
netcat -u <IP/hostname> | Establishes a UDP connection to a specified IP address or hostname, facilitating communication over the UDP protocol. |
netstat -an | Displays all active network connections and listening ports on the system, showing both TCP and UDP connections. |
tcpdump -i <interface> | Captures and analyzes network traffic on a specific interface, allowing packet-level inspection and analysis. |
nmap -p <port> <IP> | Performs a port scan on a specified IP address, checking for open ports and providing information about running services. |
iptables -A <chain> | Appends a rule to a specific chain in the iptables firewall, allowing customization of packet filtering and network traffic control. |
route change | Modifies an existing route in the IP routing table, allowing changes to the network destination, subnet mask, and gateway information. |
ip route add | Adds a new route to the IP routing table, specifying the network destination, subnet mask, and gateway. |
netsh interface ipv4 | A Windows command-line utility for managing IPv4 network interfaces, including configuration, settings, and statistics. |
traceroute -I <IP/hostname> | Traces the network route to a destination using ICMP echo requests, using the ICMP Echo Request/Reply protocol. |
ifup -a | Activates all available network interfaces on Unix-based systems, bringing them up and enabling network connectivity. |
ifdown -a | Deactivates all available network interfaces on Unix-based systems, bringing them down and disabling network connectivity. |
ssh -L <local_port>:<destination>:<remote_port> | Sets up local port forwarding via an SSH tunnel, allowing connections to a local port to be forwarded to a remote destination. |
ip -s link | Displays detailed statistics for network interfaces, including packet counts, error counts, and interface status, on Linux systems. |
ip address delete | Removes an IP address from a network interface on Linux systems, disassociating the IP address from the interface. |
hostname -I | Retrieves the list of IP addresses assigned to the current system, showing all the IP addresses associated with the hostname. |
ping -t <IP/hostname> | Sends ICMP echo requests to a specified IP address or hostname continuously until interrupted, allowing continuous network monitoring. |
netstat -s | Displays comprehensive network statistics and protocol-specific information, including errors, retransmissions, and segment counts. |
dig -x <IP> | Performs a reverse DNS lookup for a given IP address and retrieves the corresponding hostname(s). |
arp -f <file> | Adds multiple IP-to-MAC address mappings to the ARP cache from a file, associating the IP addresses with the specified MAC addresses. |
ssh-copy-id <user>@<IP/hostname> | Copies the user’s SSH public key to a remote host, enabling passwordless SSH authentication for the specified user. |
curl -o <filename> <URL> | Downloads a file from a specified URL and saves it with the specified filename. |
wget -O <filename> <URL> | Downloads a file from a specified URL and saves it with the specified filename, allowing custom naming of the downloaded file. |
netcat -l <port> | Sets up a listening TCP socket on a specified port, allowing incoming connections and data transfer. |
iptables -D <chain> | Deletes a rule from a specific chain in the iptables firewall, removing the rule from the firewall configuration. |
route flush | Flushes all routes from the IP routing table, removing all entries and resetting the routing table to default. |
ip route delete | Deletes a route from the IP routing table based on the network destination and subnet mask. |
netsh interface ipv6 | A Windows command-line utility for managing IPv6 network interfaces, including configuration, settings, and statistics. |
traceroute -6 <IP/hostname> | Traces the network route to a destination using ICMPv6 echo requests, displaying the IPv6 addresses of routers along the path. |
ifconfig -s | Displays a summary of network interfaces, including interface names, IP addresses, and status, on Unix-based systems. |
arp -n | Displays the ARP cache table without performing reverse DNS lookups, showing only the IP-to-MAC address mappings. |
ssh -X <user>@<IP/hostname> | Initiates an SSH session with X11 forwarding enabled, allowing remote display of X applications. |
curl -L <URL> | Follows HTTP redirects and downloads a file from a specified URL, allowing retrieval of the final destination of a redirected URL. |
wget -N <URL> | Downloads a file from a specified URL only if the local copy is outdated or missing, based on the file’s timestamp. |
netcat -ul <port> | Sets up a listening UDP socket on a specified port, allowing incoming UDP datagrams to be received. |
netstat -s -p <protocol> | Displays comprehensive statistics for a specific network protocol, such as TCP or UDP, including segment counts and error statistics. |
tcpdump -n -i <interface> | Captures and analyzes network traffic on a specific interface, displaying packet information without performing DNS resolution. |
nmap -A <IP> | Performs an aggressive scan on a specified IP address, providing detailed information about open ports, services, and OS detection. |
iptables -F <chain> | Flushes all rules from a specific chain in the iptables firewall, removing all rules from the chain. |
ip link set | Modifies the attributes of a network interface, such as the MAC address or MTU, on Linux systems. |
route -n | Displays the IP routing table without resolving IP addresses to hostnames, showing the routes as numeric addresses. |
ssh -C <user>@<IP/hostname> | Initiates an SSH session with compression enabled, reducing the amount of data transferred over the network. |
curl -X <method> <URL> | Sends an HTTP request with a specified method (GET, POST, PUT, DELETE, etc.) to a specified URL. |
wget –mirror <URL> | Mirrors a website by recursively downloading its content, allowing offline browsing of the mirrored site. |
netcat -w <timeout> <IP/hostname> | Sets a timeout for the netcat command when establishing a connection to a specified IP address or hostname. |
iptables-save | Saves the current iptables firewall configuration to a file, allowing the rules to be restored later. |
route -p add | Adds a persistent route to the IP routing table on Windows systems, ensuring that the route persists across reboots. |
ip link show up | Displays information about network interfaces that are currently in the “up” state, indicating active interfaces. |
arp -i <interface> | Displays ARP cache information specific to a particular network interface, showing IP-to-MAC address mappings for that interface. |
hostname -f | Retrieves the fully qualified domain name (FQDN) of the current system, which represents the complete hostname including the domain. |
ping -s <size> <IP/hostname> | Sends ICMP echo requests to a specified IP address or hostname with a specific payload size, allowing testing of maximum packet size. |
netstat -t | Displays only TCP-related network connections and listening ports, excluding UDP and other protocols. |
dig -t <record_type> <hostname> | Performs a DNS query for a specific record type associated with a hostname, retrieving records such as A, AAAA, MX, or TXT. |
nslookup -type=mx <domain> | Retrieves the MX (Mail Exchanger) records for a domain, which specify the mail server(s) responsible for handling email for the domain. |