Date: Sat, 13 Nov 1999 11:06:39 +0800 (WST) From: Michael Kennett <mike@laurasia.com.au> To: papalia@UDel.Edu (John) Cc: freebsd-questions@freebsd.org Subject: Re: DNS (was: DNS & Virtual hosting) Message-ID: <199911130306.LAA18644@laurasia.com.au> In-Reply-To: <4.1.19991112131338.00955680@mail.udel.edu> from John at "Nov 12, 99 01:34:14 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Hi John, > Mike, > > Well, the good news is that the suggestions you made seems to work quite > (almost) flawlessly. That was probably the easiest ("basic") setup I've Thats great! > done yet :) I made up my (currently) phoney domain per your instructions, > and found it with nslookup no problem. As I indicated though, this is > merely a stepping stone for stuff I plan to (need to) get done in the next > couple of months, so, here's a few more questions - if these branch outside > of the realm of named, please let me know :) > > (funny... as I started asking the questions, and started pasting in cuts > from my files, I found a lot of my errors =) ) > > 1) I'll be registering 3 domain names. As things grow, they'll be used. > If my domains are foo1.bar, foo2.bar, foo3.bar, and I have them all point > to my dns (let's say my machine's # is 1.1.1.1), and assuming all http > access is off one machine, how do I get the machine to recognize where to > go for a request between each of the domains? I'm assuming i have to set > up zones for them, but how do I tell it where to find the appropriate > files? I'm not sure if this is this outside of the named question? You'll have to set up three different zone files. The /etc/namedb/named.conf file is the `anchor' for the named configuration, and in this file you'd put lines like: // Zone file for the foo1.bar domain... zone "foo1.bar" { type master; file "foo1.bar.domain"; }; // Zone file for the foo2.bar domain... zone "foo2.bar" { type master; file "foo2.bar.domain"; }; // ....more zone declarations... Next, you'd create each of the fooX.bar.domain files (as outlined in a previous email). Assuming that your web server has the IP address 1.2.3.4, and that you want to have that machine visible from each of the fooX.bar domains, you'd create an address (A) entry in each of the zone files for that machine: [in foo1.bar.domain] www IN A 1.2.3.4 [in foo2.bar.domain] www IN A 1.2.3.4 [in foo3.bar.domain] www IN A 1.2.3.4 Now, an nslookup on www.fooX.bar (X=1,2,3) should return 1.2.3.4. You had the question: ``assuming all http access is off one machine, how do I get the machine to recognize where to go for a request between each of the domains?'' [I think this is the `virtual hosting' question -- I'm not experienced at doing that, and I think it falls outside of named, but here goes....] As stated above, the name->address translation for each of the www.fooX.bar names will return the IP address 1.2.3.4 --- so a `naive' setup of your Webserver for these domains would return the **same** set of pages, which is most probably not what you want! I'm assuming you want the requests to http://www.foo1.bar/welcome.html and http://www.foo2.bar/welcome.html to return different pages... The Apache Web server (v1.3 and above?) supports `Virtual Hosting', which is the ability of a single machine to act differently according to the name/IP-address it is accessed as. There are two virtual hosting mechanisms (documented in the Apache distribution -- look at it for more details): 1. IP Address I won't discuss this one -- it won't work with the named configuration that I've suggested above. 2. Name Use the <VirtualHost>, and NameVirtualHost directives in your apache configuration files. Each virtual host can be given its own set of web pages with the DocumentRoot directive. According to the Apache Documentation: ``While the approach with IP-based virtual hosts works well, it is not the most elegant solution, ..., and it is hard to implement on some machines. The HTTP/1.1 contains a method for the server to identify what name it is being addressed as. Apache 1.1 and later support this approach .... The benefits of using the name-based virtual host support is a practically unlimited number of servers, ease of configuration and use, and requires no additional hardware or software. The main disadvantage is that the client must support this part of the protocol. ...'' So, have a look at the Apache documentation, and try it out! > 2) Based upon the upper question, I also need to set up an smtp server. > I'm assuming I can just add a record to the named files for "mail.foo1.bar" > and "mail.foo2.bar" and "mail.foo3.bar". But again, how is this handled if > all three are on the same machine? Mail is handled quite differently in the DNS system. It uses the `MX' (mail exchange) records in the zone files. Basically, I've got entries like the following in my zone files: [e.g. foo1.bar.domain zone file] gateway IN A 1.1.1.1 ; IN MX 100 mail ; (mail==gateway, no MX req'd) mail IN CNAME gateway ; mail is another name for gateway ; mail sent to machineX.foo1.bar is handled by the mail (gateway) machine machine1 IN A 1.1.1.2 IN MX 100 mail machine2 IN A 1.1.1.3 IN MX 100 mail machine3 IN A 1.1.1.4 IN MX 100 mail Note: I've used the `CNAME' directive. This is a handy directive for setting up aliases for the name of a machine. Internally, I have `friendly' names for a few of my machines (sparkle, alpha, rabbit, etc...), but these are aliased over to the more `functional' names www, mail, ftp that provide the given service. You can set a single mail gateway to accept mail for a variety of hosts. I'm not a sendmail guru, but I've done it by editing the /etc/mail/sendmail.cw file, and adding in the names (as seen in the DNS) of the hosts that I accept mail for. You might also have to edit the /etc/sendmail.cf file to add in the line: Fw-o /etc/mail/sendmail.cw (From memory, this is commented out by default (?). It should be at the top of the /etc/sendmail.cf file) > > Again, I know these aren't well phrased questions, but I hope you can still > help. Your questions are fine! I think we've found the `virtual hosting' part of what you want to do -- it is done by Apache (or your web server), and not the DNS. Your second question (on mail) is handled by both the DNS and the mail transport agent (e.g. sendmail). > > Thanks again!!! > --John Papalia Regards, Mike Kennett (mike@laurasia.com.au) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911130306.LAA18644>