I had a similar use case when I hadneeded to access services on three different places using different LAN / WAN settings in hosts file. Karolos' answer above is one possible solution. My approach is here.
1- ref to http://apple.stackexchange.com/q/139267/74657
2- created hosts files for each location (hosts.work, hosts.home, hosts.vendor)
3- Using soloz's script, here (https://github.com/slozo/Network-listener) whenever I connect to home network, I execute simple script to switch the hosts file.
simplest method would be
mv hosts.home /etc/hosts
alternately you can automate Karolos' answer above using sed to update the exiting file on connecting to specific SSID which you can detect and run easily by using soloz's script mentioned above.
hope that helps anyone stumbling upon the subject issue.