How to use the command "ip-neighbour" (with examples)

How to use the command "ip-neighbour" (with examples)

Code:

ip neighbour

Motivation:

This command is commonly used to display the entries in the neighbour/ARP table. The neighbour/ARP table contains mappings of IP addresses to MAC addresses of devices in the local network.

Explanation:

The ip neighbour command without any additional arguments simply displays the entries in the neighbour/ARP table.

Example Output:

192.168.1.1 dev eth0 lladdr 00:11:22:33:44:55 STALE
192.168.1.10 dev eth0 lladdr 66:77:88:99:aa:bb REACHABLE

This output shows two entries in the neighbour/ARP table. The first entry maps the IP address 192.168.1.1 to the MAC address 00:11:22:33:44:55 with a status of STALE. The second entry maps the IP address 192.168.1.10 to the MAC address 66:77:88:99:aa:bb with a status of REACHABLE.

Example 2: Remove entries in the neighbour table on device eth0

Code:

sudo ip neighbour flush dev eth0

Motivation:

There may be situations where it is necessary to remove all entries in the neighbour table for a specific network interface, such as when troubleshooting network connectivity issues or when reconfiguring the network.

Explanation:

The ip neighbour flush command with the dev option followed by the network interface (eth0 in this example) removes all entries in the neighbour table associated with that interface.

Example Output:

No output is generated by this command.

Example 3: Perform a neighbour lookup and return a neighbour entry

Code:

ip neighbour get 192.168.1.1 dev eth0

Motivation:

Sometimes it is necessary to perform a neighbour lookup to obtain information about a specific IP address in the neighbour/ARP table, such as the associated MAC address or other attributes.

Explanation:

The ip neighbour get command with the IP address (192.168.1.1 in this example) and the network interface (eth0 in this example) performs a neighbour lookup and returns the corresponding neighbour entry.

Example Output:

192.168.1.1 dev eth0 lladdr 00:11:22:33:44:55 STALE

This output shows the neighbour entry for the IP address 192.168.1.1, which includes the associated MAC address 00:11:22:33:44:55 and a status of STALE.

Example 4: Add an ARP entry for the neighbour IP address to eth0

Code:

sudo ip neighbour add 192.168.1.10 lladdr 66:77:88:99:aa:bb dev eth0 nud reachable

Motivation:

Adding an ARP entry is useful when manually managing the neighbour/ARP table, such as when configuring static ARP mappings or resolving network connectivity issues.

Explanation:

The ip neighbour add command with the IP address (192.168.1.10 in this example), MAC address (66:77:88:99:aa:bb in this example), network interface (eth0 in this example), and the nud reachable option adds an ARP entry for the neighbour IP address to the specified network interface.

Example Output:

No output is generated by this command.

Example 5: Delete an ARP entry for the neighbour IP address from eth0

Code:

sudo ip neighbour del 192.168.1.10 lladdr 66:77:88:99:aa:bb dev eth0 nud reachable

Motivation:

Deleting an ARP entry is necessary when removing unnecessary or outdated mappings from the neighbour/ARP table.

Explanation:

The ip neighbour del command with the IP address (192.168.1.10 in this example), MAC address (66:77:88:99:aa:bb in this example), network interface (eth0 in this example), and the nud reachable option deletes the ARP entry for the neighbour IP address from the specified network interface.

Example Output:

No output is generated by this command.

Example 6: Change an ARP entry for the neighbour IP address on eth0

Code:

sudo ip neighbour change 192.168.1.10 lladdr aa:bb:cc:dd:ee:ff dev eth0

Motivation:

Changing an ARP entry is necessary when the associated MAC address of a neighbour IP address has been updated.

Explanation:

The ip neighbour change command with the IP address (192.168.1.10 in this example), new MAC address (aa:bb:cc:dd:ee:ff in this example), network interface (eth0 in this example), and the nud reachable option changes the ARP entry for the neighbour IP address on the specified network interface.

Example Output:

No output is generated by this command.

Example 7: Replace an ARP entry for the neighbour IP address on eth0

Code:

sudo ip neighbour replace 192.168.1.10 lladdr aa:bb:cc:dd:ee:ff dev eth0

Motivation:

Replacing an ARP entry is necessary when completely updating an existing neighbour IP address with a new MAC address.

Explanation:

The ip neighbour replace command with the IP address (192.168.1.10 in this example), new MAC address (aa:bb:cc:dd:ee:ff in this example), network interface (eth0 in this example), and the nud reachable option replaces the ARP entry for the neighbour IP address on the specified network interface.

Example Output:

No output is generated by this command.

Example 8: Modify an ARP entry for the neighbour IP address on eth0

Code:

sudo ip neighbour change 192.168.1.10 lladdr aa:bb:cc:dd:ee:ff dev eth0 nud permanent

Motivation:

Modifying an ARP entry is necessary when changing the attributes of an existing neighbour IP address, such as the NUD (Neighbor Unreachability Detection) state.

Explanation:

The ip neighbour change command with the IP address (192.168.1.10 in this example), new MAC address (aa:bb:cc:dd:ee:ff in this example), network interface (eth0 in this example), and the nud permanent option modifies the ARP entry for the neighbour IP address on the specified network interface by changing the NUD state to permanent.

Example Output:

No output is generated by this command.

Related Posts

How to use the command 'brew uninstall' (with examples)

How to use the command 'brew uninstall' (with examples)

The ‘brew uninstall’ command is used to remove a Homebrew formula or cask from your system.

Read More
How to use the command 'ykman config' (with examples)

How to use the command 'ykman config' (with examples)

The ‘ykman config’ command is used to enable or disable YubiKey applications.

Read More
How to use the command 'hostname' (with examples)

How to use the command 'hostname' (with examples)

The hostname command is used to show or set the system’s host name.

Read More