The way I’ve dealt with this in the past is to either use a a “lock” bone, i.e. one that a bone in your joint has a locked track to (discussion found here) or to use another short IK chain (two bones) and a copy rotation. This second method I got from some tutorial somewhere on animating a mechanized spider.
I only have time for a short description now, if that doesn’t work, I could make an example available. Starting with your normal IK leg, add an additional bone that runs from the beginning of your “thigh” bone to the heal (I call it LegRot.L/R), add a IK child to this bone (I call it LegRotNull.L/R). Add a Copy Location constraint to LegRot.L/R to the corresponding Thigh.L/R. To LegRotNull.L/R, add an IK solver to one of your heal bones.
If you’ve done this right so far, moving the leg up and down will keep the center of the LegRot.L/R bone on your heal, although since LegRot.L/R doesn’t shrink or stretch it’ll look like your heal is riding on a “rail” more or less. I hope that makes sense, :).
Now, on your Thigh.L/R bone, add a copy rotation from the LegRot.L/R bone you just added. If you have your roll angles set up right, that should do it. You might have some issues with your model though, depending on its rest position (hard to tell from the picture). In my humanoid models, this works well, but then my legs are reasonably close to straight. If your mech model armature’s legs are bent in the rest position, there may be some issues.
The nice thing about this setup if you can get it to work is that you can rotate the leg by rotating the LegRot.L/R bone, giving it a good range of motion when you want, but no rotation unless you key it into the animation.