2

I'm trying to foward some domains to another. The scenario is quite easy:

  • domain example.com is the primary domain

  • the domain example.net should be forwarded to example.com

  • all set up subdomains should be as well

As a DNS, my machine is running bind and my configs look like this:

named.conf:

zone "example.com" {
     type master;
     file "/etc/bind/db.example.com";
     notify yes;
     allow-transfer{
         208.79.240.3;
         208.79.241.3;
     };
};

zone "example.net" {
     type master;
     file "/etc/bind/db.example.net";
     notify yes;
     allow-transfer{
         208.79.240.3;
         208.79.241.3;
     };
};

db.example.com:

$TTL    1d
@   IN      SOA     ns.example.com.   dns.example.com.  (
                                    2012021204      ;serial
                                    8H      ; refresh
                                    2H      ; retry
                                    4W      ; expire
                                    1D)     ; minimum
                        IN      NS      ns
                        IN      NS      ns1.rollernet.us.
                        IN      NS      ns2.rollernet.us.
ns                      IN      A       78.46.106.248
ns1.rollernet.us.       IN      A       208.79.240.3
ns2.rollernet.us.       IN      A       208.79.241.3

@                       IN      MX      10      mail
@                       IN      MX      100     mail.rollernet.us.
@                       IN      MX      100     mail2.rollernet.us.
@                       IN      A       78.46.106.248
mail                    IN      A       78.46.106.248
www                     IN      A       78.46.106.248

db.example.net

$TTL    1d
@   IN      SOA     ns.example.net.   dns.example.net.  (
                                       2012021208      ;serial
                                       8H      ; refresh
                                       2H      ; retry
                                       4W      ; expire
                                       1D)     ; minimum
                        IN      NS      ns.example.com.
                        IN      NS      ns1.rollernet.us.
                        IN      NS      ns2.rollernet.us.
ns                      IN      A       78.46.106.248
ns1.rollernet.us.       IN      A       208.79.240.3
ns2.rollernet.us.       IN      A       208.79.241.3
@                       IN      A       78.46.106.246
mail                    IN      CNAME   mail.example.com.
www                     IN      CNAME   www.example.com.

The forwarding works fine so far and all access to (www.)example.net is forwarded to (www.)example.com.

The only thing I am missing is that the address bar in my browser is not switching to (www.)example.com when I'm accessing (www.)example.net. How can I make this happen?

nonbeing
  • 198
  • 1
  • 6
Moritz
  • 129
  • 1
  • 1
  • 2

3 Answers3

2

If you want to simply go to the same IP address, then a simple CNAME will suffice.

But I gather you want to actual redirect, so you will have to use http redirect. Through Bind/dns redirect is not possible.

Since this is a simple catch all redirect then with apache it is a simple as these couple of lines:

 <VirtualHost *:80>
   ServerName example.net
   ServerAlias www.example.net *.example.net
   Redirect permanent / http://www.example.com/
 </VirtualHost>
Jay Chakra
  • 103
  • 3
flurdy
  • 545
  • 4
  • 8
1

Not via DNS. What you want is a URL redirect, possibly via HTTP.

al.
  • 915
  • 6
  • 17
  • He specifically does not want the URL to change. This means he needs either a proxy or duplicate DNS records. – adaptr Feb 13 '12 at 11:19
  • No, actually I want the URL to change in the addressbar. I just thought that'd be possible with DNS as well. Guess I have to switch to a mod_rewrite solution then. – Moritz Feb 13 '12 at 16:30
0

You can't.

If both domains need to end up at the same machine, then both domains need to contain identical A records for their respective labels.

If the data in the zone file is all relative, you can use the same zone file for both zones.

adaptr
  • 16,479
  • 21
  • 33