How to setup DOF to blur near and far objects

Hello. My question is in the title. I want to achieve an effect where near enough and far enough objects are blurred, but everything else is sharp. From example on the picture, I want to blur two objects close to camera, leave the area with player sharp, and blur the cityscape. What settings should I tweak to achieve that? For now I can only either blur everything or blur only distant objects, which I can’t blur hard enough not to touch middle plane. So what should I do?

Hi, I know this is a really old topic- but could you explain how to do this for the background and foreground? I made my own topic for more details but I’m still a bit of beginner so I would appreciate any help! :sob: