Florida-based real estate investor named David Oberlander was surprised to learn three years ago that one of his rental properties was falling just short of a five-star rating on Airbnb.

As he related on the website biggerpockets.com, one of his tenants called to tell him of the comings and goings at an adjacent property — how it seemed the residents were never home, but many others were taking turns staying there.

Sure enough, Oberlander went to Airbnb’s site and found 31 reviews for his property, all of which reflected that the visitors were duly impressed by the place.

Suffice it to say that he didn’t view things in quite the same light. Secure in his knowledge that his tenants were in violation not only of their lease but various city ordinances and building codes, he wrote of his intention to evict them.

Oberlander’s property was a duplex, not a multifamily dwelling, but it nonetheless serves as a case study for how best to make any rental property share-proof: Require that your tenants abide by the terms of their lease. Plain and simple, that’s the solution. Just enforce what you have in writing. And if the renters don’t do so, farewell to them.

Beyond that, there are different places that have gone to great lengths to keep the sharing economy in check. New York state, for example, passed a law in 2016 making it illegal to advertise or rent an apartment via a site like Airbnb for fewer than 30 days, unless the host remains on site and there are no more than two guests.

The law, passed at the behest of the hotel lobby and affordable housing advocates, came on the books to prevent landlords from running de facto hotels. It led to incidents like one involving a tenant named Nan Doyle, who in 2017 rented her Brooklyn apartment to a California family. When they were somehow found out, Doyle was presented with several summonses, two of which were for listing the property on Airbnb and the site VRBO (Vacation Rental By Owner). Each summons carried with it a fine of $1,000.

In places where the laws are more lax, Airbnb can actually be a boon to investors. One report suggested, in fact, that the owner of a property featuring, say, 12 units, would be wise to set two of them aside for short-term rentals, as the return is much higher than it is for a monthly or yearly lease.

The downside is that a landlord would be forced to spend more time on administrative tasks, like marketing those properties or responding to inquiries. But that time investment can result in big dividends.

When a tenant elects to list his apartment on Airbnb, however, it can result in sizable headaches for a landlord — especially if the tenant tries to be secretive about it.

One piece laid out the thinking of a typical landlord — how under normal circumstances they view their properties, rented for a year or two at a time, as long-term, low-risk propositions. When a renter then goes the Airbnb route, it makes it a short-term, high-risk deal for the landlord.

The biggest risk of all involves insurance, and the fact that all claims will be denied if the policyholder discovers that a place was rented like a business — a business like Airbnb, for instance. There is also the chance that a landlord’s policy could be declared null and void in such a case.

The bottom line, again, is this: A lease needs to have teeth. It is the best way for the owner of a multifamily property to protect oneself.