The second-floor apartment was a beautiful and spacious, smartly appointed two bedroom in San Francisco's posh Pacific Heights neighborhood. It was pricey, about $400 a night on Airbnb, and came with an unexpected caveat.

Along with a complimentary bottle of California wine, renters were greeted with a handwritten note warning them to lie if they ran into any neighbors. If anyone asked questions, they were instructed to say they were just friends of the family.

Short-term rental hosts are getting crafty when it comes to working around rules. But now they're not just going up against nosy neighbors. There's a new wave of startups that investigate and catch hosts who are violating building regulations and local laws. They're hired by landlords concerned about quality of life or insurance issues, and cities worried about diminishing housing stock or people not paying proper taxes.

Landlords, apartment managers, and condo associations hire Austin-based startup BNB Shield to catch tenants illegally renting out their apartments. Launched in February, BNB Shield employees aren't staking out buildings, looking for strangers with roller luggage. It uses custom software to comb through listings in a given area and match information with known features in a specific building.

Related: Why everyone is cracking down on Airbnb

Some buildings have the same floors, windows, crown molding, or refrigerators in all units. BNB Shield can put that into its database and scan photos to ID tenants.

Jacques Casimir, the 36-year-old cofounder of BNB Shield, says many hosts are getting smarter about not posting identifying details on listings, such a photo of the outside of a building.

Most hosts are regular people trying to make cash while they're away. But Casimir has also seen a single person take out multiple leases on 13 apartments and rent them out 24/7, creating an underground hotel business.

Illegal hotels aside, why would landlords pay money just to crack down on a tenant's side hustle? David Shapiro of SubletAlert.com says it's a combination of issues. His San Francisco company makes tools that real estate and building management companies can use to find short-term rentals.

Having strangers come and go can be a safety and quality of life issue for other tenants. Buildings often have specific insurance policies that don't cover short-term sublets. And Shapiro says a steady stream of vacationers has greater wear and tear on buildings.

Like BNB Shield, SubletAlert doesn't handle evictions or enforcement. The companies turn the information over to clients who decide how to proceed, typically starting with a warning.

(Landlords aren't always the victims. In one Los Angeles criminal case, owners of a building are accused of illegally evicting all tenants and turning the units into more lucrative Airbnb rentals.)

Increasingly, Airbnb-like sites are catching the attention of local governments. Different cities and towns are enacting their own patchwork laws to address the proliferation of short-term rentals.

Every city has different reasons. Some are facing housing shortages and want to make sure apartments are being used for full-time tenants. Others are vacation towns that want to encourage tourism while making sure proper taxes are collected. Many communities are concerned about quality of life issues, like too much noise.

Airbnb says it supports regulation, but the company has clashed with some cities that it sees as going to far. The company is currently suing San Francisco over a new rule that requires all hosts to register with the city.

Related: Airbnb has sued its hometown of San Francisco

Host Compliance is another startup that helps cities enforce their short-term rental laws. The company has worked with about 15 cities, including Vancouver, Pasadena, Los Angeles and Truckee, a resort town near Lake Tahoe, California.

The company scrapes together all the information it can find on local short-term listings and sends notices to hosts on behalf of the cities. It might tell them to register or pay taxes, or inform them of other city rules. It has a hotline for neighbors who want to report issues such as noise or parking, then it gathers evidence to back up the claim for cities to take action.

"The world is better for short-term rentals if they behave correctly," said Host Compliance founder Ulrik Binzer. Like the other startups, he doesn't see Host Compliance as taking on Airbnb, but picking up where the company leaves off.

"If this industry is to be sustainable in the long run, we have to accept that it's here to stay so we get ourselves out of thinking we can regulate it into oblivion," said Binzer.

Airbnb seems to err on the side of minimal enforcement. It does list local regulations on its site, but doesn't check on listings itself. If a neighbor or building owner complains to the company, it will reach out to the host and help them address the problem. The company declined to comment on third-party policing startups.

"I think people will try and characterize us as trying to take away people's ability to make money," said BNB Shield's Casimir. "But if you're playing the game correctly, then everybody gets to play."