Home > Network Management > flush

flush: Flush Network Addresses and Routes

`flush` is primarily used as a subcommand of the `ip` utility to clear IP addresses, routing tables, and caches of network interfaces. This is useful for removing old information or resolving issues after network configuration changes. The `ip` command is part of the `iproute2` package.

Overview

The `flush` functionality is used with the `ip` command to remove specific network objects (addresses, routes, caches, etc.). It is commonly used in forms like `ip addr flush`, `ip route flush`, and `ip neigh flush`.

Key Uses

  • Remove IP addresses from network interfaces
  • Delete routing table entries
  • Clear ARP/NDP caches

Key Options

The `flush` subcommand is used in conjunction with other subcommands of the `ip` command and has various options depending on the type of object to be flushed. Here, we cover the main options that can be used with `ip addr flush` and `ip route flush`.

Specifying the Target

Controlling Behavior

Generated command:

Try combining the commands.

Description:

`flush` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Flush all IP addresses on a specific device

sudo ip addr flush dev eth0

Removes all IP addresses assigned to the eth0 interface.

Flush all routing table entries

sudo ip route flush

Removes all routes from the main routing table. (Caution: This may disconnect your network.)

Flush routes for a specific network range

sudo ip route flush to 192.168.1.0/24

Removes all routes pointing to the 192.168.1.0/24 network.

Flush ARP cache entries

sudo ip neigh flush all

Removes all ARP (Address Resolution Protocol) cache entries.

Installation

The `flush` functionality is part of the `iproute2` package and is typically installed by default on most Linux distributions. No separate installation is usually required.

Check Package

You can check if the `iproute2` package is installed by verifying if the `ip` command works.

  • Check Command: ip a

Install Package (Debian/Ubuntu)

sudo apt update && sudo apt install iproute2

If the `iproute2` package is not installed, you can install it with the following command:

Install Package (CentOS/RHEL)

sudo yum install iproute2

If the `iproute2` package is not installed, you can install it with the following command:

Tips & Warnings

Warnings

The `ip flush` command can have an immediate impact on network connectivity, so use it with caution. It should be used carefully, especially on production systems.

  • `ip addr flush` removes all IP addresses from the specified device, which can lead to disconnection if you are connected remotely.
  • `ip route flush` clears the routing table, which can make network communication impossible.

Related Commands

Commands used for other types of flush operations besides network-related ones.

  • `sync`: Used to synchronize file system buffers to disk.
  • `iptables -F`: Used to flush firewall rules.


Same category commands