How do you configure a default route, and what is the difference between ip route 0.0.0.0, ip default-gateway and ip default-network?
Show the answer
Say this first
ip route 0.0.0.0 0.0.0.0 <next-hop> installs a static default and is what you use on a router.
ip default-gateway only works when IP routing is off, for example on a layer 2 switch for its management
address. ip default-network is a legacy command that flags a classful network as a candidate default;
you rarely see it now.
Go deeper
On a router
ip route 0.0.0.0 0.0.0.0 203.0.113.1Gateway of last resort is 203.0.113.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 203.0.113.10.0.0.0/0 matches every address with a prefix length of 0, so longest match makes it the last resort.
On a layer 2 switch
no ip routing
ip default-gateway 10.10.99.1With ip routing enabled, IOS ignores ip default-gateway. That is a classic reason a layer 3 switch
cannot be reached from another subnet after someone turned routing on.
Sending a default into a protocol
| Protocol | Usual way |
|---|---|
| OSPF | default-information originate (add always to send it without a default in the RIB) |
| EIGRP | redistribute the static default, or a summary of 0.0.0.0/0 on an interface |
| RIP | default-information originate |
| BGP | neighbor x.x.x.x default-originate, or network 0.0.0.0 with a default in the RIB |
IPv6 uses ipv6 route ::/0 <next-hop>.
They will ask next
Why do people say always is dangerous with OSPF default-information originate?
With
always, the router advertises a default even when it has no way out. If its internet link fails, it keeps attracting traffic and drops it. Withoutalways, the advertisement follows the presence of a default in its own table.
Traps
- Using
ip default-gatewayon a router with routing enabled and expecting it to work.