Even if Iran’s neighbouring countries have good relations with Iran, the question is whether the banking system in the neighbouring countries is liable to the sanctions.
Cash withdrawals through ATMs between different banks are handled through interbank networks, many of which exist as standalone networks within a country (as the Wikipedia article linked to indicates). Cross-country / multi-region transfers are handled by interbank networks run by Visa Plus, MasterCard Cirrus, or other products from Visa / MasterCard that talk directly to their respective networks without going through an interbank network.
The main interbank networks and card providers are all run by Visa and MasterCard (primarily, except for regions such as China where UnionPay used to be monopoly until recently). So for you to be able to use ATMs from a country with friendly relations with Iran, you’ll need a bank that issues cards for its own country not on an American-owned network like Visa / MasterCard as well as on a card network that works in Iran.
According to the page on Iran’s banking system (Shetab), it’s an in-country network but with mutual agreements with banks in UAE, Bahrain, Qatar, Kuwait, and China. This means theoretically it may be possible to get bank accounts in one of these countries with a card that works in Iran, but there are caveats highlighted above that you need to watch out for and YMMV. Your safest option is to check beforehand with any prospective bank whether their cards will work in Iran.
Credit:stackoverflow.com‘