Updating an A record from Command Line

Posted on by Matt Aurand | Updated:
Reading Time: 2 minutes

Domain Name Service, or DNS, can be one of the most be one of the more complicated concepts in server administration. This article will walk through changing an A record from the Linux command line.
This article assumes that you are running BIND on a linux server, that you already have an understanding of what DNS is, the different types of DNS entries, and how DNS works. Please note: The incorrect editing of your zone file can take your site offline. All editing must be done on the authoritative nameservers for the given domain.

Before updating any DNS record, you will want to lower the Time to Live (TTL) values for that zone file. A guide to dropping the TTL values can be found in our Knowledgebase article on lowering TTLs’.

Below is an example of what the zone file looks like from the command line.

; Zone file for example.com
$TTL 14400
@ 86400 IN SOA ns1.example.com. admin.example..com. (
2010090802 ; serial, todays date+todays
86400 ; refresh, seconds
7200 ; retry, seconds
3600000 ; expire, seconds
86400 ) ; minimum, seconds
example.com. 86400 IN NS ns1.example.com.
example.com. 86400 IN NS ns2.example.com.
example.com. IN A
localhost.example.com. IN A
example.com. IN MX 0 example.com.
mail IN CNAME example.com.
www IN CNAME example.com.
ftp IN A
cpanel IN A

When editing an A record, we are concerned with any of the lines that something ‘IN A IP-address’. You may want to change an A record because the IP of a subdomain has changed for whatever reason. Due to propagation times involved with making DNS changes, you will want to make sure that you only make changes if they are absolutely needed.

The steps to change the A record are rather straightforward. In this example, we will change the IP address of the ftp.example.com subdomain. To make these changes from the command line:

  1. Edit the zone file with your favorite command line editor. In this example, we use ‘vi’.

[root@host /var/named/]% vi /var/named/example.com.db

  1. Locate the appropriate line and update the up address. You will see something like the following:

ftp IN A

  1. Update the Zone’s Serial number.
  2. Make BIND aware of your DNS changes by reloading the DNS zone.

[root@host /var/named/]% rndc reload example.com

  1. Test that your changes worked correctly using the information in our KB article about using dig.

[root@host /var/named/]% dig @localhost ftp.example.com

That is all you have to do to change an A record on the command line. If you are uncomfortable with the command line, you can also update your A records using Web Host Manager.

If you have any questions or are not comfortable making these changes yourself, please feel free to contact Heroic Support.


Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434
[email protected]

Avatar for Matt Aurand

About the Author: Matt Aurand

Latest Articles

Using a Cloudflare Argo Tunnel with load balancing

Read Article

Subdomain takeover — protect your website against it!

Read Article

Controlling PHP settings with a custom php.ini file

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article