Figure out what IP address MySQL resolves a host name to
Alright.. It was wrong TCP port. Sorry :) So I solved my problem with RDS connectivity. But the second part still stands: MySQL server as a "DNS resolver". While dealing with RDS I tried to go with PostgreSQL, because if it were DNS problem it would affect PostgreSQL as well. I figured that I can do it in PostgreSQL with various extensions like plperlu. Unfortunately, all of them are blocked in RDS :)