ip default-gateway command

Unanswered Question
May 13th, 2008


I am just trying to learn about cisco routers and i came across th ip default-gateway command used at the global configuration mode

What is that command used for

I know on pcs we set the default gateway address for the router

please inform me

I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4.3 (3 ratings)
jim_berlow Tue, 05/13/2008 - 13:57

The ip default-gateway command is similar in nature to setting the default gateway address on your pc. Basically this command tells the router "if I don't have a route for this network then send it to this ip address who will know what to do with it". It is basically setting a default gateway for your router. In case you are wondering, this command is frequently used on routers as you don't want the router to discard a packet simply because it doesn't know what to do with it.

Does that make sense?

gurkamal01 Tue, 05/13/2008 - 14:12


Appreciate your response

So mostly the default gateway address on a router is of another router which has more routes on it or something else

I mean to say how is it determined that this router (A) should be a default gateway of router (B)


srue Tue, 05/13/2008 - 19:45

the "ip default-gateway" command is used when IP routing is disabled, and only for traffic sourced from the device that the command is configured on. you will commonly find this command configured on layer 2 switches but not usually on routers.

On devices where routing is enabled, whether it's a router or layer 3 switch, the routing table (including default ROUTES) takes precedence and this command is simply ignored.

CriscoSystems Sat, 05/17/2008 - 14:44

Thanks for that, srue, 'cause that explains part of what I'm mixed up about: the difference between the default gateway and the gateway of last resort. In my lab routing tables I often see "gateway of last resort is not set"; then I configure a default gateway; I see it configured in the output of show run, but still sh ip route sez last resort isn't set.

I didn't know default-gateway was just for locally sourced traffic - but last resort IS for routed traffic that the local device has no route for, correct? AND, how on earth do I configure a last resort gateway?!? You have no idea how much scouring I've done on this site and google, for "IOS" "gateway" "last resort" and found nothing.

Richard Burts Sun, 05/18/2008 - 04:01


Steven gave a good explanation. It appears that you are focused on the second part of his explanation, which is that ip default-gateway is for locally sourced traffic. The really important part of the explanation is the first part about ip routing not being enabled. If ip routing is enabled then ip default-gateway is ignored and if ip routing is not enabled the ip default-gateway is used.

There are 2 common circumstances where the router may be using ip default-gateway: if the router is configured with "no ip routing" or if the router is booted into rommon. I frequently configure routers with ip default-gateway just to cover the possibility of rommon.

To get a gateway of last resort into your routing table configure a default route or have your routing protocol learn a default route. The easy way to get a gateway of last resort is a static default route such as: ip route




This Discussion