What is MIME type "text/dns"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

text/dns is a MIME type used for text files that store DNS zone information. These files hold the configuration data for the Domain Name System. They list records such as A, MX, NS, and others that define how domain names resolve to IP addresses.
This MIME type is primarily used for zone files like ZONE files. They are plain text files, which means you can open and edit them with any text editor.
It provides a common format for applications to share and interpret DNS settings. For more details, check the official listing on the IANA website.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/dns    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/dns">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/dns');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What is the text/dns MIME type used for?

The text/dns MIME type identifies files containing Domain Name System (DNS) resource records, commonly known as zone files. These files map domain names to IP addresses using records like A, MX, and CNAME to configure how traffic is routed on the internet.

How do I open or edit a file associated with text/dns?

Since these are plain text files, you can open them with any standard text editor such as Notepad, TextEdit, or Sublime Text. While they are readable by humans, strict syntax rules must be followed so that DNS server software can parse them correctly.

How do I configure Apache to serve .zone files as text/dns?

You can map the extension by adding the line AddType text/dns .zone to your .htaccess file or main server configuration. This ensures that when a client requests a .zone file, the server correctly identifies the content type.

Is it safe to make text/dns files publicly accessible?

Generally, no. Exposing raw zone files can reveal your entire network topology, including internal subdomains and IP addresses, which can aid attackers in reconnaissance. It is best practice to block public web access to these configuration files.

Will web browsers display text/dns content?

Yes, most modern browsers will render text/dns files as plain text directly in the browser window. However, depending on specific server headers like Content-Disposition, the browser might prompt you to download the file instead.

What is the difference between text/dns and text/plain?

While both are technically plain text, using text/dns provides semantic meaning to the file, indicating it follows the specific syntax of DNS zone configurations (like RFC 1035). This allows IDEs and specialized tools to apply correct syntax highlighting and validation.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.