The running IPv4 default route points to the wrong gateway.
Update it to 192.0.2.1 via enp1s0 whether or not the old route exists.
Which command is appropriate?
ip route replace updates an existing route or adds it when absent, making it suitable for idempotent default-route configuration.
Detailed explanation
ip route show default via 192.0.2.1 dev enp1s0Incorrect. show only reads the route table.
Incorrect. show only reads the route table.
ip route replace default via 192.0.2.1 dev enp1s0Correct. It replaces or creates the requested default route.
Correct. It replaces or creates the requested default route.
ip address replace default via 192.0.2.1 dev enp1s0Incorrect. address handles local IP addresses, not routes.
Incorrect. address handles local IP addresses, not routes.
ip neighbor replace default via 192.0.2.1 dev enp1s0Incorrect. neighbor handles the neighbor table, not routes.
Incorrect. neighbor handles the neighbor table, not routes.
Try it yourself
An example you can run in a temporary verification environment.
ip route help 2>&1 | sed -n '1,5p'Expected result
ip routeのadd、replace、delete、showなどの構文概要Key points
- replace updates or adds
- default is 0.0.0.0/0
- Specify via and 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
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.