We help IT Professionals succeed at work.

Creating a CNAME from one sub domain to another sub domain on the same server with plesk

Greg Alexander
on
Heres the sitch:

I have two websites:
domain1.com
domain2.com

I want :
admin.domain1.com to go to admin.domain2 through a CNAME.

I have setup a sub-domain on domain2.com for admin.domain2.com and I setup a CNAME record on domain1.com for admin.domain1.com that points to admin.domain2.com... However when I go to admin.domain1.com it just goes to domain2.com and not the sub-domain, Any ideas?
Comment
Watch Question

BRONZE EXPERT

Commented:
1. If you go directly to admin.domain2.com, does that work?

2. If you do "host admin.domain1.com", does it return something like "admin.domain1.com is an alias for admin.domain2.com" ?  (if you don't have the host command, how about "nslookup admin.domain1.com"?)

Sounds like DNS isn't correctly set up if the answer is yes to question 1 above.
Greg AlexanderLead Developer

Author

Commented:
1. yes
2. here is what I get:

admin.domain1.com is an alias for admin.domain2.com.
admin.domain2.com has address xxx.xxx.xxx.xxx
Host admin.domain2.com not found: 2(SERVFAIL)
Host admin.domain2.com not found: 2(SERVFAIL)

But if I go to admin.domain2.com in the browser it works
BRONZE EXPERT

Commented:
Is your browser on the same server as the website?  If so, you could be getting resolution from a local hosts entry.

So obviously you added the CNAME correctly, but did you ever add the A record for admin.domain2.com?  It should be something like "admin  IN A <ip address of admin.domain2.com>"
Greg AlexanderLead Developer

Author

Commented:
Let me try that
Greg AlexanderLead Developer

Author

Commented:
There is an A record on domain2.com's DNS settings for admin.domain2.com
BRONZE EXPERT

Commented:
Okay, so if you do 'host admin2.domain.com" what do you get?

And if it doesn't look up, what if you do "host admin2.domain.com ns1.domain.com" (this forces the query to go to ns1.domain.com instead of using the local system resolver which may be pointed at ISP DNS servers)
SILVER EXPERT
Distinguished Expert 2019

Commented:
can you masquerade the domain while posting the zone file files for
domain1.com and domain2.com?
make sure you do not have admin.domain2.com defined as a delegated zone.

dig -debug alias.domain1.com should tell you what requests are being made and where they are being sent.
or host -d admin.domain1.com
Greg AlexanderLead Developer

Author

Commented:
@xterm:

When I run the command host admin.domain2.com, it just says:

admin.domain2.com has address XXX.XXX.XXX.XXX (which is the correct ip address, if yo type in that address, you go to domain2.com, but when you add the admin. it goes to the sub-domain) In other words everything seems to be going to the right places, for some reason the server is not going to the sub-domain when it comes from admin.domain1.com

Greg AlexanderLead Developer

Author

Commented:
@arnold

Here is the zone file for domain2.com

; *** This file is automatically generated by Plesk ***
$TTL    86400

@       IN      SOA     ns.domain2.com. server.domain2.com. (
                        1319727369      ; Serial
                        10800   ; Refresh
                        3600    ; Retry
                        604800  ; Expire
                        10800 ) ; Minimum

domain2.com.           IN NS   ns.domain2.com.
webmail.domain2.com.           IN A    XXX.XXX.XXX.XXX
mail.domain2.com.              IN A    XXX.XXX.XXX.XXX
ns1.domain2.com.               IN A    XXX.XXX.XXX.XXX
ns2.domain2.com.               IN A    XXX.XXX.XXX.XXX
domain2.com.           IN A    XXX.XXX.XXX.XXX
git.domain2.com.               IN A    XXX.XXX.XXX.XXX
admin.domain2.com.             IN A    XXX.XXX.XXX.XXX
ftp.domain2.com.               IN CNAME        domain2.com.
*.webmail.domain2.com.                 IN CNAME        domain2.com.
www.domain2.com.               IN CNAME        domain2.com.
*.proofs.domain2.com.          IN CNAME        domain2.instaproofs.com.
domain2.com.           IN MX  10 mail.domain2.com.
domain2.com.           IN TXT  "v=spf1 a mx a:p3plsmtps2ded03.prod.phx3.secureserver.net a:p3plsmtps2ded02.prod.phx3.secureserver.net a:p3plsmtps2ded01.prod.phx3.secureserver.net-all"

Open in new window


And here is domain1.com (which is on the same server, but different ip address..domain2.com is the primary server address BTW)

; *** This file is automatically generated by Plesk ***
$TTL    86400

@       IN      SOA     ns1.domain2.com. server.domain2.com. (
                        1320418811      ; Serial
                        10800   ; Refresh
                        3600    ; Retry
                        604800  ; Expire
                        10800 ) ; Minimum

domain1.com.           IN NS   ns1.domain2.com.
domain1.com.           IN NS   ns2.domain2.com.
domain1.com.           IN A    XX.XX.XXX.XXX
webmail.domain1.com.           IN A    XX.XX.XXX.XXX
mail.domain1.com.              IN A    XX.XX.XXX.XXX
ftp.domain1.com.               IN CNAME        domain1.com.
*.webmail.domain1.com.                 IN CNAME        domain1.com.
www.domain1.com.               IN CNAME        domain1.com.
admin.domain1.com.             IN CNAME        rubix.domain2.com.
domain1.com.           IN MX  10 mail.domain1.com.
domain1.com.           IN TXT  "v=spf1 a mx a:p3plsmtps2ded03.prod.phx3.secureserver.net a:p3plsmtps2ded02.prod.phx3.secureserver.net a:p3plsmtps2ded01.prod.phx3.secureserver.net-all"

Open in new window

BRONZE EXPERT

Commented:
TheCNAME shows that it goes to rubix.domain2.com, not admin.domain2.com

And there is no rubix.domain2.com in domain2.com zone

That's why it doesn't work.  Change the CNAME from rubix -> admin.domain2.com
Greg AlexanderLead Developer

Author

Commented:
That was my mistake in masquerading the domain... they are all supposed to go to that.
BRONZE EXPERT

Commented:
> That was my mistake in masquerading the domain... they are all supposed to go to that.

I don't understand what you just said - your original question stated that you wanted admin.domain1.com to take users to admin.domain2.com - is this no longer the case?

Because the zone file for domain1.com that you just pasted does not support your desired goal.
Greg AlexanderLead Developer

Author

Commented:
Sorry, in my haste, I for got to change rubix. to admin. in the example I gave you... just trying to hide the domain name, I know it is an alias but just trying to be catious so this entire time when I said admin, it is actually rubix, just missed that one when I posted the file
Greg AlexanderLead Developer

Author

Commented:
cautious*
BRONZE EXPERT
Commented:
This concerns me:

admin.domain1.com is an alias for admin.domain2.com.
admin.domain2.com has address xxx.xxx.xxx.xxx
Host admin.domain2.com not found: 2(SERVFAIL)
Host admin.domain2.com not found: 2(SERVFAIL)

Until you are not getting those servfails, this is not going to work.  So I know you're being cautious here, but ultimately, did the error say above that rubix.domain2.com was not found in that SERVFAIL line?

If so, when you added that entry to the domain2.com zone file, did you update the serial and reload it?

Is there any chance you could share with us the real domain/hostnames so that I can at least query the DNS servers and make sure that they are 100% correctly set up for those records?
Top Expert 2011

Commented:
Since he is getting an IP back from the query, perhaps the problem isn't with the admin records.

The NS record for domain2.com does not have an associated A record.  Either change that to ns1.domain2.com and/or ns2.domain2.com or create an A record for ns.domain2.com.

domain2:
domain2.com.           IN NS   ns.domain2.com.
ns1.domain2.com.               IN A    XXX.XXX.XXX.XXX
ns2.domain2.com.               IN A    XXX.XXX.XXX.XXX

Open in new window


domain 1:
domain1.com.           IN NS   ns1.domain2.com.
domain1.com.           IN NS   ns2.domain2.com.

Open in new window

BRONZE EXPERT

Commented:
That's true, it is indeed a bad referral if that is not a typo
SILVER EXPERT
Distinguished Expert 2019

Commented:
could you run the following query
nslookup -q=soa domain2.com
The part I am interested in is the serial number which should be 1319727369 or larger.
Try changing the serial number for domain2.com to a higher number. Often the convention used for Zone serial numbers is to use the date of the change with index i.e. 2011100400 for the first change of the day with each subsequent update incremented by one.  This makes things simpler to diagnose if a change is not propagating, the serial number from the SOA request will show that there is an issue.

can you run the following test in the shell?
named-checkzone domain2.com /var/named/db.domain2.com <this will be the path to the file you have
See if you have an error in the zone that causes changes to be rejected.

domain1.com has ns1 and ns2 on domain2.com, domain2.com has ns.domain2.com as the responsible DNS.  Does this means it was an error or you do not have an ns.domain2.com record?
Greg AlexanderLead Developer

Author

Commented:
The first test returned this:
;; Got SERVFAIL reply from XXX.XXX.XXX.1, trying next server
Server:         XXX.XXX.XXX.2
Address:        XXX.XXX.XXX.2#53

Non-authoritative answer:
domain2.com
        origin = ns.domain2.com
        mail addr = server.domain2.com
        serial = 1319727369
        refresh = 10800
        retry = 3600
        expire = 604800
        minimum = 10800

Authoritative answers can be found from:
domain2.com   nameserver = ns.domain2.com.

Open in new window


The checkzone returned:
zone domain2.com/IN: loaded serial 1319727369

Also something to note is that domain2.com is ther servers default domain... so not sure if that is why there are no ns records... I think it would default anyway... but perhaps because it is the default, maybe it has never been setup right and that is why this whole thing is not workin... anyway just a thought.

SILVER EXPERT
Distinguished Expert 2019

Commented:
use the debug option
host -d alias.domain1.com and see what and where the queries are sent.
Greg AlexanderLead Developer

Author

Commented:
Here is what I get

Trying "admin.domain1.com"
Received 37 bytes from XXX.XXX.XXX.1#53 in 4 ms
Trying "admin.domain1.com"
Host admin.domain1.com not found: 3(NXDOMAIN)
Received 115 bytes from XXX.XXX.XXX.2#53 in 1 ms

Open in new window

Greg AlexanderLead Developer

Author

Commented:
Wait, that may not be accurate... I was meesing around with that CNAME and it may still , work... I made a change so it may take a minute to change
SILVER EXPERT
Distinguished Expert 2019

Commented:
nslookup -debug alias.domain1.com
nslookup -q=soa domain1.com to see whether the serial number in the zone matches the number the nslookup query reflects.

host -C domain1.com will check whether all the referenced name servers have the same serial number.
Greg AlexanderLead Developer

Author

Commented:
I don't know what is happening with admin.domain1.com but I added the CNAME to a different domain on the server and it gives me the same results as when i first started so I know the senerio is the same... it resolves to domain2.com and not admin.domain2.com... I am begining to wonder is it resolves to domain2.com because it is the primary domain on the server and I am thinking it is resolving via DNS instead it maybe resolving because it has no cluse where to go so it defaults.. Anyway the new test you had me run looks like that is the case.. it can't find admin.domain2.com (although you can navigate there in the broweser and it works fine)

Trying "admin.domain1.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29624
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;admin.domain1.com.          IN      A

;; ANSWER SECTION:
admin.domain1.com.   86391   IN      CNAME   admin.domain2.com.
admin.domain2.com.    85465   IN      A       XXX.XXX.XXX.XXX

;; AUTHORITY SECTION:
domain2.com.          85465   IN      NS      ns.domain2.com.

Received 101 bytes from XXX.XXX.XXX.2#53 in 0 ms
Trying "admin.domain2.com"
Received 37 bytes from XXX.XXX.XXX.2#53 in 0 ms
Trying "admin.domain2.com"
Host admin.domain2.com not found: 2(SERVFAIL)
Received 37 bytes from XXX.XXX.XXX.2#53 in 0 ms
Trying "admin.domain2.com"
Received 37 bytes from XXX.XXX.XXX.2#53 in 0 ms
Trying "admin.domain2.com"
Host admin.domain2.com not found: 2(SERVFAIL)
Received 37 bytes from XXX.XXX.XXX.2#53 in 0 ms

Open in new window

Greg AlexanderLead Developer

Author

Commented:
the serial numbers match
Top Expert 2011

Commented:
Please follow the instructions from http:#37085699
SILVER EXPERT
Distinguished Expert 2019

Commented:
The problem is that we have no way to see for ourselves what is going on and rely on you to perform the tasks.
The latest response includes info admin.domain1.com CNAME admin.domain2.com
admin.domain2.com IP x.x.x.x

Did you use the HOST -C option?  It may mean that when it tried to check with ns.domain2.com that is when the failures occurred.

Make sure the zones you have are accurate i.e. NS records point to valid/existing  Name servers.
If this is a public domain, make sure to use your register interface to register the Name Servers.
ns.domain2.com
ns1.domain2.com
ns2.domain2.com.
Greg AlexanderLead Developer

Author

Commented:
@Papertrip

Added an A record for the ns.domain2.com and nothing changed, I also tried adding changing it to ns1 and that did nothing either..... Its gotta be how domain2.com is handling the request because I can send the CNAME to google.com and it works fine... just for a test I changes the alias to test.domain1.com to go to domain3.com (which is another domain on the server) and I get a default plesk page and I have no idea where is is actually resolving :( because it is not domain3.com
SILVER EXPERT
Distinguished Expert 2019

Commented:
nslookup -debug admin.domain1.com
This should tell you what queries are being made and where they are sent.
Greg AlexanderLead Developer

Author

Commented:
 QUESTIONS:
        admin.domain1.com, type = A, class = IN
    ANSWERS:
    ->  admin.domain1.com
        canonical name = admin.domain2.com.
    ->  admin.domain2.com
        internet address = XXX.XXX.XXX.162
    AUTHORITY RECORDS:
    ->  domain2.com
        nameserver = ns.domain2.com.
    ADDITIONAL RECORDS:
    ->  ns.domain2.com
        internet address = XXX.XXX.XXX.162

Open in new window


Why is it going to domain2.com instead of admin.domain2.com towards the end?
SILVER EXPERT
Distinguished Expert 2019

Commented:
domain2.com is the zone where admin.domain2.com is
it responded with the IP for admin.domain2.com as being xxx.xxx.xxx.162

You need to make sure that admin.domain1.com is defined within the web server in the same section where admin.domain2.com is as it seems you are using host headers.
The CNAME only tells the browser the address, but the browser is still making the request to the webserver for admin.domain1.com and if the host header does not match, the default or the first site in the list will be presented for such a request.

within plesk, you need to add admin.domain1.com as an option where admin.domain2.com is.
Greg AlexanderLead Developer

Author

Commented:
within plesk, you need to add admin.domain1.com as an option where admin.domain2.com is.

Not clear on that... does that mean I need to add a record in the DNS settings for domain2.com? If so then what kind of record should it be?
SILVER EXPERT
Distinguished Expert 2019
Commented:
NO. at this point going to admin.domain1.com should get you to the web server where admin.domain2.com is, but the request for admin.domain1.com to that web server can not be answered as you want i.e. with the same web site as admin.domain2.com.  IT currently provides the wrong web site.
To correct the presentation of the wrong web site when a request is made for admin.domain1.com requires that the web server reflect that admin.domain1.com should be handled the same way admin.domain2.com is.

If you can look at the web logs, you should see a request for admin.domain1.com.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.