I have an OSPF configuration task where I need to send traffic between routers on specified routes. In the picture of logical scheme below you can see that traffic from Loopback0 on R3 needs to flow over R1 and R2 in order to get to Loopback0 on R4. It is marked with red line.
Also Loopback1 interfaces on R3 and R4 need to communicate through blue line (R3-R4). Routers R1, R2, R3 & R4 are currently all part of OSPF area 0.
What method would you recommend me to use in order to make this work?
Well, it might be worth taking a look at what we can’t do and why. OSPF, as a link-state protocol, does not allow you to specify metrics for specific prefixes. OSPF works with LSAs rather than prefixes, and you can filter out specific LSAs from being redistributed, but only between areas. Any LSAs shared within an area, such as in your example here, cannot be filtered. Changing the cost of loopback or other interfaces will affect OSPF routing, but it will do so for all routes, so you can’t differentiate between one or the other.
It is actually quite difficult to influence OSPF routing within an area in the way you are suggesting because parameters like cost, bandwidth, and filtering will affect all routing in the same way, and not based on particular prefixes. That’s how OSPF has been designed. It’s link based and not prefix based.
As far as I can see, there is no way to to do this in OSPF unless you break apart the OSPF area into four areas, one for each router involved. Then you can adjust the routing between OSPF areas quite easily using LSA filtering.
OSFP, DHCP, and VLANs are three features that are completely independent of one another. They are related only in the fact that they coexist within a network. I believe that the best way you can see how these features can all be applied at the same time on a network is to first go through each one and understand it. You can then create a topology of your own (using GNS3, packet tracer, CML, or even real equipment) that will incorporate all three. In general, however, these features don’t affect each other directly. More info can be found here:
A simple topology that you can get started with is to have a single router connected to a Layer 3 switch using an access port, and create three or four VLANs on that switch. Have the router act as a DHCP server, and run OSPF between the switch and the router so that the devices can learn each others networks. Connect hosts to the switch on several VLANs and have them obtain their IP addressing information via the DHCP server. The best way to learn these concepts is by actually implementing them in a topology and testing them out.