cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
807
Views
15
Helpful
3
Replies

What exactly happens when you type in a routing statement?

rkoloj
Level 1
Level 1

This is something that I always wanted to understand with more granularity.  For example, you want to configure OSPF on a router.

Say you configure the routing statement below on the G0/0 interface:

 

R1(config)# router ospf 1

R1(config-router)#network 192.168.1.0 0.0.0.3 area 0

 

Now if there is a physical interface that is 192.168.1.1, this interface will automatically begin advertising this network on this physical interface?

What if the routing statement is applied to the interface itself?  ie. 'ip router ospf 1'  What is the difference?

 

1 Accepted Solution

Accepted Solutions

Joseph W. Doherty
Hall of Fame
Hall of Fame

"Now if there is a physical interface that is 192.168.1.1, this interface will automatically begin advertising this network on this physical interface?"

Maybe.  That interface will also be a possible candidate to advertise that network but OSPF would need to have acquired a neighbor to do so.  What will happen, though, that interface's network should become part of the OSPF topology its assigned to, and then be advertised to other OSPF neighbors as part of the same topology.

"What if the routing statement is applied to the interface itself? ie. 'ip router ospf 1' What is the difference?"

Depends on the IOS version.  Later Cisco OSPF IOSs support defining the interface's network, as part of an OSPF topology, on the interface itself.  Perhaps the biggest difference, when you do so on the interface, only the interface's network is included.  When you do it with an OSPF network statement, all matching interface networks will be include.

For example, you might have:

R1(config)# router ospf 1
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
This works much like an ACL ACE, i.e. any interface IP which falls within the /24 block would be included. I.e. you don't have to match a corresponding /24 network.

View solution in original post

3 Replies 3

Joseph W. Doherty
Hall of Fame
Hall of Fame

"Now if there is a physical interface that is 192.168.1.1, this interface will automatically begin advertising this network on this physical interface?"

Maybe.  That interface will also be a possible candidate to advertise that network but OSPF would need to have acquired a neighbor to do so.  What will happen, though, that interface's network should become part of the OSPF topology its assigned to, and then be advertised to other OSPF neighbors as part of the same topology.

"What if the routing statement is applied to the interface itself? ie. 'ip router ospf 1' What is the difference?"

Depends on the IOS version.  Later Cisco OSPF IOSs support defining the interface's network, as part of an OSPF topology, on the interface itself.  Perhaps the biggest difference, when you do so on the interface, only the interface's network is included.  When you do it with an OSPF network statement, all matching interface networks will be include.

For example, you might have:

R1(config)# router ospf 1
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
This works much like an ACL ACE, i.e. any interface IP which falls within the /24 block would be included. I.e. you don't have to match a corresponding /24 network.

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello @rkoloj ,

>> Now if there is a physical interface that is 192.168.1.1, this interface will automatically begin advertising this network on this physical interface?

No, because OSPF is a link state protocol and has an Hello discovery mechanism . Routes are exchanged only with true neighbors.

 

So the interface will start to send out OSPF Hellos to 224.0.0.5 ALL OSPF routers on segment and it will start to listen to OSPF hellos if any.

If OSPF hellos are received on in the interface and a series of parameters match the two neighbors will move to two way state.

The parameters that must match are :

the area Id     area 0 or 0.0.0.0  is different from area 1 or 0.0.0.1.

the area type normal, stubby or NSSA ( area 0 must be normal)

the hello timer and dead interval must be the same

The primary addresses of the two devices have to be on the same IP subnet and they must agree on the subnet mask.

OSPF wil not operate on secondary addresses even if it can advertise them . ( this should be Cisco specific)

Authentication parameters if used must match.

 

The two routers must have a different OSPF Router ID.

 

In the two way state each router sees its own OSPF RID listed in the Hello received from the other device.

 

If at least two devices has a non zero OSPF priority on the interface  a Designated Router DR and BDR are elected.

 

If more then two routers are present in the segment : each DR other will build a full adjacency with only the DR and BDR (more on this below).

The process happens between a pair of routers.

From two way state a router will build a full adjacency with the DR by exchanging the OSPF database going via several states (Exstart, Exchange , Loading , Full)

 

At the end of the process both routers have the same ( per area ) LSAs in their database and declare each other in FULL state.

 

A new router connecting to the network will provide its own Router LSA describing itself and the links in the area and it will receive from the other router all the other LSAs of every type that are known in the area.

 

In short OSPF has neighbor state machine concept and  it is not like RIP that starts and sends out routing updates unconditionally.

 

The difference between using ip ospf 1 area 0 under the interface and using a network ... area command under router ospf 1 has been explained by @Joseph W. Doherty : the network ...  area command has the potential to cover multiple interfaces where all of them will be enabled in OSPF for the area (the same one thi is the key point ), the interface level command enables OSPF on that specific interface for the specified area.

 

Hope to help

Giuseppe

 

 

 

Giuseppe well, and further, describes how OSPF will send "hellos" out an OSPF interface, but that's by default.  It's possible to configure such an interface to not send or accept "hellos", i.e. the interface will not be able to establish an OSPF neighbor on that interface (often a good practice for edge facing interfaces).  However, the interface's network will still be in the OSPF topology, i.e. other OSPF routers would be able to route to that interface's network.

Giuseppe also touches on how OSPF works a bit differently from RIP.  Further, although the router protocol section, for different routing protocols, often share similar if not some identical configuration statements, different routing protocols can work a bit differently with how they actually work.  I.e. don't assume one protocol's similar, or even identical, configuration statements, all work exactly alike.

OSPF routing process network statements, which can match multiple interfaces, can be a bit confusing compared to other routing protocols.  Again, as I earlier mentioned, they work somewhat like an ACL's ACE, i.e. you can even match such that "overlapping" network statements will place matched interfaces into different OSPF areas.

Review Cisco Networking for a $25 gift card