Routing - network vs redistribute connected commands

When using a dynamic routing protocol such as OSPF or EIGRP, it is possible to use either the network command or the redistribute connected command to "inject" the directly connected networks into the routing protocol.

Which method you will use depends upon what you want to achieve. Here is a description of the behavior of each choice:

  1. network Command:
    • Purpose: The network command is primarily used within a routing protocol configuration to specify which interfaces or IPv4 or IPv6 networks should participate in that particular routing protocol.
    • Effect: When you specify a network using the network command, the router will start sending and receiving routing updates on interfaces that belong to that specified network. Additionally, the router will advertise that network to its neighbors.
    • Example: If you're configuring OSPF on a router and you want the network to participate in OSPF, you would use:
      router ospf 1 network area 0
  2. redistribute connected Command:
    • Purpose: This command is used within a routing protocol configuration to inject routes for directly connected networks into the routing protocol. This is typically used when you want to share a connected route with other routers participating in the dynamic routing protocol, especially if that connected route isn't already being advertised by the network command under the routing protocol.
    • Effect: Directly connected routes (i.e., routes for networks to which the router has a direct physical or logical connection) are injected into the routing table of the dynamic routing protocol. These routes will then be advertised to other routers participating in that protocol.
    • Example: If you have a directly connected network (let's say on interface GigabitEthernet0/1) and you want to redistribute this into OSPF:
      router ospf 1 redistribute connected subnets
      The subnets keyword ensures that even subnets (and not just classful networks) get redistributed.

Main Difference:

While both commands involve routing and route advertisement, the primary difference lies in their approach:

  • The network command directly involves an interface or a set of interfaces in the dynamic routing protocol. Only those networks specified by the network command will be advertised. The interfaces corresponding to those networks will actively participate in creating neighbor adjacencies. This option is more granular as you can choose what networks to advertise.
  • The redistribute connected command takes already existing directly connected routes and injects them into the dynamic routing protocol, allowing them to be advertised to neighbors. Interfaces corresponding to those networks will not actively participate in routing protocol operations. This option is less granular as it doesn't allow you to choose which connected routes to inject, unless you use a Route-map or other related filtering process.-