Contrary to what I am reading in this thread I believe international law does recognize the (limited) right of naval vessels to stop and board and inspect merchant vessels of any registry.
The way I understand it is:
A merchant or civilian vessel in national waters is subject to the dual jurisdiction of its country of registry and the nation it is in. Normally the host nation will not get involved in matters aboard unless they have serious repercussions ashore. The local consul of the country of ship’s registry is the local authority aboard.
A merchant ship in international waters is subject to the jurisdiction and protection of the country of registry. Notwithstanding this, naval vessels of other nations have certain rights of boarding, inpection etc. I believe the Coast Guard are naval vessels for this purpose (in fact that is their mission: inspection etc, rather than fighting which is navy stuff) and it is naval vessels who are deputized as CG for this type of operation.
A vessel with no flag of registry has no protection and can be detained and taken to port by any nation.
If you are registered in one country and sail the high seas with the purpose of carrying out activities which are illegal in another country, I doubt the first country would offer you much protection except consular notice, request for due process etc.
If you have a ship of contraband in international waters with the intention of unloading it in some country (they do this all the time, staying offshore and shuttling the contraband in speeboats)your ship can be seized (I am not sure of the legal justification, just that it is done).
Naval vessels are solely under the jurisdiction of their country where ever they may be and cannot be boarded or inspected (we are talking when there is no war going on) and when visiting foreign ports are generally exempt of certain obligations (like hiring pilots) to which merchant vessels are subject.
I first learned some of this some years ago when I was studying for a captain’s license in Spain and I learnt the title allowed the owner to skipper a boat up to a cer tain size and up to so many miles off the coast. my reasoning is that since national jurisdiction ended sooner, by the time I got to that many miles, I was free to go as far as I wanted. It turned out I was wrong because, if the boat is registered in Spain it is under Spanish jurisdiction where ever it may be.
The obvious answer is to register the boat in another jurisdiction with less bureaucracy.
All these laws were made in times when there was no significant amount of small private boats so they were made with merchant ships in mind.
Now, small boat owners are registering their boats in other countries with the purpose of avoiding taxes, avoiding jurisdiction etc. European countries have been trying to deal with this for some years now but they do not seem to get anywhere.