Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Ok, this will be a somewhat lengthy question. First, some background: I am developing and testing websites on a Macbook (OSX Lion), using Parallels to run various installs of Windows for IE testing. I needed a way to initialize a new web project through a BASH file, automatically setting up my virtual host for the project and whatnot.. I needed to have my VM's recognize the virtual host though, without me having to go in a manually edit the VM's windows hosts file, but to do that, I needed my BASH script in OSX to be able to edit the hosts file in the Windows VM.

I'm still not sure this is possible, but while trying to figure that out, I came across a blog post. This blog post talked about BIND and using named zones and everything to set up a DNS server to get my virtualhosts recognized by the VMs. It had a form that asked for my IP address or something and output a script that I used to set everything up and it worked perfectly! The problem, however, is for whatever idiotic reason, I didn't bookmark that blog post. On top of that, when I upgraded to Parallels 8, it broke something and the whole thing stopped working. I've searched and searched for the blog post and can't find it again.

What I know about what the script did, however, was it definitely used the IP of the Parallels Shared #0 adapter (192.168.2.2) in the zone file. Not sure why it worked before I upgraded to Parallels 8, but after I upgraded, my virtual hosts would only work (even on my local machine) while I had Parallels running. It also created a folder in /etc/ called resolver, with a file for my virtual host in it. I have no idea why it worked then without parallels running.

Anyway, since giving up on trying to find that blog post, I've started trying to figure out the whole bind thing myself.

The virtual host base I want to use is stupid.local.. so if I have a site called "test", it would be accessed at http://test.stupid.local. I have the main virtual host set up in my apache httpd.conf file correctly and my BASH script generates the individual site virtual host files for me (which, I know for a fact work). So far, I've set up bind/named through terminal and added this to my /etc/named.conf file:

 zone "local" IN {
        type master;
        file "local.zone";
        allow-update { none; };
    };

my /var/named/local.zone file looks like this:

$TTL  60
$ORIGIN local.
@      1D IN SOA  localhost. root.localhost. (
          46    ; serial (d. adams)
          3H    ; refresh
          15M    ; retry
          1W    ; expiry
          1D )    ; minimum

      1D IN NS  localhost.
      1D IN A  127.0.0.1

*.local. 60 IN A 192.168.1.138
stupid.local. 60 IN A 192.168.1.138
*.stupid.local. 60 IN A 192.168.1.138

...the 192.168.1.138 is my IP at work. As you may be able to guess, this set up works and is accessible by my Windows VM through IE, but only when I'm on my network at work. When I take my Macbook home, I have to change that IP address to the one on my home network, which is 192.168.1.4. Also, If I change that IP address to 192.168.2.2 (the IP of the Parallels Shared #0 adapter), it works and is accessible by my Windows VM through IE, but of course, only when Parallels is running. Changing it to 127.0.0.1 makes the set up work only within OSX and not at all through my VM.

So what I need is a to create or access some sort of IP address, that is going to stay with my Macbook and not change, that I can use with BIND to be able to access my virtual hosts at *.stupid.local on both my local OSX machine and within my Parallels VM's.

Long winded, I know, but I wanted to be thorough. So... any ideas? Or, any alternative solutions?

share|improve this question
    
Just wanted to say that I believe I've resolved this situation.. I duplicated my main Wi-Fi network device in System Preferences > Network and then set the IP address for it manually. Then, all I had to do was change the IP addresses in my local.zone file to the IP address of my new interface. May not be the best approach, but it seems to work like a charm! –  Shelby Neil Smith Jan 2 '13 at 17:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.