A records not found; non-www isn't working

Lee asked:

I recently setup bind on CentOS and want to redirect the non-www to www part of the site.

Currently the www works, but when I try the bare domain from Safari I get: Can’t open http://mydomain.com because the server can’t find mydomain.com.

My zone file looks like this: (without the $TTL part below)

                IN NS         ns1.mydomain.com.
                IN A          [ip here]

      ns1       IN A          [ip here]

      @         IN MX 10      aspmx.l.google.com.
      @         IN MX 20      alt2.aspmx.l.google.com.

      *         IN CNAME      [ip here]

IntoDNS reports at “WWW A Record” section:

ERROR: I could not get any A records for mydomain.com!

When I try * IN A [ip] I get the following error:

      Stopping named:                                            [  OK  ]
      Starting named: 
      Error in named configuration:
      zone localhost/IN: loaded serial 42
      dns_master_load: /var/named/mydomain.com.zone:19: *.mydomain.com: CNAME and other data
      zone mydomain.com/IN: loading from master file /var/named/mydomain.com.zone failed: CNAME and other data
      zone mydomain.com/IN: not loaded due to errors.
      _default/mydomain.com/IN: CNAME and other data
                                                                 [FAILED]

But IN A [ip] – without * – works (as it was above).

My answer:


To make example.com resolve to an IP address, add an A record for @.

@               IN      A       198.51.100.250

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.