10 Replies Latest reply: Oct 17, 2014 7:53 AM by Ray G. RSS

    IP default-network vs ip route 0.0.0.0/0

    Aimen Khudair

      it says here, If you use both the ip default-network and ip route 0.0.0.0 0.0.0.0 commands to configure candidate default networks, and the network used by the ip default-network command is known statically, the network defined with the ip default-networkcommand takes precedence and is chosen for the gateway of last resort. Otherwise if the network used by the ip default-network command is derived by a routing protocol, the ip route 0.0.0.0 0.0.0.0 command, which has a lower administrative distance, takes precedence and is chosen for the gateway of last resort.

       

       

      Can some one help me to verify if this is true about the behavior of ip default-network and ip route 0.0.0.0/0 command??

      when i tried to apply this in PT, I configured a static route for network 198.10.1.0, and used this network for the ip default-network command, and the gateway of last resort was set as it shown in the show ip route :

       

       

      2513(config)#do sh ip route

      Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

             E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

             i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

             * - candidate default, U - per-user static route, o - ODR

             P - periodic downloaded static route

       

      Gateway of last resort is 161.44.192.2 to network 198.10.1.0

       

           131.108.0.0/24 is subnetted, 1 subnets

      C       131.108.99.0 is directly connected, Serial0/0/0

           161.44.0.0/24 is subnetted, 1 subnets

      C       161.44.192.0 is directly connected, FastEthernet0/0

      S*   198.10.1.0/24 [1/0] via 161.44.192.2

       

       

       

      Then when I am configuring default route using the ip route 0.0.0.0/0 131.108.99.2 command, it takes precedence and chosen for the gateway of last resort. although that the network used for the ip default-network is known statically for the router:

       

       

      2513(config)#do sh ip route
      Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
             E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
             i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
             * - candidate default, U - per-user static route, o - ODR
             P - periodic downloaded static route
      Gateway of last resort is 131.108.99.2 to network 0.0.0.0
           131.108.0.0/24 is subnetted, 1 subnets
      C       131.108.99.0 is directly connected, Serial0/0/0
           161.44.0.0/24 is subnetted, 1 subnets
      C       161.44.192.0 is directly connected, FastEthernet0/0
      S*   198.10.1.0/24 [1/0] via 161.44.192.2
      S*   0.0.0.0/0 [1/0] via 131.108.99.2

       

       

      2513(config)#do sh ip route

      Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

             E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

             i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

             * - candidate default, U - per-user static route, o - ODR

             P - periodic downloaded static route

       

      Gateway of last resort is 131.108.99.2 to network 0.0.0.0

       

           131.108.0.0/24 is subnetted, 1 subnets

      C       131.108.99.0 is directly connected, Serial0/0/0

           161.44.0.0/24 is subnetted, 1 subnets

      C       161.44.192.0 is directly connected, FastEthernet0/0

      S*   198.10.1.0/24 [1/0] via 161.44.192.2

      S*   0.0.0.0/0 [1/0] via 131.108.99.2

       

       

       

      Thanks in advance,

       

      Aimen

        • 1. Re: IP default-network vs ip route 0.0.0.0/0
          Michael Law

          The ip default-network command is used mostly with routing protocols. The ip route command is used with static routing. Both are achieving the same goals but can be used in different scenarios. If you have a routing protocol for a domain, and you would like to advertise to the rest of the routers that a default route, you would implement the ip default-network command. This would cause the routing protocol to carry the candidate for default network in its routing updates to all routers in the domain.

           

          The ip route 0.0.0.0 0.0.0.0 xx is a command that is statically assigned. This is called a default network because the all-zeros syntax means to catch all routes. The ip route command is not automatically carried in routing updates like the ip default-network command is in some routing protocols. You must redistribute the static command into a routing protocol for it to be carried.

           

          In a network where, there are multiple default gateways, you must understand that certain parts of the network will be routed out one direction, and other parts might be routed out another direction. Understand that each router makes it's own forwarding decision even when the network is converged with consistent routing information. This can cause an un-even balance of routing out of default routes.

           

          In this scenario, let's say you typed ip default-network on router 161.144.91.2 (top one) and all routers are converged. This will cause all routers in the domain to see a candidate default network as 192.10.1.0/24. Now, let's say you type ip route 0.0.0.0 0.0.0.0 131.108.99.2 on the middle router. You have just created a routing loop. How? the bottom router sees the candidate default route at the top, and sends all packets that did not match a more specific route to the middle router. The middle router has been configured with IP route back to the lower router because it was statically assigned. It's AD takes precedence over the ip default-network command and packets are sent back down to the bottom router.

           

          Now you ask why do the ADs look the same for both ip route 0.0.0.0 0.0.0.0 and ip default-network? It's because you have configured them on the same router. Go to another router and you will see the 192.10.0/24 network have a different AD. This is because on the local router, you have statically defined both default routes. But, ip default-network command is sent across routing updates and therefore carries the routing protocol's AD instead of a static one.

           

          That is a complicated answer to ur scenario. If you don't understand the answer, make you take away a few ideas: all routers make routing decisions on their own regardless of influences from others. AD dictates a route "believability", the lower the better and lastly, unless you know exactly what you're doing: don't install multiple default routes or routing loops may appear. This happens a lot.

           

          Hope that helps. Good Luck

           

          Mike

          • 2. Re: IP default-network vs ip route 0.0.0.0/0
            Aimen Khudair

            Well Mike, thanks for you reply, but you are talking about the second part of the note i posted in the beginning of my post, which is when the network used by the ip default-network command is not known statically ( in other words it is known through an ip routing protocol, just like your example), this i understand.

             

            My Question exactly is, when the network used by the ip default-network command is known statically, and we configure the ip route command as well in the same router ( all the configuration is made in the middle router), and according to the not, the ip route 0.0.0.0/0 command should take precedence and chosen for the gateway of last resort, but what is happening in my router ( middle router ) is that the ip default-network taking precedence and chosen for the gateway of last resort.

             

            middle router configuration

             

             

            2513#sh run
            Building configuration...
            Current configuration : 709 bytes
            !
            version 12.4
            no service timestamps log datetime msec
            no service timestamps debug datetime msec
            no service password-encryption
            !
            hostname 2513
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            !
            interface FastEthernet0/0
            ip address 161.44.192.1 255.255.255.0
            duplex auto
            speed auto
            !
            interface FastEthernet0/1
            no ip address
            duplex auto
            speed auto
            shutdown
            !
            interface Serial0/0/0
            ip address 131.108.99.1 255.255.255.0
            clock rate 64000
            !
            interface Serial0/0/1
            no ip address
            shutdown
            !
            interface Vlan1
            no ip address
            shutdown
            !
            ip classless
            ip default-network 198.10.1.0
            ip route 198.10.1.0 255.255.255.0 161.44.192.2
            ip route 0.0.0.0 0.0.0.0 131.108.99.2
            !
            !
            !
            !
            !
            !
            !
            line con 0
            line vty 0 4
            login
            !
            !
            !
            end

            2513#sh run

            Building configuration...

             

            Current configuration : 709 bytes

            !

            version 12.4

            no service timestamps log datetime msec

            no service timestamps debug datetime msec

            no service password-encryption

            !

            hostname 2513

            !

            interface FastEthernet0/0

            ip address 161.44.192.1 255.255.255.0

            duplex auto

            speed auto

            !

            interface FastEthernet0/1

            no ip address

            duplex auto

            speed auto

            shutdown

            !

            interface Serial0/0/0

            ip address 131.108.99.1 255.255.255.0

            clock rate 64000

            !

            interface Serial0/0/1

            no ip address

            shutdown

            !

            interface Vlan1

            no ip address

            shutdown

            !

            ip classless

            ip default-network 198.10.1.0

            ip route 198.10.1.0 255.255.255.0 161.44.192.2

            ip route 0.0.0.0 0.0.0.0 131.108.99.2

            !

             

            line con 0

            line vty 0 4

            login

            !

            end

             

             

            Regards,

            Aimen

            • 3. Re: IP default-network vs ip route 0.0.0.0/0
              Michael Law

              Hi Aimen,

               

              What is your confirmation that the router is using the ip default-network command to forward packets to a default network? According to your show ip route command in the first post, it shows both with AD of 1. This implies that both are statically assigned on the router. Like I said both are similar in their goals but are for different scenarios.

              • 4. Re: IP default-network vs ip route 0.0.0.0/0
                Aimen Khudair

                Hi Mike,

                 

                This is exactly my question, when both configured in the same router with AD=1, which one should take precedence and is chosen for the Gateway of last resort ??

                 

                According to the Note, which I found in Cisco.com ( link attached ), the ip default-network should take precedence and chosen for the gateway of last resort, but in my configuration what is happening is the contrary.

                 

                http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094374.shtml#flagging

                 

                 

                Regards,

                Aimen

                • 5. Re: IP default-network vs ip route 0.0.0.0/0
                  Aimen Khudair

                  Hi Folks,

                   

                  can someone help me with this issue, I would appreciate that.

                   

                  Thanks,

                  Aimen

                  • 6. Re: IP default-network vs ip route 0.0.0.0/0
                    Izhar Kazmi

                    The ip default-network command is classful

                    The ip default-network command is classful.

                    This means that if the router has a route to the subnet defined by this command, the router installs the route to the major net. and if the major network is devided into subnets in routing table, no network (subnet) has been flagged as the default network. The ip default-network command must be issued again, using the major net, in order to flag the candidate default route.

                     

                    By the ip route (static) command, we can use any ip to set it as the gateway of last resort.

                     

                    izharkazmi@gmail.com

                    • 7. Re: IP default-network vs ip route 0.0.0.0/0
                      Shahryar Ali - CCDA / CCNA R&S

                      The default route configured with IP  default-Network command is NOT a static route.it's administrative distance is identical to the distance of the underlying classful network. This is the reason your static default route takes precedence.

                      • 8. Re: IP default-network vs ip route 0.0.0.0/0
                        Shahryar Ali - CCDA / CCNA R&S

                        In your example the route confgured with IP default- network command should take precedence as the both routes have AD=1. You need to confirm if that route is properly functional.Look for the reverse route issue and any ACL issue which can restrict it to act as a default route.

                        • 9. Re: IP default-network vs ip route 0.0.0.0/0
                          guanbowen

                          em.. very interesting topic. I just found this one today, and did some tests based on your theory.

                          Pretty much, you have to use classful network after ip default-network command to make it work. however, that classful network must have a route in routing table (subnet routes do not count).

                          When you say the command has to be flagged again to make it work, I found it is not all true. What it does is if you issue ip default-network 'subnet' command, the router will create a static route in the routing table for the classful network, but this is only trure if the 'subnet' you used also has a route in the routing table. For example, you try to make 20.20.20.0 as your last resort network, so you put 'ip default-network 20.20.20.0' in the router. Now, if you have a route in the routing table for network such as 20.20.20.0/24 or 20.20.20.0/30 or something similar which can cover 20.20.20.0, it will then creat a static route for network 20.0.0.0/8 with next hop ip 20.20.20.0. so if you issue 'ip default-network 20.0.0.0', it will give you the last escort network as 20.0.0.0 through next hop 20.20.20.0.

                          This also works with ip add 20.20.20.1/2/3 as well as it is covered in the routing table.

                           

                          what I have also found is if the classful ip routes in routing table has next hop as an interface, ip default-network wont work. for example, you have a static route in the routing table saying '20.0.0.0/8 is directly connected, FastEthernet1/0', whatever you do, ip default-network cannot use 20.0.0.0/8 as a default gateway network, it has to be an next hop ip address in the routing table.

                           

                          hope it makes some sense to you, and I only did this through GNS3.

                           

                          Cheers.

                          • 10. Re: IP default-network vs ip route 0.0.0.0/0
                            Ray G.

                            Although it's very unlikely this issue is still ongoing from the date of the posts, but,

                             

                            Why are you trying to compare an ip default-network for a defined network vs an ip route to 0.0.0.0?

                             

                            You have to remember that the gateway of last resort is the one route to be used when no other routes for that network exist.

                             

                            By doing ip default-network 198.10.1.0 alone, that could be easily overriden by even an ip default-network of 198.10.0.0, because of the latter being advertised for the major network.

                             

                            By adding the ip route 0.0.0.0/0, your previous ip default-network is no longer preferred as a destination to the biggest major network, and a route to the 198.10.1.0 is known and placed in the routing table.

                             

                            If you want to test ip default-network taking precedence over ip route, I would suggest implementing and comparing them both using the same classful network. Otherwise, it would almost be the equivalent of comparing routes preferred based on AD.

                             

                            http://www.cisco.com/c/en/us/support/docs/ip/routing-information-protocol-rip/16448-default.html