Almost every place you sail on the planet, the official answer is that you must first check in with the authorities before you drop your
anchor in locations further afield. That's what we always did unless
weather forced us to do otherwise, and we could make a good case for
emergency stopping prior to checking in. Enforcement in many
remote areas is spotty at best, but if you get caught, the penalties can be severe and expensive. Try doing that in
Australia, and you'll be really sorry. They have spotter planes flying along the coast, and there is a good chance that you'll be photographed when still
offshore. They'll know about your misdeed and they will display a non-forgiving attitude. Expect no mercy for breaking the rules there. Try the same thing in Eritrea, and probably nothing will happen.