Zone file that returns CNAME for $HOSTNAME?
Posted: Fri Mar 06, 2009 12:07 am
My problem is simple. On my MacBook I have named (BIND9) running so that I can have my own zone files that are checked *before* talking to my ISP's nameservers. Why? So that I can have *.webdev map to 127.0.0.1 to make starting new web development projects easier on my mac.
For example on my MacBook swiftmailer.webdev resolves to 127.0.0.1 and an Apache VirtualHost has some clever rewrite rules to know where to expects the document root for this project. I can create a new project called "otherproject" by simply creating a directory at the correct part of my filesystem and then opening "otherproject.webdev" in my browser. Easy.
This works really well, here's the zone file:
[text]$TTL 86400$ORIGIN webdev.@ 1D IN SOA @ root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS @ 1D IN A 127.0.0.1 * IN A 127.0.0.1[/text]
Today I installed VirtualBox (a virtual machine) and I've got a Windows XP installation running in it. All good so far!
The Windows Virtual machine is correctly using my DNS to lookup *.webdev domains with one major flaw.... the returned IP of 127.0.0.1 points to the windows installation, not to my mac. Hmmf.
I want swiftmailer.webdev and other.webdev to point to the *host machine*, i.e. my mac. The solution of course is NOT to use 127.0.0.1 as the A record, it is to use the public IP address 10.x.x.x. This works.
The problem with using the 10.x.x.x address is that it's dynamically assigned and being on my MacBook, I move around a lot.
What I was hoping I'd be able to do is this. Since my MacBook always has the name "chrisbook.local" on the network, I wanted to CNAME using that instead:
[text]$TTL 86400$ORIGIN webdev.@ 1D IN SOA @ root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS @ 1D IN CNAME chrisbook.local. * IN CNAME chrisbook.local.[/text]
While I can ping chrisbook.local and see my 10.x.x.x IP address comes back correctly, I can't ping swiftmailer.webdev (unknown hostname). Clearly whatever name finding protocol is being used on to create the hostname for the mac isn't valid for use with named/BIND.
Does anyone have any ideas how I can get the zone to return the current public IP address all the time? I'll drop the TTL to just a few seconds too. Stumped.
For example on my MacBook swiftmailer.webdev resolves to 127.0.0.1 and an Apache VirtualHost has some clever rewrite rules to know where to expects the document root for this project. I can create a new project called "otherproject" by simply creating a directory at the correct part of my filesystem and then opening "otherproject.webdev" in my browser. Easy.
This works really well, here's the zone file:
[text]$TTL 86400$ORIGIN webdev.@ 1D IN SOA @ root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS @ 1D IN A 127.0.0.1 * IN A 127.0.0.1[/text]
Today I installed VirtualBox (a virtual machine) and I've got a Windows XP installation running in it. All good so far!
The Windows Virtual machine is correctly using my DNS to lookup *.webdev domains with one major flaw.... the returned IP of 127.0.0.1 points to the windows installation, not to my mac. Hmmf.
I want swiftmailer.webdev and other.webdev to point to the *host machine*, i.e. my mac. The solution of course is NOT to use 127.0.0.1 as the A record, it is to use the public IP address 10.x.x.x. This works.
The problem with using the 10.x.x.x address is that it's dynamically assigned and being on my MacBook, I move around a lot.
What I was hoping I'd be able to do is this. Since my MacBook always has the name "chrisbook.local" on the network, I wanted to CNAME using that instead:
[text]$TTL 86400$ORIGIN webdev.@ 1D IN SOA @ root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS @ 1D IN CNAME chrisbook.local. * IN CNAME chrisbook.local.[/text]
While I can ping chrisbook.local and see my 10.x.x.x IP address comes back correctly, I can't ping swiftmailer.webdev (unknown hostname). Clearly whatever name finding protocol is being used on to create the hostname for the mac isn't valid for use with named/BIND.
Does anyone have any ideas how I can get the zone to return the current public IP address all the time? I'll drop the TTL to just a few seconds too. Stumped.