How to use the Linode CLI command 'linode-cli domains' (with examples)

How to use the Linode CLI command 'linode-cli domains' (with examples)

The Linode CLI command ’linode-cli domains’ allows you to manage Linode Domains and DNS configuration. This command provides several use cases for efficiently managing your domains and making changes to the DNS configuration. Below, we will illustrate each of these use cases with examples.

Use case 1: List all managed domains

Code:

linode-cli domains list

Motivation: The ’list’ command is useful when you want to get an overview of all the domains managed in your Linode account. It provides a quick and convenient way to see the available domains at a glance.

Output Example:

ID        Domain                 Type    SOA Email           Status
123456    example.com            master  hostmaster@example.com active
789012    sub.example.com        slave   hostmaster@example.com active

Explanation:

  • The ’list’ sub-command is used to retrieve a list of all the managed domains in your Linode account.
  • The output of this command includes the ID, domain name, type (master or slave), SOA (Start of Authority) email, and the current status of each domain.

Use case 2: Create a new managed domain

Code:

linode-cli domains create --domain example.com --type master --soa-email hostmaster@example.com

Motivation: When you need to add a new managed domain to your Linode account, you can use the ‘create’ sub-command. This allows you to specify the domain name, type (master or slave), and the SOA email address for the domain.

Explanation:

  • The ‘create’ sub-command is used to create a new managed domain.
  • The --domain argument specifies the domain name.
  • The --type argument specifies the type of the domain, which can be either master or slave.
  • The --soa-email argument specifies the Start of Authority (SOA) email address for the domain. This email address is used for administrative purposes related to the domain.

Output Example:

ID        Domain                 Type    SOA Email           
123456    example.com            master  hostmaster@example.com

Use case 3: View details of a specific domain

Code:

linode-cli domains view 123456

Motivation: To obtain detailed information about a specific domain, you can use the ‘view’ sub-command. This is particularly useful when you want to gather more information about a domain, such as its type, DNS records, or SOA email address.

Explanation:

  • The ‘view’ sub-command is used to retrieve the details of a specific domain.
  • The domain_id argument specifies the ID of the domain for which you want to view the details.

Output Example:

ID: 123456
Domain: example.com
Type: master
SOA Email: hostmaster@example.com
...

(Detailed information about the domain)

Use case 4: Delete a managed domain

Code:

linode-cli domains delete 123456

Motivation: When a domain is no longer needed or needs to be removed from your Linode account, you can use the ‘delete’ sub-command to delete a managed domain.

Explanation:

  • The ‘delete’ sub-command is used to delete a managed domain.
  • The domain_id argument specifies the ID of the domain you want to delete.

Use case 5: List records for a specific domain

Code:

linode-cli domains records-list 123456

Motivation: To view all DNS records associated with a specific domain, you can use the ‘records-list’ sub-command. This is helpful for reviewing the existing records or making changes to them.

Explanation:

  • The ‘records-list’ sub-command is used to retrieve the list of DNS records for a specific domain.
  • The domain_id argument specifies the ID of the domain for which you want to list the records.

Output Example:

ID        Type  Name          Target       Priority TTL     Group
123456    A     subdomain     192.168.1.1  -        3600    -
789012    MX    example.com   mail.server  10       14400   -

Use case 6: Add a DNS record to a domain

Code:

linode-cli domains records-create 123456 --type A --name subdomain --target 192.168.1.1

Motivation: When you need to add a new DNS record to a domain, the ‘records-create’ sub-command allows you to easily specify the necessary details, such as the record type, name, and target value.

Explanation:

  • The ‘records-create’ sub-command is used to create a new DNS record for a domain.
  • The domain_id argument specifies the ID of the domain to which the record needs to be added.
  • The --type argument specifies the type of the DNS record (e.g., A, AAAA, CNAME, MX, etc.).
  • The --name argument specifies the name or subdomain for the record.
  • The --target argument specifies the target value associated with the record.

Use case 7: Update a DNS record for a domain

Code:

linode-cli domains records-update 123456 789012 --target new_target_value

Motivation: If you need to modify the target value of an existing DNS record for a domain, you can use the ‘records-update’ sub-command.

Explanation:

  • The ‘records-update’ sub-command is used to update an existing DNS record for a domain.
  • The domain_id argument specifies the ID of the domain to which the record belongs.
  • The record_id argument specifies the ID of the record that needs to be updated.
  • The --target argument specifies the new target value to be assigned to the record.

Use case 8: Delete a DNS record from a domain

Code:

linode-cli domains records-delete 123456 789012

Motivation: When a DNS record needs to be removed from a domain, you can use the ‘records-delete’ sub-command to perform the deletion.

Explanation:

  • The ‘records-delete’ sub-command is used to delete an existing DNS record from a domain.
  • The domain_id argument specifies the ID of the domain to which the record belongs.
  • The record_id argument specifies the ID of the record that needs to be deleted.

Conclusion:

The ’linode-cli domains’ command offers powerful functionality for managing Linode Domains and DNS configuration. With the different sub-commands provided, you can list managed domains, create new domains, view domain details, delete domains, list records, add records, update records, and delete records. By utilizing these use cases, you can efficiently manage your domains and make necessary changes to your DNS configuration using the Linode CLI.

Related Posts

How to use the command 'loc' (with examples)

How to use the command 'loc' (with examples)

The ’loc’ command is a tool written in Rust that counts lines of code in a directory.

Read More
How to use the command 'ifup' (with examples)

How to use the command 'ifup' (with examples)

The ‘ifup’ command is a tool used to enable network interfaces on a Linux system.

Read More
How to use the command 'http-server' (with examples)

How to use the command 'http-server' (with examples)

The ‘http-server’ command is a simple static HTTP server that allows you to serve static files.

Read More