Skip to content

ip

17 commands

The iproute2 tool for addresses, links, routes, neighbours and network namespaces — the modern replacement for ifconfig and route.

  • networking
  • routing
  • interfaces

Install ip

sudo apt install iproute2

Addresses5

ip a

Every interface and its IPv4 and IPv6 addresses (short for ip address show).

ip -br a

Brief one-line-per-interface summary.

ip -4 a show <iface>

IPv4 addresses on one interface.

Link
sudo ip addr add <cidr> dev <iface>

Adds an address (not persistent across reboots).

Link
sudo ip addr del <cidr> dev <iface>

Removes an address.

Link

Routing4

ip r

The routing table; the default route shows your gateway.

Link
ip route get <ip>

Which interface, source address and gateway the kernel would use to reach an address.

Link
sudo ip route add <cidr> via <gateway>

Adds a static route — common when pivoting into internal networks.

Link
sudo ip route del <cidr>

Deletes a route.

Link

Neighbours and namespaces4

ip neigh

The ARP/NDP cache: nearby hosts this machine has talked to.

sudo ip neigh flush all

Clears the neighbour cache.

Link
ip netns list

Network namespaces, used by containers and for isolated testing.

Link
sudo ip netns exec <ns> <cmd>

Runs a command inside a namespace.

Link