1)
I was following a guide to setup bind again after I formatted to Ubuntu 10.04.2 LTS.

I can get my domain example.com to resolve but I want "www.example.com" to resolve to the actual domain on the web.

I don't have a webserver setup on my domain at the moment so I would rather it resolve properly.

So "ping example.com" works and resolves to my local address but "ping www.example.com" gives "ping: unknown host www.example.com".

Here is the file ,

;
; BIND data file for example.com
;
$TTL    604800
@       IN      SOA     ns.example.com. root.example.com. (
                              9         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.example.com.
@       IN      A       10.11.12.1
;www    IN      A       10.11.12.1
ns      IN      A       10.11.12.1

I tried adding in a www entry but it only resolves to the same local ip as example.com so I commented it out.


2)
I am planning on adding all of the urls from the ad block site http://winhelp2002.mvps.org/hosts.txt to bind so as to block them on my network.

So how would I add this list to bind?

Dani AI

Generated

Brief, practical follow‑ups for that build on 's points.

DNS vs HTTP: DNS only gives a name an IP. Creating a DNS record for "www" so it resolves to the same IP as the apex is normal and harmless — it only makes the name resolvable. Making browsers change the visible URL (for example redirecting http://www.example.com to http://example.com) requires an HTTP redirect served by a webserver or a redirect service; DNS cannot perform an HTTP redirect.

Making the DNS change stick (checklist)

  • Edit the zone, bump the SOA serial (use a clear scheme like YYYYMMDDnn).
  • Validate the file before reload: run the zone/config checks.
  • Reload BIND (or rndc reload) and inspect logs for errors.
  • Test directly against the nameserver (use dig/nslookup against the server IP) and clear any client DNS cache if results differ.

Example commands to validate/reload and test:

named-checkzone example.com /etc/bind/db.example.com
named-checkconf
sudo rndc reload
dig @127.0.0.1 www.example.com +short

Blocking large hosts lists

  • For a few machines, editing each client hosts file is simplest. For a LAN, dnsmasq can ingest a hosts-format file centrally (lightweight) and is easy to update.
  • For BIND, two approaches: (a) generate a single zone with many A records that point blocked names to a sinkhole IP, or (b) use BIND Response Policy Zones (RPZ) if your BIND supports it — RPZ is cleaner and scales better because it rewrites/blocks responses without creating thousands of zones.
  • If you convert a hosts.txt file into DNS A records, map to a sinkhole IP appropriate for your network. Avoid mapping everything to each client’s loopback (127.0.0.1) because that sends clients to themselves; 0.0.0.0 or an internal blackhole address are common alternatives.

Operational tips

  • Automate rebuild + validation + reload (cron) so the blocklist updates safely.
  • Remember DNS blocking won’t prevent TLS/HTTPS certificate errors or stop trackers embedded in other domains; test changes from multiple clients and watch DNS TTLs and caching behavior.

Hi Shwick!

"I tried adding in a www entry but it only resolves to the same local ip as example.com"

^This is the expected behavior here. On the web server side of things, you would want to make sure that apache (or your web server of choice) resolves both example.com and www.example.com to the same place.

The OTHER option you might be looking for is a 'CNAME' record. Try something like: www IN CNAME example.com. The list you linked is in the format of a 'hosts' file. You don't need to run BIND for that, you can simply add the entire list to your /etc/hosts file on any client machine (/windows/system32/drivers/etc/hosts on windows).

BUT if you want to add the list to BIND and point your clients to that server for DNS resolution, that would work too. You would do it the same way you added your example.com zone. Once you have the steps down, you could probably script it pretty easily, or you might be able to find an existing script to create the zones for you.

I hope this helps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.