How to stop my 9 year of dog from marking?

I got my dog about 6 years ago when he was 3 and he was not spayed. we got him spayed right away, and we were good. A couple of months later I think he started marking in the house which we thought was annoying but fine, we just dealt with it. I want to try to train him out of it now because I'm moving into a townhome next year with some friends and i want to bring him with me but I can't if he's going to be marking in the house. I know there are some articles on it but a lot of them focus on puppies and don't really mention how to deter him when living in a new space. Any information would be helpful