Helpful Information
 
 
Category: Apache Development
DNS - Configuring subdomains

I am trying to configure a subdomain.
I have a freebsd/apache machine.

The jist of my question is... I just can't seem to get it to go right.. how do you set this up?

Currently I modify /etc/namedb/mydomain.com.db file, adding the subdomain in this manner:

subdomain.domainname.com. IN A 111.111.111.1
#(not actual ip obviously)

Ive also tried it using the above and a cname record
IN CNAME subdomain.domainname.com.

and several other types of configurations

I also added the subdomain to my /etc/namedb/named.conf file, making it a master and refering it to the domain.com.db file mentioned above.

It seems to almost work, but maybe someone can point me in the right direction, or point out my error.

Thanks in advance,

Chuck

You can have multiple A record pointing to the same IP or multiple CNAME with at least one A record, both should work. Or you can even have a wildcard A record plus your default A record.

Anyhow, you need to ensure forward nslookup of your subdomain.domainname.com returns the same IP (111.111.111.1) before going any further to configure Apache.

If you need further helps, be sure to provide more info (not enough currently).

Thanks for the reply freebsd.

I have a machine with primary & 2nd dns (although I dont use the 2nd as far as I know, at this time), on that machine are my sites.
I'll just explain my set up and hopefully the error will glare.

Using 111.111.1.245 as dns for myserver.com
111.111.1.5 as MX
111.111.1.100 as ip for mydomain.com
111.111.1.200 as ip for subdomain.mydomain.com


In my http.conf file my entries refering to this site are:

<VIRTUALHOST 111.111.1.100>
DocumentRoot /var/www/public_access/mydomain.com
ServerName mydomain.com
</VIRTUALHOST>

<VIRTUALHOST 111.111.1.200>
DocumentRoot /var/www/public_access/subdomain.mydomain.com
ServerName subdomain.mydomain.com
</VIRTUALHOST>

#######
## NOTE: If i ping either mydomain.com or subdomain.mydomain.com It will go to 111.111.1.100 (to mydomain.com)
###########

In my named.conf file, among the other normal entries, are the entries for these sites.

zone "mydomain.com" {
type master;
file "dbs/mydomain.com.db";
};

zone "subdomain.mydomain.com" {
type master;
file "dbs/mydomain.com.db";
};

###I have one .db file, as shown above, and that is for mydomain.com at mydomain.com.db. I refer subdomain.mydomain.com to this same db.

The name server entries for that .db are as follows (the normal stuff, refresh, retry, expire, etc are all there as well, these are just the entries below that):

IN NS ns1.myserver.com.
IN NS ns2.myserver.com.
IN A 111.111.1.100
IN MX 10 mail.mydomain.com
www IN A 111.111.1.100
ftp IN A 111.111.1.100
mail IN A 111.111.1.5
* IN A 111.111.1.100
subdomain.mydomain.com. IN A 111.111.1.200
subdomain. IN A 111.111.1.200

###I noticed in the post preview that this board scrunches my entries, sorry if the IN records are difficult to read.

Freebsd, hopefully this is enough for you and thanks once again!

>> If i ping either mydomain.com or subdomain.mydomain.com It will go to 111.111.1.100 (to mydomain.com)

1) * IN A 111.111.1.100
2) subdomain.mydomain.com. IN A 111.111.1.200

*.mydomain.com matches subdomain.mydomain.com so need to give (2) higher priority by moving it higher, as high as the first A record.










privacy (GDPR)