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.
ip route replace default via 192.0.2.1 dev enp1s0Correct. 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.
ip neighbor replace default via 192.0.2.1 dev enp1s0Incorrect. 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
Interface counters
Kernel-maintained counts of packets, errors, and drops at an interface.
Socket
A local or remote endpoint associated with a transport protocol and process.
Path tracing
A diagnostic method that observes hops and path limits toward a destination.