Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Web redirection by bind(CNAME)

Posted on 2008-11-17
38
Medium Priority
?
1,040 Views
Last Modified: 2013-12-16
HI,
From bind i am trying to redirect the web request from this domain abc.com to xyz.com
dont know if it will work or not.

i know , i can setup A record for the webserver or from apache i can redirect or even by using redirect script ( php or asp)

but I am just doing Dns management for the domain, and the client is not paying me for hosting.and he want me to redirect all the traffic request  to another web site

i got this one : http://www.experts-exchange.com/Networking/Protocols/DNS/Q_22921515.html

but its not really clear
so can any one tell me, is this possible by CNAME ??

 
0
Comment
Question by:fosiul01
  • 15
  • 13
  • 10
38 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 22979543
setting CNAME only will not change the http host header required for name based virtual hosts(majority).
So unless the target www is IP based virtual host - CNAME will not work.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22979588
ommmm problem is


if i type : http://56.555.66.55 the web site will not come

thats the problem, other wise, i would of just change the A record to that IP

do you mean this ??
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22979702
I'm not following?
In fact, if xyz.com is nameBasedVirtualServer - no matter A or CNAME You set - it will not work.
You either need to send proper HTTP redirect, or ask xyz.com to add abc.com as alias of xyz.com in the webserver configuration.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Author Comment

by:fosiul01
ID: 22979754
yes, i will be responsible for xyz.com

and any trafiq is comming to xyz.com will be redirect to abc.com


your comments : " ask xyz.com to add abc.com as alias of xyz.com in the webserver configuration."  -> how will i do this ??

can i not do this from zone file ?? ( as i said, client is not paying me for hosting, so i am not configuring webserver for them )
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22981645
You can add in the domain records with CNAMEs.

you have an A record for xyz.com and then point
xyz.com (and www.xyz.com) to the A record

abc.com                IN      A      60.70.80.90
xyz.com                IN      CNAME   abc.com
www.xyz.com       IN      CNAME   abc.com

When the traffic arrives at abc.com they need to set up the server to accept that domain name or it will fall through to the default vhost.
They just need to add a doaminalias to the httpd.conf file on that vhost
(or add a parked domain in plesk / cpanel)




0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22982745
The option under apache's config is

<VirtualHost www.xyz.com:80>
ServerName www.xyz.com
ServerAlias xyz.com www.abc.com abc.com
...
</VirtualHost>
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22982838
HI yah sorry due to night didnot able to reply.

as i am saying, I dont have control to abc.com , but i have full control on xyz.com

and any trafiq will come to xyz.com will redirect to abc.com

now as edster9999 said, if create just  cname, will it work ??
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983017
I said creating a cname will redirect the traffic.  Thing of it as a forwarding address for a domain name.  if they go to www.xyz.com it will look up the dns address and get the ip address for the record the cname point to.
All the traffic will then go to that server.

BUT on that server there is nothing to receive the traffic as it will still say 'www.xyz.com' on the URL so someone needs to add the doaminalias line (or park that domain which does the same thing) as above.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983048
omm you  wait, i am confused too much

let me tell you then explain me please.


I am responsible for xyz.com domain. so in xyz.com.zone file i will insert this :

abc.com                IN      A      60.70.80.90
xyz.com                IN      CNAME   abc.com
www.xyz.com       IN      CNAME   abc.com

so as you saying : any trafiq comes to www.xyz.com    will be redirect to abc.com  , right ??    [ but why i will have add the doamin list in abc.com ??]  
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983091
In the above scenario You have definied
abc.com.xyz.com as 60.70.80.90
xyz.com.xyz.com as cname to abc.com.xyz.com
www.xyz.com.xyz.com as cname to abc.com.xyz.com

anyway, even if You properly configure those A/CNAMEs, nobody will see them - they will not ask Your nameserver, but the one responsible(authoritative) for abc.com domain.

> so as you saying : any trafiq comes to www.xyz.com    will be redirect to abc.com  , right ??
No, to the IP of abc.com. What will do with this the wwwserver on abc.com it depends on it's config.
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 1400 total points
ID: 22983107
> anyway, even if You properly configure those A/CNAMEs, nobody will see them - they will not ask Your nameserver
correction - it's only about A record. Your nameserver will probably send a hint, but clients should reject it, as Your nameserver is not auth for abc.com domain.
0
 
LVL 20

Assisted Solution

by:edster9999
edster9999 earned 600 total points
ID: 22983145
Sorry - ravenpl is correct.  You do not need the abc.com 'a' record if you are not controling that.  I messed that bit up and though you were running that system.

So just set up cnames for the xyz domain to go to the abc.com domain and it will get the a record from them.  The rest of the stuff about serveralias / domain parking still stands.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983152
omm  both of you send me 2 different configuraiton one said : abc.com                IN      A      60.70.80.90 and other one is abc.com.xyz.com as 60.70.80.90  but  i have tryed with both solution in zone file, but still it does not work.

ravenpl , can you please explain me what you meant by this ? "No, to the IP of abc.com. What will do with this the wwwserver on abc.com it depends on it's config."

[ as i said, i can forward by using apache or programming but i dont want to do that ]  here, abc.com will not do anything. and also i dont have any access to abc.com  , only i have access to xyz.com
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983168
ok you saying, aftter doing Cname for xyz.con.zone file, still i  will have to request abc.com autority to allow web request from xyz.com ??
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983180
C'on - I havent sent You any config, but explained that Yours is wrong.

> ravenpl , can you please explain me what you meant by this ?
What web browser do if You enter xyz.com? determines it's IP, follows any CNAMES. So it gets the ip of abc.com but still sends the http Host: header as xyz.com. The webserver on abc.com tries to match the xyz.com to one of those virtualHosts - but no match there! Usually webservers are configured to display "not found" message or display the default virtualHost(whatever it is).

So either You have to redirect it with Your webserver/script or ask abc.com webmaster to add xyz.com as an alias of abc.com virtualHost.
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983192
ok here is an example file for
xyz.com.conf :
; zone file for xyz.com
$TTL 2d    ; 172800 secs default TTL for zone
@             IN      SOA   ns1.xyz.com. hostmaster.xyz.com. (
                        2008111800 ; se = serial number
                        12h        ; ref = refresh
                        15m        ; ret = update retry
                        3w         ; ex = expiry
                        3h         ; min = minimum
                        )
              IN      NS      ns1.xyz.com.
NS1           IN      A       50.60.70.80    ;   <-  This is your Nameserver
@             IN      CNAME   abc.com
www           IN      CNAME   abc.com

Open in new window

0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983196
ok so in my case, adding CNAMe in xyz.com.zone file it not a solution ??

is not it ??
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983205
fixup to the bind config

@             IN      CNAME   abc.com.
www           IN      CNAME   abc.com.

> ok so in my case, adding CNAMe in xyz.com.zone file it not a solution ??
It's not all. Maybe it is, if the abc.com is not nameBased virtualHost - unlikely.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983216
hahahahah hahahahahahahah

at my very first comment is said,  

if i type : http://56.555.66.55 the web site will not come

if they would of define Ip for this abc.com ,then i would not ask so many question, but its name based hosting, thats why i am confused ,what to do!!
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983263
Already explained what need to be done.
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983264
you need two things.

On your DNS server a cname to point the traffic for xyz.com -> their server

On their server an entry in the httpd.conf file to show the page to people using xyz.com as the url
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983277
ok i have added this 2 lines in xyz.co.uk.zone file


@                       IN CNAME xxxcollection.co.uk.
www                     IN CNAME xxxcollection.co.uk.


when i am restarting the named  its giving me error


dns_master_load: xyz.co.uk.zone:13: xyz.co.uk: CNAME and other data
dns_master_load: xyz.co.uk.zone:13: xyz.co.uk: CNAME and other data
dns_master_load: xyz.co.uk.zone:13: xyz.co.uk: CNAME and other data
zone xyz.co.uk/IN: loading master file xyz.co.uk.zone: CNAME and other data
_default/xyz.co.uk/IN: CNAME and other data
zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
zone 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 1997022700
zone 255.in-addr.arpa/IN: loaded serial 42
zone 0.in-addr.arpa/IN: loaded serial 42
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983287
I dont think it has a dot on the end
(a bit like my example above he he he)
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983309
That's correct - You can't have
www IN CNAME something
www IN A 1.2.3.4

same applies to @ - can You bring here whole zone config file?
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983321
without . its still same
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983331
$TTL 14400
@ 86400   IN      SOA     ns1.ityou.co.uk. ns2.ityou.co.uk. (
                2008021501      ; serial
                86400           ; refresh
                7200            ; retry
                3600000         ; expire
                86400 )         ; minimum

                        IN NS ns1.ityou.co.uk.
                        IN NS ns2.ityou.co.uk.
                        IN MX 10  mail.web4u.co.uk.
                        IN MX 20  mail1.web4u.co.uk.
@                       IN CNAME elcollection.co.uk
ns1                     IN A 78.xx.xx.196
ns2                     IN A 78.xx.xx.135
www                     IN CNAME elcollection.co.uk

so when trafiq will come to web4u it will redirct to elcollection.co.uk

[here web4u and elcollection is imaginary domain ]

0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983357
No, You need the dot at the end! See my fixup message. Why will not You listen?
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983372
I didnot put . !! where are u seeing i put . ??

@                       IN CNAME elcollection.co.uk

www                     IN CNAME elcollection.co.uk

0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983391
ok i have removed every .

$TTL 14400
@ 86400   IN      SOA     ns1.ityou.co.uk ns2.itou.co.uk (
                2008021501      ; serial
                86400           ; refresh
                7200            ; retry
                3600000         ; expire
                86400 )         ; minimum

                        IN NS ns1.itou.co.uk
                        IN NS ns2.ityou.co.uk
                        IN MX 10  mail.web4u.co.uk
                        IN MX 20  mail1.web4u.co.uk
;@                      ; IN ;CNAME ;elcollection.co.uk   [ I tryed both]                    
@                       IN CNAME 62.253.216.10      [ I tryed both]
ns1                     IN A 78.xx.xx.196
ns2                     IN A 78.xx.xx.135
www                     IN CNAME elecollection.co.uk

same thing, named is giving error as i past earlier
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983500
You not reading my comments, are You?
- You need the dot in "?? IN CNAME elecollection.co.uk."
- You cannot have both CNAME and other records for @, basically You cannot have CNAME for @ (according to rfc)
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983535
hahah ok i am mixing your comments with you edstrr ..

ok this is my zone file now

if its still wrong, can you just edit the zone file and past here please

$TTL 14400
@ 86400   IN      SOA     ns1.ityou.co.uk. ns2.ityou.co.uk. (
                2008021501      ; serial
                86400           ; refresh
                7200            ; retry
                3600000         ; expire
                86400 )         ; minimum

                        IN NS ns1.ityou.co.uk.
                        IN NS ns2.ityou.co.uk.
                        IN MX 10  mail.web4u.co.uk.
                        IN MX 20  mail1.web4u.co.uk.
@                       IN CNAME elecollection.co.uk.
ns1                     IN A 78.xx.xx.196
ns2                     IN A 78.xx.xx.135
www                     IN CNAME eleecollection.co.uk.

and named is still giving same error with CNAME
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983607
> @                       IN CNAME elecollection.co.uk.
You cannot have this... It would delegate whole domain to elecollection.co.uk - but You adding next records - this is invalid.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22983640
ok so this is final one


$TTL 14400
@ 86400   IN      SOA     ns1.ityou.co.uk. ns2.ityou.co.uk. (
                2008021501      ; serial
                86400           ; refresh
                7200            ; retry
                3600000         ; expire
                86400 )         ; minimum

                        IN NS ns1.ityou.co.uk.
                        IN NS ns2.ityou.co.uk.
                        IN MX 10  mail.web4u.co.uk.
                        IN MX 20  mail1.web4u.co.uk.

ns1                     IN A 78.xx.xx.196
ns2                     IN A xx.110.xx.135
www                     IN CNAME eleollection.co.uk.

with this named restart well.
but the purpose i was trying to solved it does not work. so i guess, i will have to use apache then for forwarding is not it ???

;
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983877
I think that one is pretty much correct.

I still say you can add :

*     IN     CNAME    eleollection.co.uk.

I've swapped to '*' as I was looking in my bind files and this is what I have.  I think you can use * or @ interchangeably at this point but I'm swapping to '*' as that might help you. (maybe)

The only records that disagree with this are NS1 and NS2.  These have already been defined up at the .com level as the nameservers.  having them in this file is just a 'cover every base' option.  It is the correct thing to do but by the time you get to this box to look that up you already know it as you... got to the box in the first place.

If you define other records in the zone file I think they are excluded from the '*' everything clause.  It may not be in the original spec but I have used this and lots of other poeple do and it seems to work with all modern clients.
Try it and see.
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983889
Oh one correction.  The top line :

@ 86400   IN      SOA     ns1.ityou.co.uk. ns2.ityou.co.uk

the last entry should be an email address with the '@' sign changed to a dot.

@ 86400   IN      SOA     ns1.ityou.co.uk. postmaster.ityou.co.uk

would be more correct.... although this is just layout and is not used for anything so it is not causing any problems here.
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983892
Opps and it should have a dot after it (sorry)

@ 86400   IN      SOA     ns1.ityou.co.uk. postmaster.ityou.co.uk.    (

0
 
LVL 43

Expert Comment

by:ravenpl
ID: 22983900
Note: the asterisk does not apply to the @ itself :(
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22983918
which is fine as that does not contain the server names we want to redirect.

Please give it a try.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question