linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Введение
  • Уроки
  • How it works
  • Симулятор
  • База знаний
  • Собеседование
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/Commands/cmd-ip

kb/commands ── Commands ── intermediate

ip: Swiss army knife for network configuration

`ip` is the iproute2 frontend that replaces the old ifconfig, route, and arp tools. Subcommands: `ip addr` (addresses), `ip link` (interfaces), `ip route` (routing table), `ip neigh` (ARP).

view as markdownaka: iproute2, ip-command

Basic syntax

ip [-OPTIONS] OBJECT [COMMAND [ARGUMENTS]]

The main OBJECTs:

objectwhat it covers
addrIP addresses on interfaces
linknetwork interfaces (up/down, MAC, MTU, type)
routerouting table
neighneighbors (ARP/NDP)
rulepolicy-routing rules
netnsnetwork namespaces (see namespaces)
tunneltunnel interfaces (gre, ipip, sit)
xfrmIPsec
monitorlive stream of netlink events

Useful options

  • -br - brief format (one line per entry)
  • -4 / -6 - IPv4 only / IPv6 only
  • -c - colorize
  • -j - JSON output (useful in scripts)
  • -s - statistics (counters)

Examples by object

addr

bash
ip -4 -br addr            # compact IPv4 list
ip addr show eth0         # one interface in detail
sudo ip addr add 10.0.0.5/24 dev eth0
sudo ip addr del 10.0.0.5/24 dev eth0

link

bash
ip -br link               # all interfaces, brief
sudo ip link set eth0 down / up
sudo ip link set eth0 mtu 9000
sudo ip link set eth0 address aa:bb:cc:00:11:22
sudo ip link add veth0 type veth peer name veth1   # see [[veth-pair]]

route

bash
ip route                            # all routes
ip route get 8.8.8.8                # which route will be selected for this address
sudo ip route add 10.5.0.0/16 via 10.0.0.1
sudo ip route add default via 192.168.1.1
sudo ip route del 10.5.0.0/16

neigh

bash
ip neigh                            # ARP table (see [[arp]])
sudo ip neigh flush all
sudo ip neigh add 10.0.0.5 lladdr aa:bb:cc:dd:ee:ff dev eth0

netns

bash
sudo ip netns add red
ip netns list
sudo ip netns exec red bash         # run a command inside the netns
sudo ip link set veth1 netns red

ip monitor: live events

A useful mode for debugging network events:

bash
ip monitor          # stream all netlink events: link/addr/route/neigh
ip monitor route     # route changes only

When something changes on its own, run monitor to see what triggered it.

JSON for automation

bash
ip -j addr show eth0 | jq '.[0].addr_info[] | select(.family=="inet") | .local'
# -> "10.0.0.5"

This is the right way to parse ip output in scripts. Do not grep plain text.

§ команды

bash
ip -br -c addr

Brief and colorized output. The go-to command for a quick network overview.

bash
ip -j route show | jq

JSON route output. Ideal for monitoring scripts.

bash
ip route get 8.8.8.8

Shows which route will be selected for the given address, including the auto-selected source address.

bash
ip monitor link

Stream interface UP/DOWN events in real time.

bash
ip -s link show eth0

Show rx/tx packet and byte counters for the interface.

§ см. также

  • ipv4-addressingIPv4: Addressing and CIDRAn IPv4 address is 32 bits written as `a.b.c.d`. The **/N** suffix is the prefix length: `/24` fixes the first 24 bits for the network and leaves 8 bits for hosts (256 addresses).
  • routing-tableRouting tableThe routing table lists where to send packets for each destination. The longest matching prefix wins.
  • policy-routingPolicy Routing: Rule-Based RoutingPolicy routing selects a routing table based on src-IP, fwmark, iif, or tos. ip rule + ip route table N. Multi-uplink, source-based routing, VRF, split-tunnel VPN. RPDB is the Routing Policy Database.
  • namespacesLinux namespacesNamespaces are a kernel mechanism that gives a process its own isolated view of a resource (network, mount points, PID, UID, IPC, hostname, time). Every container is built on them.

§ упоминается в уроках

  • ›advanced-01-namespaces
  • ›intermediate-01-network-101
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies