-
Notifications
You must be signed in to change notification settings - Fork 2
Setting up bind on vm (reference)
Here's the process for enabling the dynamic DNS stuff to work from vagrant to upstream localhost
- Install bind on the vagrant box:
# yum install bind - Add the following to your
/etc/named.conf:
zone "vagrant.dev" IN {
type master;
file "vagrant.dev.zone";
};
- Write the following file to
/var/named/vagrant.dev.zone:
$TTL 1D
@ IN SOA ns1.vagrant.dev. root.vagrant.dev. (
2014022001 ; serial
8H ; refresh
4H ; retry
4W ; expire
1D) ; minimum TTL
; Nameservers
IN NS ns1.vagrant.dev.
IN NS ns2.vagrant.dev.
; Resolve nameservers to IPs
ns1 IN A 127.0.0.1
ns2 IN A 127.0.0.1
; A records
@ IN A 127.0.0.1
* IN A 127.0.0.1
- Reown the file:
# chown root:named /var/named/vagrant.dev.zone - Generate the key file:
# rndc-confgen -a -r /dev/urandom - Start up bind:
# /etc/init.d/named start - Add
nameserver 127.0.0.1as the first nameserver in/etc/resolv.conf
On your localhost:
- Start up the port forwarding:
ssh -C -D 1080 -p 2222 vagrant@127.0.0.1 - Configure your browser to use SOCKS5
If all went well, you should be able to resolve anything.you.want.vagrant.dev correctly to your vagrant box in your browser. Note that unless you modify your system proxy to utilize the SOCKS5 proxy, you will not be able to resolve it outside your browser (IE, on command line).
SOCKS5 configuration can be done in firefox under network settings for all platforms. Set the server to 127.0.0.1 and the port to 1080.
SOCKS5 configuration on chrome in linux (and maybe mac?) is done by running the following in a bash terminal:
export SOCKS_VERSION=5
export SOCKS_SERVER=127.0.0.1:1080
and then launching chromium from the same terminal.
SOCKS5 configuration in Chrome on Windows is not possible on a limited user account due Chrome using the system level proxy settings, which cannot be changed by a limited user.
To have apache automatically resolve the subdomain to a folder under your document root, append the following to your /etc/httpd/conf/httpd.conf on your vagrant box:
<VirtualHost *:80>
VirtualDocumentRoot "/var/www/html/%1"
ServerName *.vagrant.dev
UseCanonicalName Off
</VirtualHost>
Then make sure that NameVirtualHost *:80 is not commented out above, and restart the apache server with # /etc/init.d/httpd restart
Requests to blah.vagrant.dev should pull up your files under /var/www/html/blah/
Note that enabling this functionality will make requests to vagrant.dev resolve to the /var/www/html/vagrant/ directory instead of the normal /var/www/html directory.