LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 05-11-2008, 12:32 PM   #1
cool47
Member
 
Registered: Mar 2008
Location: Disney World
Distribution: CentOS
Posts: 50

Rep: Reputation: 15
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.
 
Old 05-11-2008, 05:02 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
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.
 
Old 05-11-2008, 08:29 PM   #3
cool47
Member
 
Registered: Mar 2008
Location: Disney World
Distribution: CentOS
Posts: 50

Original Poster
Rep: Reputation: 15
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.
 
Old 05-12-2008, 01:45 AM   #4
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
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
 
Old 05-12-2008, 06:40 AM   #5
cool47
Member
 
Registered: Mar 2008
Location: Disney World
Distribution: CentOS
Posts: 50

Original Poster
Rep: Reputation: 15
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

Last edited by cool47; 05-12-2008 at 10:48 AM.
 
Old 05-12-2008, 01:49 PM   #6
cool47
Member
 
Registered: Mar 2008
Location: Disney World
Distribution: CentOS
Posts: 50

Original Poster
Rep: Reputation: 15
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

Last edited by cool47; 05-12-2008 at 02:33 PM.
 
Old 05-13-2008, 12:00 AM   #7
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
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
 
Old 05-13-2008, 05:39 PM   #8
cool47
Member
 
Registered: Mar 2008
Location: Disney World
Distribution: CentOS
Posts: 50

Original Poster
Rep: Reputation: 15
Thank you for your excellant explanation.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DNS zone file not updating msteiner Linux - Server 3 11-01-2007 11:22 AM
DNS Zone file help mnm_mc Linux - Networking 2 05-22-2007 09:19 AM
DNS zone file help mnm_mc Linux - Networking 4 11-27-2006 03:28 PM
DNS zone file question DanielTan Linux - General 3 09-21-2005 09:52 PM
Need help with DNS zone file please:-) TippyToes Linux - Networking 5 04-28-2004 05:32 PM


All times are GMT -5. The time now is 09:04 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration