What was crossing a border like in premodern times? Were there passports and immigration laws, or could one simply wander into the next empire/kingdom/feudal lordship/etc?

by sparky222b
Dinocrocodile

Although there's a lot more to be said about pre-modern travel /u/Astrogator answered How would an average Roman citizen travel through the Empire from one location to another?. I'd still very much like to know what else there is about Medieval/ancient roadtripping though.