Add DNS record via CLI

2 posts / 0 new
Last post
#1 Thu, 11/20/2014 - 11:23
AndyH

Add DNS record via CLI

Hi!

To add a DNS record to a specific domain via CLI I can use this command: modify-dns --domain example.com --add-record "foo.example.com A 123.123.123.123"

But how can I add a DNS record to all domains so that "example.com" is replaced with the correct domain name?

modify-dns --all-domains --add-record "foo A 123.123.123.123" ?

Andy

Fri, 11/21/2014 - 16:51
ReArmedHalo

Hi,

Try the following:

virtualmin list-domains --name-only | while read line ; do virtualmin modify-dns --domain-name $line --add-record "$line A 123.123.123.123" ; done

That should work, I don't have a server I can test it on though so let me know if you have any issues. You only need to replace the IP address (123.123.123.123) with what you want.

-Dustin

Topic locked