As long as the government can change the law without the people's consent — it's impossible
Gerrymandering exists in any form and in any government because the government can adjust district boundaries without the consent of the people. Not that the consent of the people would significantly help or is even the issue. My point is, as long as the incumbents have the authority to change those districts, the people are proverbially hosed.
1. Redistricting will always be necessary, so it must be permitted
Today you may have a thriving residential neighborhood housing 1,000 voters. Tomorrow that same geographic location may have a shopping mall, a junk yard, and low-value commercial property housing 100 voting stalwarts who think nothing should ever change. On the flip side, today you may have 500 acres of farm land housing 2 voters and a lot of cows, but tomorrow there's a thriving master-planned community with 1,000 voters. There will always be reasons to redistrict, so the process of redistricting must exist.
2. How you redistrict isn't as important as controlling the process of redistricting
Once we admit we need redistricting, the next problem is ensuring that, once we develop a fair and equitable solution (if such a thing exists, both tend to be in the eye of the beholder), we need to make sure it's whomping hard for Representative Lastforever to simply change those boundaries to ensure his continuing reign of terror public service.
Using The United States as an example, we could create a Constitutional Amendment that identifies exactly how redistricting occurs and that's the law. Period. End of Story. Representative Lastforever loses the race if the demographics after constitutional redistricting don't favor him. However...
Part of the problem with the U.S. Constitution (and it's there for a very good reason) is that all powers of authority not explicitly identified as belonging to the Federal government automatically belong to the States. And that's one reason why gerrymandering exists in the U.S. Because redistricting is controlled at the state level and it's a lot easier to control 50 state constitutions than it is 1 federal constitution.
An astute observer might say, "yeah, but you could achieve the same effect by enshrining the process of redistricting in state constitutions." That's 100% true, kinda. I believe most state constitutions in the U.S. are changed by majority vote of the population (otherwise known as "popular vote") which means the old big-city vs rural-town problem exists. The Federal constitution requires 67% of Congress to propose a new Amendment and 75% of state legislatures to ratify it. In practice, that's honking hard to do. It has only happened 27 times in 244 years (and 10 of them happened right on top of ratifying the Constitution in the first place).
So, we remove from local government (and especially from incumbent legislators) the ability to change how redistricting occurs.
3. All that leaves is coming up with a "fair and equitable" solution
The problem with what I just proposed is that it's basically considered better to tolerate gerrymandering than to encode in so rigid a manner a solution that (perish the thought) needs to change. The problem with law, politics, philosophy, and people, is that they all change. The U.S. today is fundamentally a two-party governing system. We've tried to bring more parties into it — but it's basically a two-party system. If, by an act of pure magic, more parties suddenly come into being, that would change how redistricting should, would, or could occur — except that we just entombed it in a legal device that's specifically designed to be whomping hard to change.
That same astute observer might point out that the problem here is that people's political leanings change — and the point of gerrymandering is to take advantage of that fact. So long as you're trying to provide a "fair and equitable" solution on the basis of the changing opinions of the population, you'll always lose. To quote Whopper: "An interesting game... it appears the only way to win is to not play at all." In other words — the only way to be completely immune to gerrymandering to to never district anything.
Conclusion: it remains impossible
Can you come up with a system that's "fair and equitable?" Ignoring the simple truth that "fair and equitable" is always interpreted in the eye of the beholder, the answer is "sure, for today." Once you come up with one, there are ways to make it basically impossible to gerrymander.
But the price you pay for that convenience today might incur a high price in the future.
Which is why the fight to discontinue the use of the Electoral College has been so long, and will continue indefinitely. It's very hard to predict the future, and sometimes the devil you know is better than the devil you don't.