ip addr: Usage, Options & Common CI Errors
ip addr lists the IP addresses bound to each network interface.
ip addr is the iproute2 replacement for ifconfig. In containers it is how you discover the pod/container IP and confirm an interface came up before a service binds to it.
What it does
ip addr (ip address) displays and manages the addresses assigned to network interfaces. ip addr show lists them; ip addr add/del attach or remove an address. It is the canonical way to read a container's own IP.
Common usage
ip addr show # all interfaces and addresses
ip addr show eth0 # one interface
ip -4 addr show eth0 # IPv4 only
ip -o -4 addr show eth0 | awk '{print $4}' # parse the CIDR
ip addr add 10.0.0.5/24 dev eth0Options
| Subcommand / flag | What it does |
|---|---|
| show [dev] | List addresses (all or one interface) |
| add <cidr> dev <if> | Assign an address to an interface |
| del <cidr> dev <if> | Remove an address |
| -4 / -6 | Restrict to IPv4 / IPv6 |
| -o | One line per record (script-friendly) |
| -br | Brief, columnar output |
Common errors in CI
"Cannot find device "eth0"": the interface name differs (containers often use eth0, but some use ens5 or a veth name) - list with ip addr show first, do not hard-code the name. "RTNETLINK answers: Operation not permitted" on add/del means the step lacks NET_ADMIN (add --cap-add=NET_ADMIN or run privileged). "ip: command not found" - install iproute2. In host-network mode a container sees the host's addresses, which surprises scripts expecting an isolated IP.