Use net-tools route to add 192.0.2.1 as enp1s0's IPv4 default gateway.
Which command is appropriate?
The legacy route syntax is route add default gw GATEWAY INTERFACE. Modern systems generally prefer ip route.
Detailed explanation
route default 192.0.2.1 enp1s0Incorrect. It omits the standard add and gw keywords.
route -n default gw 192.0.2.1 enp1s0Incorrect. -n controls numeric display and does not perform the add operation.
route add 192.0.2.1 default dev enp1s0Incorrect. The default and gateway arguments are in the wrong form.
route add default gw 192.0.2.1 enp1s0Correct. It adds the default route through 192.0.2.1 on enp1s0.
Try it yourself
An example you can run in a temporary verification environment.
route --help 2>&1 | sed -n '1,8p' || printf '%s
' 'route is not installed'Expected result
routeのadd、del、gwなどの構文概要、または未導入メッセージKey points
- route add default
- gw specifies the gateway
- End with the interface
Notes
- Environment: net-tools route 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.