We have 3 of these: https://www.amazon.com/gp/product/B000H91R8S/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
The pictures show it arranged as a pen, but we mostly use them as one long zig zagged barrier.
One is permanently attached to the dog's crate to give her a bigger space. The others ( 1 upstairs and 1 downstairs) we use to block different areas at different times. I love that we can block or allow access to different areas at different times, depending on what's going on. The dog could easily jump over it, or knock it over, but it makes such a racket that the noise scares her. We can also set it up with a small gap that the cats can go through and the dog doesn't fit.