Redirecting all subdomains to a certain IP

AndyB78

Well-Known Member
Oct 7, 2003
79
2
158
Romania
cPanel Access Level
Root Administrator
Hello,

I was wondering if I can set things up so that all subdomains for a specific domain would be redirected to another IP.

I believe I have to make some setings in the DNS zone (like "* 14400 IN A new_ip") plus some settings in httpd.conf.

Can someone help me with the specific steps?

Thanks and regards!
 

InstaCarma_Tech

Well-Known Member
Apr 22, 2009
227
1
68
* is normally used for setting. wild card DNS. This means that if somebody tries to access a non-existent subdomain on that domain, then also they will be re-directed to that IP. Are you sure you want to do this? Else, manually editing the DNS zone and pointing individual sub-domain A record to that IP would be a better idea.
 

AndyB78

Well-Known Member
Oct 7, 2003
79
2
158
Romania
cPanel Access Level
Root Administrator
Well the customer has requested this so I suppose this is what I should do. Besides the DNS zone should I change anything else?

But more important: in the DNS zone would the wildcard "overwrite" all other records like the mail. CNAME etc?

Regards!
 
Last edited:

mickbeng

Well-Known Member
Oct 3, 2006
56
0
156
Penang, Malaysia
wildcard DNS record should not be able to overwrite the other record existed from your database records.

I believe that it is hard to done this except you could make the subdomain would not create the DNS entry.:D
 

madaboutlinux

Well-Known Member
Jan 24, 2005
1,051
2
168
Earth
Well the customer has requested this so I suppose this is what I should do. Besides the DNS zone should I change anything else?

But more important: in the DNS zone would the wildcard "overwrite" all other records like the mail. CNAME etc?

Regards!
CNAME and MX records won't be effected. If you want to change the A record of the selected sub-domains, you need to set them in the DNS zone of the domain. If you wish to set the wildcard entry, you need to set them in the DNS zone as well as in the VirtualHost of the domain.

DNS Zone:
* IN A WhateverIP

VirtualHost entry:
ServerAlias *.yourdomain.tld
 

mickbeng

Well-Known Member
Oct 3, 2006
56
0
156
Penang, Malaysia
CNAME and MX records won't be effected. If you want to change the A record of the selected sub-domains, you need to set them in the DNS zone of the domain. If you wish to set the wildcard entry, you need to set them in the DNS zone as well as in the VirtualHost of the domain.

DNS Zone:
* IN A WhateverIP

VirtualHost entry:
ServerAlias *.yourdomain.tld
You should run this if you manually change the VirtualHost entry.
/usr/local/cpanel/bin/apache_conf_distiller --update