This has nothing to do with the New Jerusalem and does not even hint at it,which the the New Jerusalem is a place where sin has never been and sin will never be,and the good angels and the saints will never even know about rebellion against God again,and the old heavens and old earth will be pass away because the are tainted with sin,and there will be a new heaven and new earth where sin will never be.
The battle in those scriptures happens at the end of the millennial reign of Christ,so that battle happens during the millennial reign of Christ,which describes them as Gog and Magog,the same as the battle of armageddon prior to the millennial reign of Christ,that they are Gog and Magog.
The truth is that people can repent of their sins until they take the mark of the beast.When they take the mark of the beast they cannot repent of their sins and God will take His children home.
That means all the Gentiles that are left on earth after the resurrection of the saints have taken the mark of the beast and cannot be saved.
The world,the Gentile nations,will attack Israel,known as the battle of armageddon,which the Gentiles are known as Gog and Magog,and Jesus will fight the world and defeat the world and save Israel.
God will spare one sixth of the world that fought against Israel and those are the people who Jesus and the saints will rule over in the millennial reign.
These people who Jesus and the saints rule over are in the flesh and have taken the mark of the beast so they can never have salvation,but God spared them so Jesus and the saints can rule over them.
Since these people can never have salvation for they took the mark,God will eventually have to judge them,and they cannot be with God,but God has allowed them mercy during the millennial reign of Christ.
These people are in the flesh and took the mark,but things are peaceful for Satan is bound and put in the bottomless pit,so they are not stirred up to fight against Jesus and the saints,which they would be stirred up if Satan was not bound for they are in the flesh and took the mark.
Satan will be loosed from the bottomless pit to stir them up to go against Jesus and the saints,which they are easily stirred up for they are in the flesh and took the mark,which is the purpose of God to allow Satan to stir them up,for it is God's time to judge them and take His mercy from them that they received during the millennial reign,because they still have to be judged for taking the mark and fighting against Israel,which when they attack Jesus and the saints,God devours them with fire.
The millennial reign will end after they attack Jesus and the saints and are punished,and Satan will then be judged.They are known as Gog and Magog before the millennial reign of Christ,at the battle of armageddon,and known as Gog and Magog during the battle at the end of the millennial reign,for they are the same people stirred up by Satan to fight both battles.
Those scriptures are not referring to the New Jerusalem but to the battle at the end of the millennial reign of Christ.There are no sinners in the New Jerusalem and the millennial reign of Christ is not the New Jerusalem.