You can get a re-entry permit at both DMK and BKK airports
****
In Suvarnabhumi the re-entry permit counter is in International Departure #2, it is after security screening but before you stamp out of the country. Look for the signs
In Don Mueang the re-entry counter is AFTER you stamp out of the country at passport control. Tell them when you stamp out you need a re-entry permit and they will show you where to go.