Tuesday, February 1, 2011

How IOS Cheats When Using the Network Command

When you type a command into the IOS CLI you normally expect IOS to execute your instruction as typed.  You don't expect IOS to modify what you typed, or to assume you meant something other than what you actually typed in.  In fact, to me that behavior is extremely undesirable.  I understand there are some assumed defaults where if you omit certain keywords then IOS imposes on for you.  That's fine.  But sometimes IOS changes what you typed in to something completely different.  The network command contains one such example.


First off, let me say that you should never use this variant of the network command in real life.  It's a theoretical byproduct that shows you how the syntax works, and may possibly be OK if your own labbing, but never in a million years should you use this in production.  It's sloppy, and may have unintended results.

The command I'm speaking of is the network command that includes all networks.  For OSFP it is:

        network 0.0.0.0 255.255.255.255 area 0

Or for EIGRP it would be:

        network 0.0.0.0 255.255.255.255

If you've never used them they basically activate the routing process on every configured interface on the entire router in one shot.  It uses the same logic the quad zero default route uses (except the network command uses a wildcard mask and not a subnet mask so it's inverted).

So if one was to follow this logic to the other end of the spectrum you could enter in a command that includes none of the configured interfaces.  For OSPF and EIGRP respectively you'd have:

        network 0.0.0.0 0.0.0.0 area 0

        network 0.0.0.0 0.0.0.0

Since these commands are going to effectively do nothing they are not really very useful.  But is that really the case?  No.  IOS assumes you're experiencing a brain fart and changes the command after you hit enter.
           
        Router1#sh run | s ospf
        ip ospf network broadcast
        Router1#conf t
        Enter configuration commands, one per line.  End with CNTL/Z.
        Router1(config)#router ospf 69
        Router1(config-router)#network 0.0.0.0 0.0.0.0 area 0
        Router1(config-router)#end
        Router1#sh run | s ospf
        ip ospf network broadcast
        router ospf 69
        log-adjacency-changes
        network 0.0.0.0 255.255.255.255 area 0

        Router1#sh ip ospf interface brief
        Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
        Gi0/0        69    0               172.16.0.1/24      1     DR    0/0
 
        Router1#sh run | s eigrp
        Router1#conf t
        Enter configuration commands, one per line.  End with CNTL/Z.
        Router1(config)#router eigrp 69
        Router1(config-router)#network 0.0.0.0 0.0.0.0
        Router1(config-router)#end
        Router1#sh run | s eigrp
        router eigrp 69
        network 0.0.0.0
        auto-summary

        Router1#sh ip eigrp interfaces
        IP-EIGRP interfaces for process 69

                        Xmit Queue   Mean   Pacing Time   Multicast    Pending
        Interface        Peers  Un/Reliable  SRTT   Un/Reliable   Flow Timer   Routes
        Gi0/0              0        0/0         0       0/1            0           0
        Router1#

2 comments:

  1. Hi Jason
    If Im not wrong, this was the way on how to define all interfaces in the old way (0.0.0.0 0.0.0.0) at least for OSPF. Cisco did some when change it to 0.0.0.0 255.255.255.255 hence it is converting it to 0.0.0.0 255.255.255.255 nowadays.

    regards

    Michel

    ReplyDelete
  2. Hi Michel,

    I seem to remember at one point using a subnet mask to configure OSPF and not a wildcard mask... But I've never been able to prove it. I did just go back in time on the DocCD and as far back as IOS 12.0 the configuration guides state that it is a wildcard mask. Still, you may be right and that would certainly explain the behavior.

    Jason

    ReplyDelete