Just setup domains and the times or limits you want to restrict them.
My router can do this, but not for sites using SSL (that is, just about every respectable site out there, these days). Do you filter IPs and not by domain?
Yeah it's a pain to do it right. I'm just doing it with a local DNS server for the moment.
I've considered setting up a local Raspberry Pi for both PiHole to block ads, and running Squid or whatever on it to provide better SSL filtering. If there a nice writeup for how to do this I would also be interested.
When I am working on a single computer away from home I sometimes just manually edit my hosts file. Crude but it still catches me a bunch of times over the day where I almost unconsciously pop up a distracting site.
It results in an ugly SSL error (bad certificate) when the filter is active, but it fits the job.
Or do what I do, and just edit the hosts file manually. That means I often go for days without changing it, because it forces me to make a decision, rather than act on impulse.
Not specifically about phones, but I have my router only allow access to sites like that for certain hours in the day. I can always log into the router to turn it off, but adding that extra bit of friction is usually enough to get me to check it later during the designated times.