Skip to main content

Add DNS Records

When you change your domain's NS values to the ones provided by Arvancloud, Arvancloud DNS is activated for your domain, and all of the domain's DNS records must be entered in your panel so Arvancloud can resolve them and your domain and all its subdomains open without problems.

To add DNS records, you need to be familiar with the types and values appropriate for each record and know how to add them in the panel.

A and AAAA Records​

These records contain the IP address of a domain. They store a domain name and the IP address of the physical server that hosts that domain's content. Note that this physical server means the origin server hosting your site.

Name: This field contains the name of your site's domain or subdomain. Using the @ character in this field refers to your root domain. The domain name entered in this field must meet the following rules:

  • The domain name must start with a letter or number, not a special character (such as #, $, etc.).
  • The domain name can end with a letter or number.
  • Special characters (such as @, $, etc.) cannot be used in the domain name.
  • A domain name can be up to 63 characters long.

Value: This field contains the IP address of the origin server hosting your site.

TTL: Specifies how long this record can be cached on Arvancloud servers. By default, this value is 2 minutes, meaning that if you change a DNS record, it takes 2 minutes for the change to apply everywhere.

To add an A record via API, you can use the following request:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"type":"A","name":"test","cloud":false,"value":[{"country":"","ip":"8.8.8.8","port":null,"weight":null}],"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

If the origin server hosting your site has an IPv6 address, you need to use an AAAA record. In the records management section, set the record type to AAAA, enter the domain or subdomain in Name, and enter the server's IPv6 address in Value.

To add an AAAA record via API, you can use the following sample request:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"type":"AAAA","name":"test","cloud":false,"value":[{"country":"","ip":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","port":null,"weight":null}],"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

CNAME and ANAME Records​

A CNAME record sends requests for one domain name to another domain name. For example, if a user enters example.com in their browser, their request is sent to the example1.com domain. This record does not point directly to an IP address.

To define this record, enter in Name the domain or subdomain that users' requests are first sent to, and in Value the domain name that users' requests should be forwarded to.

To add a CNAME record via API, you can use the following request:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"type":"CNAME","name":"test","cloud":false,"value":{"host_header":"source","host":"cname.example.com","port":-1},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

An ANAME record can be thought of as a combination of an A record and a CNAME record. Its only difference from CNAME is in how it works: it maps a domain directly to another IP address.

To send requests for the root of a domain (the root domain) to another domain, you need to use an ANAME record.

To add an ANAME record via API, you can use the following sample request:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"type":"ANAME","name":"test","cloud":false,"value":{"host_header":"source","location":"aname.example.com","port":-1},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

NS Record​

An NS record specifies the DNS server where all records related to a domain are stored. A domain can have several NS records, one of which points to the primary DNS server and the others to the backup DNS servers of that primary server.

Note that you only need to define this record in the records management section of the Arvancloud panel in special cases.

To add an NS record via API, you can use the following sample request:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"type":"NS","name":"ns","cloud":true,"value":{"host":"ns1.example.com"},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

MX Record​

This record specifies the email server that a domain's emails should be sent to.

This record must always point to a domain name, not an IP address.

To set this record, enter the subdomain name or the @ character for the root domain in Name, and in Value enter the domain name of the provider you get your email service from. If you have several email servers, you can define several MX records and use the Priority field to specify which email server has higher priority.

Adding an MX record via API:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data-raw '{"type":"MX","name":"@","cloud":true,"value":{"host":"mail.example.com","priority":"10"},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

You can then use the dig command to check that the MX record is published correctly.

SRV Record​

An SRV record specifies the host that supports a specific service. To define this record in DNS Records, set the record type to SRV, enter Name in the form _service._proto.example.com (for example: _sip._tcp.example.com), enter the port number the service is running on in the Port field, and enter a string in the form exampledomain.com in Value. If you want to define several SRV records, you can also use the Weight and Priority fields as needed.

An SRV record specifies the priority and weight of the servers listed in it. The priority value in an SRV record lets you prioritize one server that supports a specific service over the other servers. The server assigned a lower priority value receives more traffic than the other servers. Weight works in a somewhat similar way: among several servers with the same priority, the server with a higher weight receives more traffic.

The main difference between weight and priority is that when traffic passes through, priority is checked first. If the priorities of the servers differ, weight is not considered, and traffic goes to the server with the lower priority value. When two or more servers have the same priority, weight also matters. In that case, after checking the servers' weights, the server with the higher weight receives the most traffic.

Adding an SRV record via API:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"type":"SRV","name":"_http._tcp.","cloud":true,"value":{"port":"80","priority":"0","target":"example.com","weight":"50"},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

TXT Record​

A TXT record can contain text used for various purposes, the most important of which is mail authentication and defining SPF and DKIM records. When defining this record, set the record type to TXT, enter @ (which refers to your root domain) in Name, and enter a text string in Value.

Adding a TXT record via API:

curl --location 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json' \
--data '{"type":"TXT","name":"txt","cloud":false,"value":{"text":"text-record"},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

CAA Record​

The CAA record was developed to prevent unauthorized security certificates from being issued for a domain. With this DNS record, you can specify which certificate authority (CA) can issue a certificate for the domain. This increases security and integrity in an organization.

To add a sample record in the Arvancloud panel, select the domain in your panel, click DNS Records, and create a new CAA record.

  • In Name, enter your domain name. If the record is for the root of the domain, enter "@" in the Name field; if it is for a specific subdomain, enter only its name.
  • In Tag, specify the DNS behavior for the record. This tag accepts three states:
    • Only Allow Specific Hostnames: The CAA record is valid only for a specific hostname (the hostname entered in Name).
    • Only Allow Wildcard: The CAA record is valid for the whole domain, including the root of the domain and all its subdomains.
    • Send Violation Report in CAA DNS Record: Specifies a way for CAs to report invalid certificate requests to the domain owner.
  • In CA, enter the name of your CA, for example: (letsencrypt.org)

Creating the record via API:

curl --location --request POST 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY 1 2 3 4' \
--header 'content-type: application/json;charset=UTF-8' \
--data-raw '{"type":"CAA","name":"@","cloud":true,"value":{"flag":0,"tag":"issuewild","value":"letsencrypt.org"},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

You can check the published CAA record with the dig command.

Sample BIND format of the CAA record:

example.com. 120 IN CAA 0 issuewild "letsencrypt.org"

TLSA Record​

Applications that communicate over the internet often need to prevent their communications from being tampered with or spoofed. The Transport Layer Security (TLS) protocol provides this kind of security using encryption.

The security of cryptographic systems depends on the keys they use. If private keys are leaked, or if public keys can be replaced with fake keys, the encryption loses its security and usefulness.

The solution is to first use the DNSSEC architecture to make sure DNS records are not forged. Then, the hash of the host's public key, or the public key itself, is stored on the DNS server for the requested host, port, and protocol, so each time a user's browser requests the public key from the web server, it can compare it with the value published on the DNS server and verify it. The TLSA record was designed and implemented for this process.

According to RFC 6698, this record contains 4 fields: Matching Type, Usage, Selector, and finally the requested certificate, which is in hexadecimal. In addition, three values (port, protocol, and host) must be entered in Name.

  • Name:

    In Name, first specify what the certificate is used for, in the following form:

    _port._protocol.host.domain.com

  • Selector:

    This value shows the certificate type (the full certificate with metadata, or part of the public key). In other words, it specifies which part of the TLS certificate presented by the server matches the association data.

    0: Full Certificate

    1: Subject Public Key

  • Usage:

    This value shows how the public key is verified and trusted, and has 4 states:

    0: The certificate is checked and verified against the root CA and intermediate CA.

    1: The record specifies which CA the certificate must be verified by, and that CA must be trusted.

    2: Similar to 1, except that the CA does not need to be trusted.

    3: The certificate does not need to be verified by a CA, for example, it is self-signed.

  • Matching Type:

    Specifies how the public key is presented, and has 3 states:

    0: The public key is presented in full and is not hashed.

    1: The public key is hashed with the SHA2-256 algorithm.

    2: The public key is hashed with the SHA2-512 algorithm.

It is recommended that you use the ssl-tools tool to generate the values and parameters of a record.

Creating a TLSA record via API:

curl --location --request POST 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/dns-records' \
--header 'authority: napi.arvancloud.ir' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY' \
--header 'content-type: application/json;charset=UTF-8' \
--data-raw '{"type":"TLSA","name":"_443._tcp.","cloud":true,"matching_type":"0","selector":"0","usage":"0"},"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"none","order":"none"},"ttl":120}'

PTR Record​

The PTR (Pointer) record collects information for reverse DNS, which ultimately maps a domain name to its IP. Although the PTR record was originally developed to prevent emails sent from the related IPs from being marked as spam, today domain verification is done better with SPF, DKIM, and DMARC.

If you want to register an IP under your name in RIPE, you need to set RIPE's NSs on your IP as follows:

  • First, enter the fourth octet of your IP in the record's Name field. (In an IP address, each "." separates an octet. For example, in the IP 192.168.1.1, 192 is the first octet, 168 the second, 1 the third, and the last 1 the fourth.)
  • In the record's Value field, enter your IP in the form <octet_3>.<octet_2>.<octet_1>.

You can use the dig command to make sure the requested record is correct and available.

To add the above record via API, send your request as follows:

curl --location --request POST 'https://napi.arvancloud.ir/cdn/4.0/domains/3.2.1.in-addr.arpa/dns-records' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: Apikey 1-2-4-5' \
--header 'Content-Type: application/json' \
--data-raw '{"type":"PTR","name":"5","value":{"domain":"example.com"},"ttl":120}'