PDA

View Full Version : [all variants] subdomains in /etc/hosts?



freakavoid
July 23rd, 2008, 12:15 AM
Hi,

I'm looking for a way to assign an ip address for a site with all its subdomains (without knowing all of them). /etc/hosts doesn't allow wildcards. So something like


127.0.0.1 *.example.com

doesn't work. Any suggestions?

Thanks in advance.

Xerp
July 23rd, 2008, 12:17 AM
You can do that with BIND


sudo apt-get install bind9 dnsutils

then


sudo vi /etc/bind/named.conf.local

and add like this:


zone “myexample.com” {
type master;
file “/etc/bind/zones/myexample.com.db”;
};

and this:


sudo vi /etc/bind/zones/myexample.com.db



myexample.com. IN SOA ns1.myexample.com. admin.myexample.com. (

2008230601
28800
3600
604800
38400
)

myexample.com. IN NS ns1.myexample.com.
myexample.com. IN MX 10 mail.myexample.com.

@ IN A 192.168.0.3
www IN A 192.168.0.2
ns1 IN A 192.168.0.1


You'll need to know a bit about DNS though :/

http://en.wikipedia.org/wiki/Wildcard_DNS_record

freakavoid
July 23rd, 2008, 12:27 AM
Thank you. I'm not sure if I want to set up a dns just for this task but it seems like there is no other option. Anyways thank you for the info.

Oldsoldier2003
July 23rd, 2008, 12:29 AM
Thank you. I'm not sure if I want to set up a dns server just for this task but it seems like there is no other option. Anyways thank you for the info.

It probably is the best workaround since using a domain in hosts breaks sudo in gutsy and hardy

freakavoid
July 23rd, 2008, 12:48 AM
It probably is the best workaround since using a domain in hosts breaks sudo in gutsy and hardy

Hmm... Actually I don't want to direct the domain name to localhost. But out of curiosity: That problem occurs only if the lines with the name of the computer are changed, right?

Oldsoldier2003
July 23rd, 2008, 12:50 AM
Hmm... Actually I don't want to direct the domain name to localhost. But out of curiosity: That problem occurs only if the lines with the name of the computer are changed, right?
correct. it also happens a lot with upgraded ubuntu installations for some reason.