OSPF requirements for forming adjacency
An OSPF adjacency will form between two OSPF routers if:
- they have interfaces on the same network segment/broadcast domain
- they have IP addresses within the same subnet
- they share the same subnet mask
Note that two OSPF routers may have connectivity to each other even if they have a different subnet mask on their interfaces, however, no adjacency will form unless the subnet masks on the interfaces in question are the same.
However, certain technologies can be used to create adjacencies between OSPF routers that are not physically directly connected:
- Virtual Links - Used to link an OSPF area to the backbone area (Area 0) through another area, ensuring continuous OSPF network connectivity even when direct physical links to the backbone are not available.
- GRE tunnels - You can interconnect two OSPF neighbors over a GRE tunnel. The routers believe they are directly connected, but their link is actually tunneled through multiple other devices.
- MPLS VPNs - OSPF can be used to form adjacencies over MPLS VPNs. This is commonly seen in enterprise networks where different branches are connected via an MPLS cloud.