LX0-104 · Question #666
Given the following routing table: Why does the command route add default gw 192.168.1.1 fail?
The correct answer is A. Because there is no route to 192.168.1.1.. A common reason for the route add default gw command to fail is that the specified gateway IP address is not reachable through any existing route in the routing table.
Question
Options
- ABecause there is no route to 192.168.1.1.
- BBecause only one route can exist at a time.
- CBecause there is already a default route.
- DBecause default routes can not be set manually.
- EBecause default routes must be set with ifconfig
How the community answered
(43 responses)- A79% (34)
- B2% (1)
- D7% (3)
- E12% (5)
Why each option
A common reason for the `route add default gw` command to fail is that the specified gateway IP address is not reachable through any existing route in the routing table.
For a default gateway to be added, the system must already know how to reach that gateway IP address; if there is no existing direct or network route to the gateway's subnet, the system cannot forward packets to it, causing the command to fail with an 'unreachable gateway' error.
Multiple routes, including multiple default routes with different metrics, can exist simultaneously in a routing table; therefore, 'only one route can exist' is an incorrect statement.
While an existing default route might prevent a new one from taking precedence without specific configuration, the command itself would not typically fail due to an existing default route unless there's a specific conflict, but rather would just add a less preferred one; the inability to reach the gateway is a more fundamental failure.
Default routes can indeed be set manually using commands like `route` or `ip route`, contradicting the statement that they cannot be set manually.
Default routes are configured using routing commands like `route` or `ip route`, not `ifconfig`, which is used for configuring network interfaces.
Concept tested: Routing table gateway reachability
Source: https://www.man7.org/linux/man-pages/man8/route.8.html
Topics
Community Discussion
No community discussion yet for this question.