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 command for connected networks 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:
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 192.168.1.0/24 network to participate in OSPF, you would use:
router ospf 1 network 192.168.1.0 0.0.0.255 area 0
- Purpose: The
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 10.1.1.0/24 on interface GigabitEthernet0/1) and you want to redistribute this into OSPF:
Therouter ospf 1 redistribute connected subnets
subnets
keyword ensures that even subnets (and not just classful networks) get redistributed.
- 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
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 thenetwork
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.-
Links
https://forum.networklessons.com/t/ospf-distribute-list-filtering/1258/50?u=lagapidis