Pre-requirements
- Root or sudo access to the Linux server via SSH.
- Plesk installed on the server with DNS management enabled.
- Basic knowledge of DNS record types (A, SRV, NS, PTR, etc.).
Introduction
Using the Plesk command-line interface (CLI) is an efficient way to add or modify DNS records for specific domains on your Linux server. This guide covers various commands to manage DNS records such as SRV, A, NS, and PTR records in Plesk, and includes detailed examples for each record type.
Step 1: Connect to Your Server via SSH
- Open a terminal and connect to your Plesk server using SSH:
# For Linux and macOS:
ssh root@your-server-ip
# For Windows, use a tool like PuTTY to initiate the SSH connection.
- If direct SSH access is not possible, contact your server administrator for assistance.
Step 2: Add or Modify DNS Records via CLI
Once connected via SSH, you can add or modify DNS records for a specific domain using the following commands:
Example 1: Add SRV Record for a Domain
The SRV record is used to define service-specific hosts for protocols like SIP, XMPP, etc. To add an SRV record for example.com:
plesk bin dns --add example.com -srv sub.example.com -srv-service sip -srv-target-host sipserver.example.com -srv-protocol tcp -srv-port 5060 -srv-priority 0 -srv-weight 5
example.com
: The domain where the SRV record is being added.-srv
: Defines that the DNS record is an SRV record.- Additional parameters:
-srv-service sip
: Service name.-srv-target-host sipserver.example.com
: Target host for the service.-srv-protocol tcp
: Protocol to be used.-srv-port 5060
: Port for the service.-srv-priority 0
: Priority of the service.-srv-weight 5
: Weight assigned to the record.
Example 2: Add an A Record
To create an A record for example.com that maps the domain to an IP address:
plesk bin dns -a example.com -a "" -ip 203.0.113.2
Example 3: Delete an A Record
To delete the A record for example.com:
plesk bin dns -d example.com -a "" -ip 203.0.113.2
Example 4: Create an NS Record
To create an NS record for example.com:
plesk bin dns -a example.com -ns "" -nameserver ns1.example.com
Example 5: Create a PTR Record
To create a PTR record (used for reverse DNS) for example.com:
plesk bin dns --set example.com -list "PTR,203.0.113.2,,24.;"
Step 3: Verify DNS Changes
Once the DNS records have been added or modified, it's crucial to verify that the changes were applied correctly. You can do this using DNS lookup tools like dig or nslookup from your terminal.
Linux Commands to Verify DNS Records
- Verify A record:
dig A example.com
- Verify SRV record:
dig SRV _sip._tcp.example.com
- Verify NS record:
dig NS example.com
- Verify PTR record:
dig -x 203.0.113.2
Gotchas to Avoid
- Always double-check the domain name and record type before adding or modifying DNS records to avoid accidental misconfigurations.
- Be aware that DNS changes may take time to propagate (up to 48 hours), so test after applying the changes.
- Ensure that the DNS server component is enabled in Plesk before attempting to manage DNS via CLI.
Additional Resources
For more details on managing DNS zones using the CLI in Plesk, refer to the Plesk for Linux CLI Documentation.
By following this guide, you can efficiently add or modify DNS records for specific domains using the Plesk CLI on Linux. Whether you're working with A records, SRV records, or PTR records, the command-line method provides a powerful way to manage your DNS settings directly from the terminal. Always verify DNS changes after making updates to ensure proper propagation.
For more tips and tutorials, visit our Knowledge Base.