I want to set up a routerboard so that it can make use of different outgoing connections at different times of day.
So, for example, I’d like 0.0.0.0/0 to be routed via 192.168.1.1 between 8:00pm and 8:00am and then I’d like 0.0.0.0/0 routed via 192.168.1.2 between 8:00am and 8:00pm.
Very easy. Have to set up schedule to run a scrip at the times you want. Set up both routes and in comment call one for example day and the other night, then create two scripts lets say day and night. Day script will switch on the day router during the day and disable the night route and the night script will enable the night rout at night and disable the day route. Create a schedule that will run the appropriate script at the times you want. Thats it.
Or set up routing marks in firewall/mangle and time-profile them such that packets get whichever routing mark is applicable for the time the packet passes through. It’s a little more complex to set up, but it’s significantly easier to be more flexible (e.g. if you want different things at weekends).
I would like to do this exact thing. Is there any way to prevent connections from being reset when routes switch back to “day” mode for example?
Seems like mangle rules with connection state=established should keep their existing route until connection is closed? Something like that doable? I’m going to play around with it when I get time.
As long as you use connection marks in the time based rules and mark a connection when it’s new or don’t remark connections that already have marks, and then mark routing based on connection marks that will “just work”. Connections marks - unless reset - stay for the lifetime of the connection, so it wouldn’t change just because new connections get a different mark.