Print

How to Force Delete DNS from Command Line – CLI in WHM

Introduction

In certain situations, you might need to force delete a DNS zone from your WHM (Web Host Manager) server using the command line interface (CLI). This is typically required when a standard DNS zone deletion through the WHM interface fails or encounters issues. This guide will walk you through the steps to remove a DNS zone using the command line in WHM, ensuring a clean and efficient removal process.

This method is particularly useful in scenarios where:

  • The DNS zone deletion process is stuck in WHM.
  • You are experiencing errors when trying to delete the DNS zone through the WHM interface.
  • You need to automate DNS zone removal via scripts.

By using the command line, you can bypass potential interface issues and directly instruct the server to forcefully delete the DNS zone.

Prerequisites

Before you begin, ensure you have the following:

  • WHM Access: You need administrative access to your WHM server.
  • Root Access via SSH: You will need to connect to your server via SSH as the root user. This is necessary to execute commands with the required privileges.

Steps to Force Delete DNS Zone from Command Line – CLI in WHM

Follow these steps to force remove a DNS zone using the command line in WHM:

  1. Access your server via SSH:

    • Open your terminal application (like Terminal on macOS or PuTTY on Windows).
    • Connect to your server using the SSH command, replacing your_server_ip with your server’s IP address and ensure you are logging in as the root user.
  2. Identify the DNS Zone to Delete:

    • Before proceeding with the force deletion, you need to identify the exact name of the DNS zone you want to remove. This is usually the domain name for which the DNS zone is configured. For example, if you want to delete the DNS zone for example.com, then example.com is your DNS zone name.
  3. Execute the Force Delete Command:

    • Use the following command to force delete the DNS zone. Replace domain.com with the actual domain name of the DNS zone you want to remove.
    whmapi1 killdns domain='example.com'
    
    • whmapi1: This is the command-line interface to the WHM API 1 (Application Programming Interface). We are using it to interact with WHM functionalities.
    • killdns: This is the specific WHM API 1 function we are calling, designed to remove DNS zones. It effectively “kills” the DNS zone.
    • domain='domain.com': This parameter specifies the DNS zone that you want to delete. Replace domain.com with your actual domain name.
  4. Verify DNS Zone Deletion:

    • After executing the command, WHM will provide an output indicating the success or failure of the operation. A successful deletion will typically show a “result: 1” message.

    • You can further verify the deletion by:

      • Checking the DNS Zones list in your WHM interface to ensure the zone is no longer present.
      • Using the following command in the CLI to list all DNS zones and confirm the deleted zone is not listed:
      whmapi1 list_dns_zones
      

This article also solves the below issues:

  1. How to Fix “A DNS entry for the domain already exists” error in WHM/cPanel?

    • If you encounter the error message “A DNS entry for the domain already exists” when trying to create a new cPanel account or add a domain, it often indicates a lingering or corrupted DNS zone in WHM. Even if you cannot see the zone in the WHM interface, it might still exist in the backend DNS configuration.
    • Using the whmapi1 killdns domain='example.com' command (as described above) can forcefully remove this existing, potentially hidden, DNS zone. After force deleting, you should be able to create the cPanel account or add the domain without encountering the “DNS entry already exists” error.
  2. How to Force remove DNS record permanently.

    • This article directly addresses how to force remove a DNS record permanently (specifically, a DNS zone, which is a collection of DNS records for a domain).
    • The whmapi1 killdns domain='example.com' command ensures the permanent removal of the entire DNS zone for the specified domain from your WHM server. This is a forceful and irreversible action, effectively deleting all DNS records associated with that domain within WHM’s DNS management.

Important Considerations:

  • Force deletion is irreversible: Once you force delete a DNS zone, it is permanently removed. Ensure you have backed up any necessary DNS records before proceeding.
  • Use with caution: Only use the killdns command when standard deletion methods are failing. Incorrectly forcing deletion can lead to unintended consequences if not used properly.
  • Alternative Force Delete Command: In certain rare situations, if killdns does not suffice, you can try the command
    whmapi1 remove_dns_zone zone=domain.com force=1

    This command also forces deletion and might be helpful in very specific edge cases. However, killdns is generally the recommended command for forceful removal.

  • Propagation time: After deleting a DNS zone, allow time for DNS propagation to complete. During this time, some users might still be directed to the old server until the DNS changes fully propagate across the internet.

Conclusion

By following these steps, you can effectively force delete a DNS zone from the command line in WHM. This method provides a powerful way to resolve DNS zone removal issues, fix “DNS entry already exists” errors, and ensure permanent DNS record removal, thus helping to maintain your server efficiently. Remember to use this command with caution and always verify the DNS zone deletion to ensure the process is successful.

If you have any further questions or encounter any issues, please contact our support team at myglobalHOST for assistance.

Table of Contents
Close
Get 75% + extra 10% Discount on web Hosting Plans by myglobalHOST

Extra 10% OFF

Coupon Code

EXTRA10

Applicable on

FLAT Rs 100 OFF

Coupon Code

FLAT100

Applicable on

How to Avail: Simply browse the most appropriate hosting plan for you and avail extra discount on all orders.

Expert Advice

+91-79862-84663

11AM to 6PM

Live Chat : 11AM to 6PM