I think this is the most difficult question of them all. My own, pie-in-the-sky proposals are this:
1) We establish a four state solution, as follows:
A: State of Israel within the borders of 1967, with some adjustments in the West Bank where there are undeniably Israeli towns on the edge of the pre-1967 State of Israel.
B: West Bank Palestine, internationally recognised and largely within the pre-1967 West Bank borders, minus a handful of exceptions. All settlements deep within the West Bank would be abandoned. Israel would cede control of the West Bank borders, particularly with Jordan.
C: Gaza City State, which would be under Arab control and designed to create a new Singapore in the region. Israel would fully disengage, including economically, with the US Dollar or similar strong currency used. The Arab countries would have responsibility for security and defence, with the goal of normalising relations between Gaza and Israel. The aim would be for independence to be granted within 10 years, but with the strict rule that any sort of political unification between Gaza and the West Bank Palestine state would be explicitly prohibited.
D: Neutral Jerusalem, which would be under UN control and function as a single city. Public services would be provided by separate Jewish and Arab municipalities operating within the city, with the UN acting as a neutral referee and overlord in case of dispute. The city would be legally separate from both Israel and West Bank Palestine, and the UN would be permitted to use force to ensure neutrality. The city itself would have its own legal system, including migration, and would function as a de facto independent city state. There would be no possibility of the city gaining independence, unless a majority of both Jewish and Arab residents consented.
2) A separation barrier is built with international cooperation to put an end to attacks. This should be as secure as possible to ensure both Israeli and Palestinian safety. The UN would provide a strong peacekeeping presence, with a buffer zone built between the two and monitored by UN authorities.
3) Gaza would have a functioning seaport and airport, while the Arab countries would take responsibility for building a new transit road to Gaza via Egypt and Jordan. The same would be with the West Bank.
The question is: what happens if Israel is then attacked despite all this? I don't know the answer.