Add 192.0.2.10/24 to enp1s0 for the running state only.
Do not edit persistent configuration files.
Which command is appropriate?
ip address add ADDRESS/PREFIX dev INTERFACE adds an address to a running interface. It is normally lost when configuration is reapplied or the system restarts.
Detailed explanation
ip route add 192.0.2.10/24 dev enp1s0Incorrect. ip route add adds a route, not a local interface address.
ip link add 192.0.2.10/24 dev enp1s0Incorrect. ip link add creates a link rather than adding an address to an existing one.
ip address add 192.0.2.10/24 dev enp1s0Correct. It adds the CIDR address to enp1s0.
ip neighbor add 192.0.2.10/24 dev enp1s0Incorrect. ip neighbor add modifies the neighbor cache.
Try it yourself
An example you can run in a temporary verification environment.
ip address help 2>&1 | sed -n '1,3p'Expected result
ip addressのadd、delete、showなどの構文概要Key points
- address add
- Specify CIDR prefix
- Select the interface with dev
Notes
- Environment: iproute2 help / 状態変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Network interface
A host attachment whose link state and addresses can be managed.
Connection profile
Saved settings used to activate a persistent network connection.
Routing table
Rules that select the next hop for each destination network.