We have a machine in the office that we use for source control, and its set up in DNS with a fully qualified name that points to the offices external IP address. Of course, if you try and use that fully qualified name while youre in the office, you cant connect you have to use the local 192.168.X.X address to get to it. Thus, the machine has different addresses depending on whether youre trying to reach it from within or outside of the office LAN.
Short of requiring everyone VPN into the LAN when outside the office, the simplest solution (not having a domain controller or DNS server inside the LAN) weve found thus far is to update the HOSTS file (C:\Windows\System32\Drivers\Etc\Hosts) of computers when they are outside of the office. To achieve this, we simply created two hosts files:
hosts.office.txt includes mapping of foo.bar.com > 192.168.x.x
hosts.home.txt includes mapping of foo.bar.com > xxx.xxx.xxx.xxx internet address
Home really means Anywhere but the office but usually thats home. It also starts with a different letter (as opposed to out of office) which well see matters slightly.
The next step is to create an office.bat and home.bat which each consist of one line and say:
office.bat:
xcopy /Y hosts.office.txt hosts
home.bat:
xcopy /Y hosts.home.txt hosts
The /Y tells it to overwrite without asking.
Now all that remains is to make it easy to call these two batch files. This is where Slickrun comes in handy. By creating magic words for office and home that map to these two files, switching from one profile to another is just a matter of typing:
Win-Q, h o ENTER (for home)
or
Win-Q o f ENTER (for office)
Now, what Id really like is for Windows to automatically notice when its network status changes (basically, my machines IP address, or perhaps the name of the LAN/Wireless network), and determine from that which hosts file to use. If someone has a script that does something like this, let me know. In the meantime, this approach has worked for the last couple of years with minimal friction/annoyance, so Ill keep using it until something simpler presents itself (or until we move our source control to the cloud/internet).