Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Conditional Hosts File

Conditional Hosts File
Thread Tools
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Nov 28, 2004, 09:26 AM
 
Okay, this isn't exactly a cross post, as I'm asking a slightly different question about a slightly different topic... about the same problem I was having in the network forum.

I'll cut to the chase - I somehow need to have urls resolved differently based on whether I am behind my router or not. For example, if I'm behind my router, then I'd like www.fahrenbacher.com to resolve directly to 192.168.2.2 instead of my router ip, because then it simply resolves to my router's setup utility instead of my website. But if I'm not behind my router, then I want www.fahrenbacher.com to resolve to my router ip, because then my router is smart enough to redirect incomming traffic to the appropriate server. So, is there someway to make my hosts file conditional... or something along those lines?

Thanks.
     
Junior Member
Join Date: May 2004
Status: Offline
Reply With Quote
Dec 1, 2004, 09:32 PM
 
I've been thinking about the same thing for a little while. The best I can think of is a script that checks your location and renames different hosts files to the active one.
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Dec 2, 2004, 12:26 AM
 
Run a local DNS server?
-DU-...etc...
     
Fresh-Faced Recruit
Join Date: Jan 2004
Status: Offline
Reply With Quote
Dec 2, 2004, 01:55 PM
 
I don't know what an elegant "conditional" solution might be, but I've always punted and have always just added additional lines in my hosts files for internal testing:

192.168.2.2 internal.fahrenbacher.com

Whatever.

Uber
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Dec 3, 2004, 05:37 AM
 
Multihoming? Setup the configs you want in the Network Pref Pane, each with the ip of the DNS server you want to use for that individual configuration. The Location window of the Network Pref Pane is easily accessible via the blue Apple menu if you want to change priorities.

Check out this article from a couple of years ago on Apple's website by David Pogue.

Craig
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Dec 3, 2004, 06:47 AM
 
Perhaps just bookmark it? Say a bookmark for the internal address 192.168.1.whatever, and a separate bookmark for the external. Yer done.

The whole scripting and/or switching of configs seems way more complex than need be.
-DU-...etc...
     
Fresh-Faced Recruit
Join Date: Jan 2004
Status: Offline
Reply With Quote
Dec 3, 2004, 08:43 AM
 
Originally posted by utidjian:
Perhaps just bookmark it? Say a bookmark for the internal address 192.168.1.whatever, and a separate bookmark for the external. Yer done.

The whole scripting and/or switching of configs seems way more complex than need be.
For me, the problem with just using the internal ip address is I have several virtual hosts set up, so the "name" is important.

Uber
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Dec 3, 2004, 10:07 AM
 
Originally posted by uberwrensch:
For me, the problem with just using the internal ip address is I have several virtual hosts set up, so the "name" is important.
Easy. Map this "internal" configuration page to a different port, say 5080 (or something). You can do this on the router if it allows it or use a redirect from your webserver. Your bookmark would then look something like http://192.168.2.2:5080 then bookmark it. Yer done.
-DU-...etc...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:02 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2