DEV Community

Cover image for Common Network Commands
Ilyas Filali
Ilyas Filali

Posted on

Common Network Commands

Networking commands are tools used in operating systems to manage network connections, troubleshoot network issues, and gather information about network configurations.

The below mentioned commands are some of the most useful commands required to troubleshoot network problems and configure network settings.

Image description

Image description

The ip command in Linux is a powerful tool for network configuration and administration. The ip n subcommand, specifically, is used to display and manipulate the neighbor table, which contains information about devices (or neighbors) on the same network segment. This table is commonly used for IPv4 ARP (Address Resolution Protocol) and IPv6 neighbor discovery.
Here's a breakdown of what ip n does:

Display Neighbor Table: By running ip n, you can view the entries in the neighbor table, which typically include IP addresses and corresponding MAC addresses of devices that the local system has recently communicated with.

Flush Neighbor Entries: You can flush (delete) entries from the neighbor table using the ip n flush command followed by specific options. This can be useful for troubleshooting or clearing outdated entries.
• For example, to flush all ARP entries:

Image description

Add or Modify Entries: The ip n command can also be used to manually add or modify entries in the neighbor table. This is less common in practice but can be useful for certain networking scenarios.
For example, to add a static ARP entry:

Image description

Where:
• is the IP address of the neighbor.
• is the MAC address of the neighbor.
• is the network interface name.

Refresh Entries: Some implementations of ip n also allow for refreshing neighbor entries. This can be useful in situations where you want to update an existing entry without deleting and re-adding it.

In summary, the ip n command provides a way to view, manage, and manipulate the neighbor table, which stores information about devices on the same network segment. It's particularly useful for troubleshooting network connectivity issues and managing ARP cache entries.

Image description

The arp -a command is used to display the ARP (Address Resolution Protocol) cache or table on a system. ARP is used to map IP addresses to MAC addresses on a local network. The ARP cache maintains a mapping of IP addresses to MAC addresses for devices that the system has recently communicated with.

Here's what arp -a does:

  1. Display ARP Cache: When you run arp -a on a command line interface, it shows a list of entries in the ARP cache. Each entry typically includes:

    • Internet Address: The IP address of a device on the local network.
    • Physical Address: The MAC address (hardware address) associated with the corresponding IP address.
    • Type: The type of ARP entry, which is usually "dynamic" for dynamically learned entries, or "static" for manually configured entries.
  2. Information for All Interfaces: The -a option in the arp command specifies that information for all network interfaces should be displayed. This ensures that the ARP cache for all interfaces on the system is shown.

  3. Refresh ARP Cache: Running arp -a can also trigger the ARP cache to be refreshed. This means that the system may send ARP requests for devices that it needs to communicate with but doesn't have an entry for in its cache.

  4. Diagnostic Tool: arp -a is often used as a diagnostic tool for troubleshooting network connectivity issues. By examining the ARP cache, you can verify whether the system has the necessary mappings between IP addresses and MAC addresses for devices on the local network.

  5. Static ARP Entries: Some systems allow administrators to manually add static ARP entries to the cache. These entries are typically configured to ensure that specific IP addresses are always associated with specific MAC addresses. When you run arp -a, any static ARP entries will be displayed along with dynamically learned entries.

In summary, arp -a is a command-line tool used to view the ARP cache on a system, providing information about IP-to-MAC address mappings for devices on the local network. It's commonly used for network troubleshooting and diagnostics.

Image description

Image description

Image description

Curl is a versatile command-line tool used for transferring data to or from a server, supporting various protocols such as HTTP, HTTPS, FTP, FTPS, SCP, SFTP, LDAP, and more. It's commonly used for tasks like fetching web pages, uploading files, testing APIs, and debugging network-related issues. Here's an overview of how Curl works and some common use cases:

Image description

Image description

These are just a few examples of what Curl can do. Its flexibility and support for various protocols make it a powerful tool for interacting with servers and debugging network communications from the command line.

Top comments (1)

Collapse
 
heyeasley profile image
heyeasley 🍓🥭

Cool. Useful. Best regards.