LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   dns need zone file to resolve virtual host ? (http://www.linuxquestions.org/questions/linux-networking-3/dns-need-zone-file-to-resolve-virtual-host-641448/)

cool47 05-11-2008 12:32 PM

dns need zone file to resolve virtual host ?
 
hello to all

how do i resolve virtual hosts using dns ? please help me.
thanks in advance.

dkm999 05-11-2008 05:02 PM

In order to answer your question, I will first need to know some more about exactly what you see as the problem.

1. I assume that when you ask about a virtual host, you mean a virtual web server, hosted on either your (Linux?) computer or on a hosting service machine. Is that true?

2. In the configuration for such a web server, you probably have something like this:
Code:

<VirtualHost 192.168.1.5:80>
<ServerName www.fu.bar>
  ...
</VirtualHost>

The name www.fu.bar is the DNS name (also called a fully-qualified domain name, or FQDN) of the virtual host. Are you in control of the domain name"fu.bar"? Or is this a completely made-up name? If you have control of the domain that the virtual host belongs to, you can add a record to the zone file defining that domain; you can use either an A record or a CNAME record for the purpose.

If you need more detail about any of this, or if some of my assumptions are wrong, feel free to post again, with more specifics.

cool47 05-11-2008 08:29 PM

Thanks, you assumptions was right.
i have couple of doubts.
my zone file.
$84600
@ IN SOA ns1.example.com. root.Server1.example.com. (
10 ; serial
1800 ; refresh
900 ; retry
69120 ; expire
1080) ; negative cache ttl

NS ns1.example.com.
NS ns2.example.com.

ns1 IN A 192.168.0.1
ns2 IN A 192.168.0.2
Server1 IN A 192.168.0.3
www IN A 192.168.0.3
IN A 192.168.0.2
here the origin is example.com, please give me the example to add another fqdn.
and
my /etc/resolve.conf
search ns1.example.com example.com
nameserver 192.168.0.1
nameserver 192.168.0.2
how do i modify this ?
thanks in advance.

dkm999 05-12-2008 01:45 AM

To change this to a different domain, you would change example.com. to fu.bar. everywhere it appears in the zone file.
Code:

$84600
@    IN    SOA ns1.fu.bar. root.Server1.fu.bar. (
            10 ; serial
            1800 ; refresh
            900 ; retry
            69120 ; expire
            1080) ; negative cache ttl

        NS    ns1.fu.bar.
        NS    ns2.fu.bar.

ns1    IN    A    192.168.0.1
ns2    IN    A    192.168.0.2
Server1    IN    A    192.168.0.3
www    IN    A    192.168.0.3

In addition, you will need to fix up the file /etc/named.conf, which specifies the zone file:
Code:

zone "fu.bar" {
    type master;
    file whatever_the_name_of_the_zone_file_is;
};

Then your /etc/resolv.conf only needs to look like this:
Code:

search fu.bar
nameserver 192.168.0.1
nameserver 192.168.0.2


cool47 05-12-2008 06:40 AM

NO NO....
I want to include fu.bar,example.com(multiple sites in single host with single ip).
My example is working perfectly with fqdn www.example.com. but i want to add more fqdns in Server1 as virtual hosts.
Should i create zone file for each fqdns? if so how do i change the /etc/resolve.conf?

thanks in advance

cool47 05-12-2008 01:49 PM

hello dkm999,

My problem is almost solved, i don't know this way is correct or wrong,please help me to sure it. i just added zone file for each virtual host to ns1, ns2 and modified all the related files accordingly. but i have more doubts. At present the main site is www.example.com, insteaded of that below i added three virtual hosts
www.test1.com,www.test2.com,www.test3.com.
shell#lynx www.example.com o/p is www.test1.com
shell#lynx www.test1.com o/p is www.test1.com
rest is coming correctly. why www.example is not showing? should i change the port 80?

In the virtual host directive
i added
ServerAlias www.test11.com (in www.test1.com virtual host)
now how do i get this alias site using dns? or how do i modify the zone file?
should i again add zone file for this alias site like virtual host?
i don't know . please please ... help me.
thanks in advance

dkm999 05-13-2008 12:00 AM

You do indeed need to declare a zone file for each of these domains, but I recommend that you use a template, which declares the primary zone nameservers as its own, so that you don't have to make up a new zone file for each of these domains. The template zone file looks like this:
Code:

$84600
@    IN    SOA ns1.example.com. root.Server1.example.com. (
            10 ; serial
            1800 ; refresh
            900 ; retry
            69120 ; expire
            1080) ; negative cache ttl

        NS    ns1.example.com.
        NS    ns2.example.com.

www    IN    A    192.168.0.3

Then, you can use this for as many of these (virtual) domains as you would like, by making your /etc/named.conf file look like this, in part:
Code:

zone "test1.com" {
  type master;
  file "template.zone"
};
zone "test2.com" {
  type master;
  file "template.zone"
};
zone "test3.com" {
  type master;
  file "template.zone"
 };

This will generate a definition for each DNS name www.test{x}.com pointing to your web server.

I do not recommend using the ServerAlias directive in your server configuration files; it will probably just increase the confusion. Do you have a <VirtualHost> block defined for example.com? Once you start using virtual hosts, the httpd (or apache2) daemon will not notice your main configuration any more; you have to have a virtual host defined for each one you want. And if the daemon cannot find a virtual host that matches the name you used to get there, it will choose the first virtual host defined in your config file, and serve up a page from there.

Hope this helps

cool47 05-13-2008 05:39 PM

Thank you for your excellant explanation.


All times are GMT -5. The time now is 10:35 PM.