TOKYO (Reuters) - Japanese policymakers are in frequent contact with European counterparts on how to soothe markets if Britain votes to leave the European Union, with the first line of defense aimed at preventing a shortage of dollar liquidity.

The Bank of Japan is ready to offer dollar funds to domestic banks via auctions if a so-called Brexit scares investors into hoarding the U.S. currency, said officials with direct knowledge of preparations.

But Tokyo does not have as clear a plan on how to address an unwelcome yen rise that may be triggered by a Brexit, since the Japanese currency is also seen as a safe haven at times of heightened risk. Japan has not got any consent from its Group of Seven counterparts on yen-selling currency intervention.

"Solo intervention by Tokyo is quite difficult and probably won't be effective when other countries also want their currencies to stay weak," said one of the officials.

That means Japanese officials have little choice but to talk down currency volatility, the officials say, although there is no guarantee it can keep yen bulls at bay.

"Brexit is the biggest near-term risk as it could trigger a yen spike," said another official on condition of anonymity.

"If markets freeze up like after the collapse of Lehman Brothers, there's also a risk dollar funding may be squeezed."

BOJ and European central bankers are in regular contact on how to respond to any crisis that could be triggered by a Brexit with the focus being on how to avoid any recurrence of a liquidity squeeze that froze credit markets in the aftermath of the 2008 Lehman crisis, the officials said.

Global policymakers have raised alarm over the June 23 British referendum with fears of a Brexit pushing down the pound and the euro, while boosting demand for the yen.

The yen has surged to a six-week high against the dollar and a 3 1/2-year high against the euro, adding to headaches for Japanese policymakers worried about the pain the strong yen could inflict on exports and a fragile economic recovery.

Sources have told Reuters the European Central Bank would publicly pledge to backstop markets in tandem with the Bank of England should Britain vote to leave the EU.

Japan may join such calls if volatility is high, like when major central banks pledged to work together to calm markets during the 2008 global financial crisis.

NO SOLO INTERVENTION?

The BOJ sees little risk of a Brexit drying up yen liquidity.

The bigger risk, Japanese policymakers warn, is a shortage of dollar funds on flight-to-safety demand that could freeze up credit markets in Asia.

The direct hit to Japanese banks is likely to be small as most of them have secured necessary dollar funding beyond the end of this month, BOJ officials say.

In the event of severe market upheaval, the BOJ can use its weekly auctions to offer dollar funding to financial institutions suffering from a shortage of foreign currencies.

It can also use arrangements with other central banks, including the Federal Reserve and the ECB, to provide each other with foreign currency to counter severe market strains.

"If a U.K. vote to leave the EU results in a dollar shortage across Asia, Japan may request coordinated intervention with G7 partners to supply dollars and yen into the markets through activation of central bank swap lines," said Mansoor Mohi-Uddin, senior market strategist at RBS.

As a last resort, Japan can create a framework to make use of its massive foreign reserves to help domestic banks with dollar funding, the officials said.

The hurdle for direct yen-selling intervention by Japan, on the other hand, remains high with U.S. Treasury Secretary Jack Lew repeatedly rebuffing Tokyo's calls that yen moves have been "disorderly" and could justify intervention.

A Japanese government spokesman had little to say on Wednesday except that Tokyo will continue to monitor how markets react to the British referendum.

The yen's ascent will also keep the BOJ under pressure for action at Thursday's rate review. While many BOJ officials prefer to hold off on expanding stimulus, Governor Haruhiko Kuroda has warned that he is ready to pull the trigger if yen rises threaten to derail a fragile recovery.

Still, many analysts say there is not much Japan can do to keep yen rises in check for a sustained period.

"In the end, this is not something Japanese policies can influence," said a third official. "There is not much the BOJ can do besides brainstorming to prepare for the worst."