Multiple Domain Names on Linux

Multiple Domain Names - Linux 1.2.13

Aug 1996 - Updated 26 September 1996
How do I set up my Linux box (and possibly other UNIX systems) to answer to multiple domain names? - like abc.com and xyz.com

I wrote this because I searched the net and found a few things which talked about parts of this, and a few people who said how NOT to do this, but no one gave the play by play from start to finish for people who are really dumb, like me. Actually, when I say "really dumb", I only mean that I don't intuitively understand things like sendmail and DNS (Domain Name Service). When it comes to more practical things, I'm just dumb.

So, here it is.

My system is a Pentium running Linux 1.2.13 from Caldera - Red Hat

When I got my system, I stuck my domain name in a few places and started the web server and everything was cool. I got my own mail, hosted my own web site, etc. All this was pretty easy to do. I tried using the Caldera Desktop tools to give the machine my own name and my own IP number and tell it who my name server was, but that didn't work. So I grepped around the /etc directory until I found all instances of the default name and all instances of the default IP number. Eventually I changed them all. This just proves that sometimes a total lack of knowledge can be substituted with brute force search and replace.

All this worked without running named on my own system. I had a few other DNS name servers on other systems pointing to me so I didn't really have the need to run my own DNS.

But then I got a client who wanted his company, xyz.com to be found on my machine too. (My domain, we'll say, is abc.com)

So I had to set up the name service. If you are reading this, it probably means that you hunted around the Net trying to find something related to this. This probably means that you are as desparate as I was to find a way of doing this without reading the 7000+ pages in books from O'Reilly that might possibly tell you how to do this.

For the record, this is the most arcane crap I have ever seen, since I peeked into my sendmail config files. That's another story.

Don't you just wish that someone would write a human intelligible way of doing all this crap???? I love UNIX but I think these guys are more interested in job security than ease of use.

Anyway,

The first file is the named.boot file. The key for multiple domain names, is to have an extra "primary" line pointing to another "host" file - line 4 which contains "xyz.com" is this line.


named.boot
directory				/etc
primary		abc.com			named.abc.hosts
primary 	0.0.127.IN_ADDR.ARPA  	named.local
primary		xyz.com			named.xyz.hosts
cache		.			named.ca

The directory line just says where all these files are.

The first primary line is for the other hosts in my domain

The second primary line is typical of computer programmer mentality: something must always be self-referential or ridiculous. As near as I can tell, it says my machine is 127.0.0.0 and its written backwards because the original Internet programmers were a tribe of dyslexic counterintelligence agents whose native language was Reverse Polish Notation. Anyway, all machines use this 127.0.0.0 number to refer to themselves and usually it is not written as 0.0.127.IN_ADDR.ARPA.

The third primary line is for the xyz domain name that my machine will also be serving.

The next file ...


named.abc.hosts
@	IN	SOA	koko.abc.com.	mckenna.koko.abc.com (
			10118 		;	Serial
			43200		;	Refresh
			3600		;	Retry
			3600000		;	Expire
			2592000  )	;	Minimum
;	Define the nameservers and the mail servers
		IN	NS	koko.abc.com.
		IN 	MX	10 koko.abc.com.
		IN	A	207.90.132.170
;
;	Define localhost
;
localhost	IN	A	127.0.0.1
;
; 	Define the hosts in this zone
;
ftp		IN	A	207.90.132.170
www		IN	A	207.90.132.170
koko		IN	A	207.90.132.170
		IN	MX	5 koko.abc.com.
loghost		IN	CNAME	koko.abc.com.

Wow, lets just look at that. It starts with an @ sign and lists a bunch of codes and numbers. What a thing of pure beauty. Did the guy who invented this also come up with the idea of the autoexec.bat and config.sys files for DOS?

Ok, I don't really understand any of this. It is essentially copied out of TCP/IP by O'Reilly - a really long and not very helpful book.

The name of my machine is "koko" as in Koko Taylor, a famous lady of blues. The numbers at the top refer to the amount of time until something updates, expires, etc.

The NS, MX, and A lines mean something too. (really!) NS is nameserver MX is mail (exchange ?) and A is an Address. A little note. Without that A record, when I did a nslookup on abc.com, using my machine as the name server it could not find it. However, it could find koko.abc.com without that A record.

Then we define the localhost - this self referential thing again.

Then we name the other machines on our system (the A records) and give their IP numbers (in this case, these are all just different names for the same machine) If you have other machines you put their names in and their IP numbers which will be the same as your main IP number except for the numbers after the last dot.

The MX record is for mail and the 5 in this line has something to do with mail priority.

Finally, loghost is, I think, yet another way of the machine referring to itself.

The next file ...


named.xyz.hosts
@	IN	SOA	www.xyz.com.	mckenna.koko.abc.com (
			10118 		;	Serial
			43200		;	Refresh
			3600		;	Retry
			3600000		;	Expire
			2592000  )	;	Minimum
;	Define the nameservers and the mail servers
		IN	NS	www.xyz.com.
		IN 	MX	10 www.xyz.com.
		IN	A	207.90.132.170
;
;	Define localhost
;
localhost	IN	A	127.0.0.1
;
; 	Define the hosts in this zone
;
www		IN	A	207.90.132.170
ftp		IN	A	207.90.132.170
		IN	MX	5 www.xyz.com.
loghost		IN	CNAME	www.xyz.com.


This file is essentially the same as the named.abc.hosts file

only the abc's have been changed to xyz's, except for the one in my email address (line 1) 'mckenna.koko.abc.com' - yes this is an email address, the @ sign you normally see has been changed to a . because this makes intuitive sense to some UNIX guru somewhere.

The next file ...


named.local
@       IN      SOA     koko.abc.com.      mckenna.koko.abc.com (
                        1               ; serial
                        36000           ; refresh every 100 hours
                        3600            ; retry after 1 hour
                        3600000         ; expire after 1000 hours
                        36000           ; default ttl is 100 hours
                        )
        IN      NS      koko.abc.com.
1       IN      PTR     localhost.

This file says that the local host machine is called koko.abc.com and that stuff regarding this machine can be mailed to me. (Note the cleverly disguised email address with a . instead of @)

Why none of the other files were enough to tell this damn DNS name server the name of this machine, I have no idea. I guess redundancy is key here, and it also provides you with greater opportunity to screw things up.

Nothing about the other domain names you are hosting for goes in here except your one true domain name.

The last file ...


named.local

;
; Servers for the root domain
;
.               99999999        IN      NS      A.ROOT-SERVERS.NET.
                99999999        IN      NS      B.ROOT-SERVERS.NET.
                99999999        IN      NS      C.ROOT-SERVERS.NET.
                99999999        IN      NS      D.ROOT-SERVERS.NET.
                99999999        IN      NS      E.ROOT-SERVERS.NET.
                99999999        IN      NS      F.ROOT-SERVERS.NET.
                99999999        IN      NS      G.ROOT-SERVERS.NET.
                99999999        IN      NS      H.ROOT-SERVERS.NET.
                99999999        IN      NS      I.ROOT-SERVERS.NET.
;
; Root servers by address
;
A.ROOT-SERVERS.NET      99999999        IN      A       198.41.0.4
B.ROOT-SERVERS.NET.     99999999        IN      A       128.9.0.107
C.ROOT-SERVERS.NET.     99999999        IN      A       192.33.4.12
D.ROOT-SERVERS.NET.     99999999        IN      A       128.8.10.90
E.ROOT-SERVERS.NET.     99999999        IN      A       192.203.230.10
F.ROOT-SERVERS.NET.     99999999        IN      A       192.5.5.241
G.ROOT-SERVERS.NET.     99999999        IN      A       192.112.36.4
H.ROOT-SERVERS.NET.     99999999        IN      A       128.63.2.53
I.ROOT-SERVERS.NET.     99999999        IN      A       192.36.148.17
 
; The above information is available via ftp from nic.ddn.mil
; in the file netinfo/root-servers.txt -update 19 June 1996 - Gene
; it comes in the following format
; 
;
;       HOSTNAME             NET ADDRESSES      SERVER PROGRAM
;        
;        
;       A.ROOT-SERVERS.NET   198.41.0.4         BIND (UNIX)
;        
;       B.ROOT-SERVERS.NET   128.9.0.107        BIND (UNIX)
;        
;       C.ROOT-SERVERS.NET   192.33.4.12        BIND (UNIX)
;        
;       D.ROOT-SERVERS.NET   128.8.10.90        BIND (UNIX)
;        
;       E.ROOT-SERVERS.NET   192.203.230.10     BIND (UNIX)
;        
;       F.ROOT-SERVERS.NET   192.5.5.241        BIND (UNIX)
;        
;       G.ROOT-SERVERS.NET   192.112.36.4       BIND (UNIX)
;        
;       H.ROOT-SERVERS.NET   128.63.2.53        BIND (UNIX)
;        
;       I.ROOT-SERVERS.NET   192.36.148.17      BIND (UNIX)

Finally, the above is my named.ca file. It includes lots of comments which tell where I got all of this information. Basically you pull it off the net where it is stored in a file which you must rewrite entirely to make it be useful. Why they can't store this information in a form that actually works as is, I don't know. I guess it is job security again.

So the top half is how I rewrote it, and the bottom half is how it was originally. Not a big deal really, but why can't UNIX weenies ever make things easy?

I don't do the named.rev (or reverse domain name service) file because my ISP (Internet Service Provider) does it for me. If you would like to have this hassle removed from your list of responsibilities too, call GeoNet!

Then run named (/usr/sbin/named)

You can check the settings by using nslookup

    UNIX_prompt> nslookup

nslookup_prompt>  server abc.com
nslookup_prompt>  abc.com

Here it should find your machine abc.com

nslookup_promot>  koko.abc.com

Here it should also find your machine koko.abc.com

nslookup_prompt>  xyz.com

Here it should find your client's domain name on your machine.

If you need help, don't ask me, that is about all I know because that is all I need to know.

Finally, I use the Apache web server and it allows for virtual web hosting without too much hassle. It answers to multiple domain names and the user never knows the difference.

Woops!

Users with old browsers (Netscape 1.x, Mosaic 1.x, AOL, Chameleon, some early Microsoft trash, etc) do NOT send the name of the host they were looking for along with their request. They only send the IP number. Therefore, when someone with Netscape 1.x pointed their browser at my site looking for xyz.com they would land on the page that was for abc.com (my "real" domain name.) Theres not much you can do about this with this setup. Soon the world will get off shitty browsers and all will be peaceful.

So far none of this seems to screw up my mail server. That is, I can recieve mail for both domains, although the user names at one domain also can receive mail for the same user name at the other domain.

Return to Gene's Home Page
Return to Gene's Random Unix Crap