Networking Commands

Common Networking Commands

There are many common networking commands that are used to troubleshoot and manage networks. Here are some of the most common ones:

Ping

Ping: The ping command is used to test the connectivity between two hosts. It sends ICMP echo request messages to the destination host and waits for ICMP echo reply messages. If the ping command gets a reply from the destination host, it means that the hosts are connected and that the network is working.

ping www.google.com

Ipconfig

Ipconfig: The ipconfig command is used to display the IP address configuration of the local machine. It also displays other information, such as the subnet mask, default gateway, and DNS server addresses.

Ipconfig

iwconfig

iwconfig: Displays wireless network interface configuration and settings.

iwconfig

ifconfig

ifconfig: Displays the network interface configuration, including IP addresses and network details.

ifconfig

netstat

The netstat command is a networking command that is used to display network connections, routing tables, and interface statistics. It can be used to troubleshoot network problems and to monitor network traffic.

netstat [options]

The options can be any of the following:

  • -a - Display all connections, including listening ports.

  • -n - Display addresses and port numbers in numerical form.

  • -o - Display the owning process ID associated with each connection.

  • -p - Display connections for the protocol specified by proto. For example, netstat -p tcp will display all TCP connections.

  • -r - Display the routing table.

  • -t - Display connections for the transport protocol specified by proto. For example, netstat -t tcp will display all TCP connections.

  • -u - Display connections for the user specified by user.

Tracert

Tracert: The tracert command is used to trace the path that a packet takes from the source host to the destination host. It does this by sending ICMP echo request messages to the destination host and recording the IP addresses of the routers that the packets pass through.

Tracert www.google.com

Netstat

Netstat: The netstat command is used to display the network connections and listening ports on the local machine. It can also be used to display the routing table.

netstat -option

options:

  • -a - Display all connections, including listening ports. Other options that can be used with the netstat command include:

  • -n - Display addresses and port numbers in numerical form.

  • -o - Display the owning process ID associated with each connection.

  • -p - Display connections for the protocol specified by proto. For example, netstat -p tcp will display all TCP connections.

  • -r - Display the routing table.

Nslookup

Nslookup: The nslookup command is used to query the Domain Name System (DNS) for information about a hostname or IP address.

nslookup www.google.com

Route

Route: The route command is used to manage the routing table on the local machine. It can be used to add, delete, and modify routes.

route [options] [destination] [gateway] [metric]

The options can be any of the following:

  • add - Add a route to the routing table.

  • delete - Delete a route from the routing table.

  • change - Change the metric of a route in the routing table.

  • print - Print the routing table.

The destination is the network or host that the route is for. The gateway is the IP address of the router that is used to reach the destination. The metric is an integer that specifies the cost of the route.

Telnet

The telnet command is used to establish a remote terminal connection to another host. This can be used to troubleshoot problems on remote hosts or to administer network devices. The syntax for the telnet command is:

telnet [options] [host] [port]

The options can be any of the following:

  • -a - Specifies the local username.

  • -l - Specifies the remote username.

  • -r - Specifies the remote hostname.

  • -v - Specifies the verbose mode.

TCPDUMP

This tcpdump release fixes an out-of-bounds write vulnerability (CVE-2023-1801) present in the previous release (4.99.3) in the SMB printer, which is not compiled by default. It also makes various minor improvements. This release requires libpcap 1.10.0 or later to pass all test cases.

tcpdump [Options]

NMAP

Overview

Nmap (Network Mapper) is a powerful network scanning tool used to discover hosts and services on a computer network. It provides a wide range of scanning techniques and options to gather information about network devices, open ports, operating systems, and other details. Nmap uses raw IP packets to determine available hosts and services, making it flexible and efficient for network reconnaissance. It supports various scan types, including TCP, UDP, SYN, and ICMP, and can perform advanced tasks like version detection, OS fingerprinting, and script scanning. Nmap is widely used by network administrators, security professionals, and ethical hackers for network analysis and vulnerability assessment.

NMAP Options

  • Target specification: This option specifies the hosts or networks to be scanned. You can specify hostnames, IP addresses, or network ranges.

  • Host discovery: This option controls how Nmap discovers hosts on the network. By default, Nmap will send ICMP echo requests to each target. You can also use TCP SYN or UDP probes to discover hosts.

  • Scan techniques: This option specifies the type of scan to be performed. Nmap supports a variety of scan techniques, including SYN, TCP connect(), ACK, FIN, and Xmas scans.

  • Port specification: This option specifies the ports to be scanned. You can specify individual ports, ranges of ports, or all ports.

  • Output format: This option specifies the format of the scan output. Nmap can output its results in a variety of formats, including text, XML, and grepable.

  • Timing and performance: These options control the speed and intensity of the scan. You can use these options to optimize the scan for your specific needs.

  • Miscellaneous options: These options provide additional control over the scan. For example, you can use these options to disable DNS resolution, spoof your IP address, or run Nmap in stealth mode.

NMAP Commands Options

  • Basic Scan: nmap <target> - Performs a basic scan on the specified target IP address or hostname.

  • Port Scan: nmap -p <ports> <target> - Scans specific ports on the target, e.g., nmap -p 80,443 <target>.

  • Service and Version Detection: nmap -sV <target> - Detects the services running on open ports and attempts to determine their versions.

  • OS Detection: nmap -O <target> - Attempts to identify the operating system of the target machine.

  • Aggressive Scan: nmap -A <target> - Enables aggressive scanning techniques, including OS detection, version detection, script scanning, and traceroute.

  • Script Scanning: nmap --script <script> <target> - Executes specific NSE scripts to perform additional scanning and information gathering.

  • UDP Scan: nmap -sU <target> - Performs a UDP scan to identify open UDP ports on the target.

  • Timing and Performance Options: nmap -T<level> <target> - Specifies the timing template for the scan, where the level can be from 0 to 5 (higher is faster, but less reliable).

  • Output Options: nmap -oX <filename> <target> - Saves the scan results in XML format to the specified file.

You can watch this YouTube Video/Tutorial created by NetworkChuck about NMAP Tool.

You can watch this YouTube Video/Tutorial created by S7ee7 about NMAP Tool.

Last updated