So what I'm doing is a copy of /etc/hosts in RAM (small RAM disk, 20 MB in size). Keep in mind that this is "quick and dirty" script, no error checking, no nothing. I'm OK with that since I'm running it manually each time, and in worst case I lose name resolution, but not access to shell, but you were warned.