Greasing the metal legs will work; however, you may also inadvertently catch a few bees too. Once I had a beehive rack with pipe legs driven into the ground and 1 inch square structural tubing welded to the pipe uprights. I started noticing carpenter ants in the inner covers along with their eggs. They were bringing the eggs there to take advantage of the hive heat. I tied greased rags around the pipe legs thinking that would stop them. Nothing changed...still ants/eggs on the inner covers.
Closer inspection revealed that the ants were coming up the inside of the pipe. When the pipes were driven into the ground, an ant-hollowed tree root or underground ant tunnel was punctured giving them direct access into the pipe. From there it was a straight shot to the beehives. So if your pipe legs offer such an opportunity, pour oil down the pipe or bug killer. That will take care of it. Once I poured oil down the inside of the pipes, the greased rags worked fine.
Diatomaceous earth will also work around the legs but it will tend to wash away during rains. You can also use it inside the pipe.
Ants have memories and they will learn to not go places for a while but the next generation will reexplore and perhaps find the same avenues so some on-going vigilance is needed.