Static Router with OSPF Network

Hello, I have an OSPF network operating with private addressing classes. I have set the private address of the loopback interface for each router in the OSPF instance as usual. (Example: 172.16.0.1/32). Everything works perfectly. At this point I wanted to route a public subnet between two routers but when I create a static route (Dst.Address Gateway 172.16.0.2) as the next hop I enter the IP of the router. The problem is that the route is “unrechable” even if I actually manage to reach that IP (I did a ping and it is reachable). I don’t understand where the problem lies. Any suggestions can help thanks

I am guess that you’d probably have to set the target scope to 20.

Thanks, if you change the “target scope” parameter from 10 to 20 the routes are active and with the words “recursive”.
I have one last question, I was using those routes to route a public subnet from router where I have a BGP session with my ISP to a router on my network.
In the first router I added a static route
Dst.address =
gateway = .
In the internal router of my network, where I wanted to make the public subnet usable, I loaded an IP of that subnet on the loopback interface and
added a generic static route
Dst.address = 0.0.0.0 / 0
gateway = <loopback-ip-first -router>.

I was wondering if conceptually I have performed a suitable configuration or the routing procedures of public subnets in an OSPF network are carried out differently. Thank you in advance

Not sure if I follow your setup.
But since you already have ospf, is there a reason why you don’t want to let ospf does its job? IE have the bgp router advertise default route (0.0.0.0/0) and each of the internal advertise its ?
This way you don’t have to keep adding static route everywhere when you start adding more internal routers.

One reason is actually this because I wrote on the forum, I was not sure about the configuration so briefly I explain my problem maybe you have some suggestions.
I have a router with a BGP instance that connects my OSPF network to that of my ISP. On this router I announced a public / 24.
My routers internal network is fully OSPF. I split my / 24 subnet into / 29 so that I want to use each subnet on a different router.
Basically I can’t make it possible to use these last subnets on the final routers.
For this reason I have thought of static routes, but if there is a more suitable way, it is welcome.

Thanks to all for the help

Could you show your network diagram?

Here is my simplified network setup. If you need more info, no problem I will send you everything.
Thank you very much for your interest.
Rete.png

Ok, Thanks :slight_smile:

Looking at your network diagram, I couldn’t tell what is your public subnet, and which router you are referring to in this case, I am assuming that:

  1. your public subnet is 172.16.0.0/24 (I know this is not public range, but it shouldn’t matter)
  2. we are working on router_3, since that is the only router I see with /29.

Having said that, the easiest I think is to just redistribute default route at your AS_Router.

/routing ospf instance set distribute-default=always-as-type-1

If for some reason that is not possible, you can add 0.0.0.0/0 gateway 172.16.0.1 with target scope of 20 in all 3 of your routers (except as_router).

What’s the output of

ip route print

and

routing ospf lsa print detail

on the AS_Router ?

The public subnet is not in the scheme because it has only entered the private network classes.
The subnet I publish from the AS_router through the bgp session is 185.yyy.zzz.0 / 24.
Basically I would like to divide the subnet into subnets / 29 and assign one for each router present in my network, with the exception of the AS_router.
I have tried with static routes but for now to no avail.
I read that it would also be possible to route the OSPF directly by adding the public network class / 20 on each individual router and as you suggested to route the default route from the AS_router to all the others in order to have a 0.0.0.0/0 route on all routers in the network.

instance=default area=backbone type=router id=172.16.0.1 originator=172.16.0.1 sequence-number=0x80000DBA age=440 checksum=0x6D38 options=“E” body=
flags=EXTERNAL
links (type, id, data, metric)
Transit 172.16.2.6 172.16.2.5 10
Transit 172.16.2.10 172.16.2.9 10
Transit 172.16.2.14 172.16.2.13 10
Stub 172.16.2.16 255.255.255.252 10
Transit 172.16.1.1 172.16.1.1 50
Stub 172.16.0.1 255.255.255.255 10

instance=default area=backbone type=router id=172.16.0.3 originator=172.16.0.3 sequence-number=0x80000DB1 age=1295 checksum=0xD14C options=“E” body=
flags=
links (type, id, data, metric)
Stub 10.0.3.254 255.255.255.255 10
Stub 172.16.2.36 255.255.255.252 10
Stub 10.0.1.0 255.255.255.255 10
Stub 10.0.3.253 255.255.255.255 10
Transit 172.16.2.6 172.16.2.6 10
Stub 10.0.0.0 255.255.252.0 10
Stub 172.16.0.3 255.255.255.255 10

