The legacy command `ifconfig eth0 192.168.1.10 netmask 255.255.255.0` assigns an address to an interface. Which iproute2 command does the same job?

LPIC-1 Exam 102-500, objective 109. Networking fundamentals medium

Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.

It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.

The options

Not correct ip link set eth0 192.168.1.10/24

Wrong. `ip link` manages layer-2 properties of the device: up/down state, MTU, MAC address, name. It cannot assign an IP address.

Not correct ip route add 192.168.1.10/24 dev eth0

Wrong. `ip route add` inserts a routing table entry telling the kernel how to reach a destination network. It does not give the interface an address.

Not correct ip addr show eth0 192.168.1.10/24

Wrong. `ip addr show` is read-only; it displays addresses. The subcommand that modifies is `add` (or `del`).

Correct ip addr add 192.168.1.10/24 dev eth0

Correct. `ip addr add ADDRESS/PREFIX dev IFACE` attaches the address to the interface. Note that iproute2 expects CIDR prefix notation rather than a separate netmask keyword.

Why

iproute2 splits what ifconfig did into objects: `ip addr` for addresses, `ip link` for the device itself, `ip route` for routing, `ip neigh` for the ARP/neighbour cache. Unlike ifconfig, `ip addr add` adds an address rather than replacing the existing one, so an interface can hold several; remove one with `ip addr del`. Addresses set this way are not persistent across reboots.

Where this comes from

Cited
manual page ip-address(8)

Practise this

Reading one question is not practice. The trainer will draw a set from objective 109 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500