Dynamic DHCP & Recursive

I just added dyndns.org script to the router and it works, so since I am on fire now tackling the subject topic. :wink:

My current Ip route schema is as follows (using two internet dns resolving IPs to check that ISP Primary is actually up).
/ip route
(L1) add check-gateway=ping distance=3 gateway=1.0.0.1 (cloudfare)
(L2) add check-gateway=ping distance=4 gateway=208.67.220.220 (opendns)
(L3) add distance=3 dst-address=1.0.0.1/32 gateway=ISP_Primary scope=10
(L4) add distance=4 dst-address=208.67.220.220/32 gateway=ISP_Primary scope=10
(L5) add distance=10 gateway=ISP_Secondary

Two questions:

  1. Is the ā€œadd distanceā€ in L3,L4 redundant since they are used in L1,L2 ??
  2. Should I use actual IP addresses of sites vice the DNS resolver IP addresses, and if so which ones?

Now onto the dynamic part…
This will be done in two parts,
A. Put in the following script into the DHCP Client for the ISP-PRIMARY.
:if ($bound=1) do={ /ip route set [find comment=" isp1route "] gateway=($ā€œgateway-addressā€)disabled=no; :log warning ("New ISP1 gateway: ".($ā€œgateway-addressā€)) }

The other item to put in is a Default Route Distance of 255. This apparently will pull the route information from the provider but not become an active route.
It should pull the all important new ISP gateway information to add to the route rules.

B. The second part is to transform my current IP Routes to something that will work with the script.

Based upon the advice/example found:
/ip route
add dst-address=8.8.4.4 gateway=127.0.0.1 scope=30 target-scope=30 comment=" isp1route " disabled=yes
add dst-address=0.0.0.0/0 gateway=8.8.4.4 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=ISP_Secondary distance=2

I have modifed my current IP Routes as follows… and am asking did I screw it up or am I Close ???
(L10) add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 (cloudfare)
(L20) add check-gateway=ping distance=4 dst address=0.0.0.0/0 gateway=208.67.220.220 (opendns)
(L30) add distance=3 dst-address=1.0.0.1/32 gateway=127.0.0.1 scope=10 disabled=yes
(L40) add distance=4 dst-address=208.67.220.220/32 gateway=127.0.0.1 scope=10 disabled=yes
(L50) add distance=10 gateway=ISP_Secondary

or is this not possible when checking two different internet addresses and thus should simply stick to one external…
(L10) add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 (cloudfare)
(L30) add distance=3 dst-address=1.0.0.1/32 gateway=127.0.0.1 scope=10 disabled=yes
(L50) add distance=10 gateway=ISP_Secondary

I was going to post something similar so I will just be patient and wait for the feedback to pile in. :wink:

…

is the question to basic for the general forum?

When I first saw your original post, my mind entered the mid-management mode … and that is; read first 3 lines of text. If the point of whole text is clear, then do something (e.g. read the rest of it :wink:), else ignore it.

It did the same to me second, third and fourth time. This time I managed to get through … the last post of yours :wink: I don’t dare to try again with the first post though.

Yeah, it’s not that we wouldn’t like you, but some of your questions tend to be quite complex and it takes a long time to understand all details. And I’ll admit that recursive routes are not my thing, I understand the idea, I will get it working in the end, but I usually have to ā€œcheatā€ with manual.

Ok, when I look again, I don’t see that you really changed much. Maybe you should highlight changed parts next time, but I see only gateway changed from interface to IP address. So if you add comment=ā€œisp1routeā€ to those routes, so that script can find it, it will probably do what you want, assuming that original config did.

Thanks I am willing to take any reply at this point LOL.
The difference is that I am going to change from my current recursive setup to one that makes some changes to the DHCP client settings, and IP route settings and then will rely on a script to ensure that the IP route rules work.

Besides that I was asking is putting the distance parts in twice is actually needed or just once.

If there’s more than one route with same dst-address, distance is what tells the router which one should have priority. In your case, only L1 and L2 have same dst-address, so it doesn’t do anything useful for L3 and L4. I’d just keep default 1, but in this case it shouldn’t matter. I’m not sure about routing protocols like BGP and others, if it would do anything to them, but luckily that’s not what you use.

And I remembered another thing about your questions, sometimes you’re too curious. Let’s put it this way, I know that sun rises in the east, but you’d be able to ask about it in such way that I’d have to stop and think if it really does. :smiley:

Curiosity kiled the cat, not anav … he’s killing us :laughing:

hahaha, dying of laughter I presume.
okay, I get the hint experiment and then see what happens
when the daggers come out from family members due to phucking up the network I will let you know how it goes… maybe

I’m not saying that your questions are bad, in fact I’m sure I learned something new while thinking about some of them and trying to write flawless answer (to finally satisfy you, but it’s not easy). But sometimes it feels like work… and I’m coming here to procrastinate. :slight_smile:

Thanks for the humour it helps make my day much more tolerable. Although I think you might have the ā€œINATEā€ prefix wrong. Perhaps ā€œurā€ vice ā€œprocrastā€ :wink:
I come here when I feel overly adequate and need humbling.

Slow down there, remember that I’m not native speaker, no advanced word play for me. I need it simple to keep up. Sob see router. Sob configure router. Router now safe. Hacker sad. Too bad. Well, not necessarily as simple as this. :slight_smile:

Bonjourno Sob, if you want a simpler view I have moved the intent of the thread to a simpler better focussed query here…
http://forum.mikrotik.com/t/simple-dynamic-dhcp-client-script-fails/134196/1

Solved by Sob on the thread linked in this post. Honest I didnt get paid to say that!