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.
Incorrect. 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.
Incorrect. -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.
Incorrect. 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.
Correct. 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
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.