So i’m looking to set up a single area OSPF in my environment and I’d like to set up a loopback interface and hard code the router-id as the loopback interface. In my readings, I’ve seen people mention that OSPF treats a loopback interface as a stub host. I’ve seen other people mention that you can use the command “ip ospf network point-to-point” and OSPF will now treat the loopback as point to point and advertise the actual subnet mask. Is there any advantage to using one method over the other? Are LSA’s treated differently when using one setup over the other? Do you have any recommendation on which to use?
First of all, the use of the loopback interface as the router ID is completely independent of how OSPF treats loopback subnets as far as routing goes. An OSPF router will use the following steps to determine its router ID:
- It will use the manually configured router ID
- if a manually configured router ID is not available, it will use the highest IP address on a loopback interface
- If there are no loopback interfaces, it will use the highest IP address on an active non-loopback interface
So if you have a single loopback interface on the device and there is no manually configured router ID, that loopback interface will be used as the router ID.
Now having said that, the router ID will be chosen in the above way regardless of how OSPF views the loopback interface, indeed, regardless of whether or not the network of the loopback interface is participating at all in OSPF.
So, we can deal with the rest of your post as a completely separate question:
OSPF does indeed treat loopback interfaces as stub hosts. The loopback addresses are actually advertised by OSPF as host routes with a mask of /32 regardless of what their configured subnet mask is. Now it should be made clear that loopback interfaces are unavailable for regular data traffic, however, they are available for testing purposes such as for using pings.
Yes that is the case, when this command is used, the loopback interface that participates in OSPF will advertise its actual configured subnet mask rather than the /32 subnet mask. Now there are some cases where you would want OSPF to have the full subnet mask being advertised rather than the default stub host. The most common of these is when you are using a loopback interface to maintain a subnet from which IP addresses are borrowed by virtue of the
ip unnumbered command (take a look at this Cisco documentation to learn more about unnumbered interfaces) .
In any case, keep in mind that the subnet of the loopback does not actually have to participate in the OSPF routing process at all, it can still be used as the router ID for the OSPF process.
I hope this has been helpful!
Thank you Laz that was very helpful!