Time Constraint to internet

Good day,

My one ISP offers free internet between 12am and 6am.

So i want to find out how i can setup the mikrotik to only allow traffic through that internet connection between that time?

I dono if i have to wright a script that adds that route at 12 every night and then disables it in the morning? How would i go about doing it?

/ip firewall filter
add chain=forward action=accept time=0s-6h,sun,mon,tue,wed,thu,fri out-interface=internet
add chain=forward action=drop out-interface=internet

You probably want to enable NTP client on your router so your local time is accurate.

So will that just kill all internet between 6 in the morning and 12 at night?

Correct. It will allow Internet from midnight to 6am, then disallow any further access outside of that timeframe.

How would i make it so that i can use another internet connection in the day.

I have 2>

So i want it to use internet a in the day and then internetb at night?

You would either do it with a script that would change the weight of your routes based on what time of day it is, or set up a set of mangle rules that would mark connections differently depending on what time of day it is.

The second method wouldn’t necessarily be very “clean” at cut-over since the router will remember connections that have been established in the past and continue to try and send them out of the blocked interface. You could make it better by clearing out the connection table with a script at the specific times, but there may still be some lingering problems around those time frames.

/ip firewall mangle
add chain=prerouting action=mark-connection new-connection-mark=morning time=0s-6h,sun,mon,tue,wed,thu,fri,sat connection-state=new
add chain=prerouting action=mark-connection new-connection-mark=evening time=6h0m1s-23h59m59s,sun,mon,tue,wed,thu,fri,sat connection-state=new
add chain=prerouting action=mark-routing connection-mark=morning new-routing-mark=morning
add chain=prerouting action=mark-routing connection-mark=evening new-routing-mark=evening

And then just have the appropriate routes in their routing tables.