instance=default area=backbone type=router id=172.16.0.4 originator=172.16.0.4 sequence-number=0x80001151 age=591 checksum=0xD6D options=“E” body=
flags=
links (type, id, data, metric)
Stub 10.0.7.199 255.255.255.255 10
Stub 10.0.7.157 255.255.255.255 10
Stub 10.0.7.250 255.255.255.255 10
Stub 10.0.7.206 255.255.255.255 10
Stub 10.0.7.155 255.255.255.255 10
Stub 10.0.7.186 255.255.255.255 10
Stub 10.0.7.244 255.255.255.255 10
Stub 10.0.7.219 255.255.255.255 10
Stub 10.0.7.171 255.255.255.255 10
Stub 10.0.7.185 255.255.255.255 10
Stub 10.0.7.173 255.255.255.255 10
Stub 10.0.7.168 255.255.255.255 10
Stub 10.0.7.247 255.255.255.255 10
Stub 10.0.7.243 255.255.255.255 10
Transit 172.16.1.28 172.16.1.25 50
Transit 172.16.1.1 172.16.1.4 50
Stub 172.16.2.20 255.255.255.252 10
Transit 172.16.2.14 172.16.2.14 10
Stub 10.0.4.0 255.255.252.0 10
Stub 172.16.0.4 255.255.255.255 10
instance=default area=backbone type=router id=172.16.0.5 originator=172.16.0.5 sequence-number=0x80000CD5 age=1389 checksum=0xD2FC options=“E” body=
flags=
links (type, id, data, metric)
Stub 10.0.15.253 255.255.255.255 10
Transit 172.16.1.28 172.16.1.28 50
Stub 10.0.12.0 255.255.252.0 10
Stub 172.16.0.5 255.255.255.255 10

instance=default area=backbone type=router id=172.16.0.7 originator=172.16.0.7 sequence-number=0x800008A2 age=258 checksum=0x5851 options=“E” body=
flags=
links (type, id, data, metric)
Transit 172.16.2.10 172.16.2.10 10
Stub 172.16.0.7 255.255.255.255 10

instance=default area=backbone type=network id=172.16.1.1 originator=172.16.0.1 sequence-number=0x80000931 age=894 checksum=0x50DC options=“E” body=
netmask=255.255.255.248
routerId=172.16.0.1
routerId=172.16.0.4
instance=default area=backbone type=network id=172.16.1.28 originator=172.16.0.5 sequence-number=0x800007E3 age=1737 checksum=0xF167 options=“E” body=
netmask=255.255.255.248
routerId=172.16.0.5
routerId=172.16.0.4
instance=default area=backbone type=network id=172.16.2.6 originator=172.16.0.3 sequence-number=0x80000C53 age=664 checksum=0xBB41 options=“E” body=
netmask=255.255.255.252
routerId=172.16.0.3
routerId=172.16.0.1
instance=default area=backbone type=network id=172.16.2.10 originator=172.16.0.7 sequence-number=0x800008A0 age=258 checksum=0x1592 options=“E” body=
netmask=255.255.255.252
routerId=172.16.0.7
routerId=172.16.0.1
instance=default area=backbone type=network id=172.16.2.14 originator=172.16.0.4 sequence-number=0x8000098B age=1439 checksum=0x8B5 options=“E” body=
netmask=255.255.255.252
routerId=172.16.0.4
routerId=172.16.0.1
instance=default area=external type=as-external id=0.0.0.0 originator=172.16.0.1 sequence-number=0x80000026 age=455 checksum=0x86E8 options=“E” body=
netmask=0.0.0.0
forwarding-address=0.0.0.0
route-tag=0x0
metric=1
type1

This is the content, consider that the diagram I shared is quite simplified, so some more OSPF routes appear in the routing tables.

Okay, for the discussion, let’s assume the public subnet is 185.123.123.0/24.
For simplicity, assuming also on Router_3 you would like to assign ip 185.123.123.25/29. In my case I am adding it to a bridge, but in reality you can also add it to an interface.

On Router_3 I would:

/interface bridge
add name=bridge1
add name=lo

/ip address
add address=172.16.0.5 interface=lo network=172.16.0.5
add address=172.16.1.26/29 interface=ether3 network=172.16.1.24
add address=185.123.123.25/29 interface=bridge1 network=185.123.123.24

/routing ospf network
add area=backbone network=172.16.0.5/32
add area=backbone network=172.16.1.24/29
add area=backbone network=185.123.123.24/29

On AS_Router:

/routing ospf instance
set [ find default=yes ] distribute-default=always-as-type-1 router-id=172.16.0.1

This should be working, or am I missing something?

So let’s focus on the LSA for 172.16.0.5 (R3) which is at the end of your drawing. It shows the following routes advertised:

10.0.15.253/32
10.0.12.0/22
172.16.0.5/32

Assuming 10.0.12.0/22 works, I have two questions:

  1. What does the LSA look like when you try to advertise a public /29 on this router (I would recommend to substitute the doc prefix of 203.0.113.0/24 into the output instead of the actual public range)

  2. What kind of interface is 10.0.12.x/22 assigned to (eth, vlan, bridge, etc) and is the public subnet configured on a similar type of interface?

I also performed this test allowing the spread of the 0.0.0.0/0 route.
Basically all the suggestions you have given me are consistent with my current configuration but there must be a step, even a trivial one, that I have made incorrectly and for this I have problems.
I ask you a last courtesy, I have decided to reconfigure the network again because it has become confusing; when i ask you if you know of examples of ospf mikrotik configuration with routing of public subnets in order to draw example.
Basically summing up my need is to create a ospf network by routing a public / 29 for each router.
Thank you

Does it work now or not yet?
In case it is still not working, can you do

/ip route print

on both internal and as_router?