Inserting A records in dns zone [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












Following is the script we are running.



for x in `cat /root/domain | cut -d: -f1` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done


The script is inserting the domain but instead of the domain name (Domain1.com), we need the IP (192.0.2.55) to be inserted.



ns1 14400 IN A Domain1.example


We are looking for the below-mentioned data.



ns1 14400 IN A 192.0.2.55


File in content: (domain)



  • Domain1.example 192.0.2.55

  • Domain2.example 198.51.100.2

EDIT #1



We have around 500 domains and trying to insert A records to the domains with specific IPs.



Example:



  • domain1.example 192.0.2.33

  • domain2.example 198.51.100.44

  • domain3.example 203.0.113.44

The below mentioned script assigns the required records to the domains individually.



$ for x in domain1.com; do echo "ns1 14400 IN A 192.0.2.126" >> /var/named/$x.db; done


We have a file containing the domains and the IPs and we would like to have a script which would assign the records from that file itself in bulk (See the above mentioned example).



Reference link



  • https://forums.cpanel.net/threads/bulk-dns-insert.219301/






share|improve this question













closed as off-topic by Rui F Ribeiro, slm♦ Jul 7 at 14:06


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – slm








  • 1




    do you want to use domain name as file name $x.db and IP address passed into file content?
    – RomanPerekhrest
    Jul 5 at 12:36











  • Crossposted stackoverflow.com/q/51023400/4957508
    – roaima
    Jul 7 at 12:26














up vote
-1
down vote

favorite












Following is the script we are running.



for x in `cat /root/domain | cut -d: -f1` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done


The script is inserting the domain but instead of the domain name (Domain1.com), we need the IP (192.0.2.55) to be inserted.



ns1 14400 IN A Domain1.example


We are looking for the below-mentioned data.



ns1 14400 IN A 192.0.2.55


File in content: (domain)



  • Domain1.example 192.0.2.55

  • Domain2.example 198.51.100.2

EDIT #1



We have around 500 domains and trying to insert A records to the domains with specific IPs.



Example:



  • domain1.example 192.0.2.33

  • domain2.example 198.51.100.44

  • domain3.example 203.0.113.44

The below mentioned script assigns the required records to the domains individually.



$ for x in domain1.com; do echo "ns1 14400 IN A 192.0.2.126" >> /var/named/$x.db; done


We have a file containing the domains and the IPs and we would like to have a script which would assign the records from that file itself in bulk (See the above mentioned example).



Reference link



  • https://forums.cpanel.net/threads/bulk-dns-insert.219301/






share|improve this question













closed as off-topic by Rui F Ribeiro, slm♦ Jul 7 at 14:06


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – slm








  • 1




    do you want to use domain name as file name $x.db and IP address passed into file content?
    – RomanPerekhrest
    Jul 5 at 12:36











  • Crossposted stackoverflow.com/q/51023400/4957508
    – roaima
    Jul 7 at 12:26












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











Following is the script we are running.



for x in `cat /root/domain | cut -d: -f1` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done


The script is inserting the domain but instead of the domain name (Domain1.com), we need the IP (192.0.2.55) to be inserted.



ns1 14400 IN A Domain1.example


We are looking for the below-mentioned data.



ns1 14400 IN A 192.0.2.55


File in content: (domain)



  • Domain1.example 192.0.2.55

  • Domain2.example 198.51.100.2

EDIT #1



We have around 500 domains and trying to insert A records to the domains with specific IPs.



Example:



  • domain1.example 192.0.2.33

  • domain2.example 198.51.100.44

  • domain3.example 203.0.113.44

The below mentioned script assigns the required records to the domains individually.



$ for x in domain1.com; do echo "ns1 14400 IN A 192.0.2.126" >> /var/named/$x.db; done


We have a file containing the domains and the IPs and we would like to have a script which would assign the records from that file itself in bulk (See the above mentioned example).



Reference link



  • https://forums.cpanel.net/threads/bulk-dns-insert.219301/






share|improve this question













Following is the script we are running.



for x in `cat /root/domain | cut -d: -f1` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done


The script is inserting the domain but instead of the domain name (Domain1.com), we need the IP (192.0.2.55) to be inserted.



ns1 14400 IN A Domain1.example


We are looking for the below-mentioned data.



ns1 14400 IN A 192.0.2.55


File in content: (domain)



  • Domain1.example 192.0.2.55

  • Domain2.example 198.51.100.2

EDIT #1



We have around 500 domains and trying to insert A records to the domains with specific IPs.



Example:



  • domain1.example 192.0.2.33

  • domain2.example 198.51.100.44

  • domain3.example 203.0.113.44

The below mentioned script assigns the required records to the domains individually.



$ for x in domain1.com; do echo "ns1 14400 IN A 192.0.2.126" >> /var/named/$x.db; done


We have a file containing the domains and the IPs and we would like to have a script which would assign the records from that file itself in bulk (See the above mentioned example).



Reference link



  • https://forums.cpanel.net/threads/bulk-dns-insert.219301/








share|improve this question












share|improve this question




share|improve this question








edited Jul 7 at 22:21









Patrick Mevzek

2,0131721




2,0131721









asked Jul 5 at 12:16









techforever92

66




66




closed as off-topic by Rui F Ribeiro, slm♦ Jul 7 at 14:06


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – slm




closed as off-topic by Rui F Ribeiro, slm♦ Jul 7 at 14:06


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – slm







  • 1




    do you want to use domain name as file name $x.db and IP address passed into file content?
    – RomanPerekhrest
    Jul 5 at 12:36











  • Crossposted stackoverflow.com/q/51023400/4957508
    – roaima
    Jul 7 at 12:26












  • 1




    do you want to use domain name as file name $x.db and IP address passed into file content?
    – RomanPerekhrest
    Jul 5 at 12:36











  • Crossposted stackoverflow.com/q/51023400/4957508
    – roaima
    Jul 7 at 12:26







1




1




do you want to use domain name as file name $x.db and IP address passed into file content?
– RomanPerekhrest
Jul 5 at 12:36





do you want to use domain name as file name $x.db and IP address passed into file content?
– RomanPerekhrest
Jul 5 at 12:36













Crossposted stackoverflow.com/q/51023400/4957508
– roaima
Jul 7 at 12:26




Crossposted stackoverflow.com/q/51023400/4957508
– roaima
Jul 7 at 12:26










2 Answers
2






active

oldest

votes

















up vote
1
down vote













Problem is with delimiter : in cut, which does not exist.



Try,



for x in `awk 'print $2' /root/domain ` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done





share|improve this answer




























    up vote
    0
    down vote













    This can be done with pure bash:



    while read a x; do [ -n "$x" ] && echo "ns1 14400 IN A $x" >>/var/named/$x.db ; done <file



    • read a x: assign the first word to $a and the second word to $x.


    • [ -n "$x" ]: if $x is not empty


    • echo "..." >> append to the desired file.


    • <file: file is the input file with the domains and IPs.





    share|improve this answer




























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote













      Problem is with delimiter : in cut, which does not exist.



      Try,



      for x in `awk 'print $2' /root/domain ` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done





      share|improve this answer

























        up vote
        1
        down vote













        Problem is with delimiter : in cut, which does not exist.



        Try,



        for x in `awk 'print $2' /root/domain ` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done





        share|improve this answer























          up vote
          1
          down vote










          up vote
          1
          down vote









          Problem is with delimiter : in cut, which does not exist.



          Try,



          for x in `awk 'print $2' /root/domain ` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done





          share|improve this answer













          Problem is with delimiter : in cut, which does not exist.



          Try,



          for x in `awk 'print $2' /root/domain ` ; do echo "ns1 14400 IN A $x" >> /var/named/$x.db ; done






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jul 5 at 12:21









          SivaPrasath

          3,69811636




          3,69811636






















              up vote
              0
              down vote













              This can be done with pure bash:



              while read a x; do [ -n "$x" ] && echo "ns1 14400 IN A $x" >>/var/named/$x.db ; done <file



              • read a x: assign the first word to $a and the second word to $x.


              • [ -n "$x" ]: if $x is not empty


              • echo "..." >> append to the desired file.


              • <file: file is the input file with the domains and IPs.





              share|improve this answer

























                up vote
                0
                down vote













                This can be done with pure bash:



                while read a x; do [ -n "$x" ] && echo "ns1 14400 IN A $x" >>/var/named/$x.db ; done <file



                • read a x: assign the first word to $a and the second word to $x.


                • [ -n "$x" ]: if $x is not empty


                • echo "..." >> append to the desired file.


                • <file: file is the input file with the domains and IPs.





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  This can be done with pure bash:



                  while read a x; do [ -n "$x" ] && echo "ns1 14400 IN A $x" >>/var/named/$x.db ; done <file



                  • read a x: assign the first word to $a and the second word to $x.


                  • [ -n "$x" ]: if $x is not empty


                  • echo "..." >> append to the desired file.


                  • <file: file is the input file with the domains and IPs.





                  share|improve this answer













                  This can be done with pure bash:



                  while read a x; do [ -n "$x" ] && echo "ns1 14400 IN A $x" >>/var/named/$x.db ; done <file



                  • read a x: assign the first word to $a and the second word to $x.


                  • [ -n "$x" ]: if $x is not empty


                  • echo "..." >> append to the desired file.


                  • <file: file is the input file with the domains and IPs.






                  share|improve this answer













                  share|improve this answer



                  share|improve this answer











                  answered Jul 5 at 13:34









                  chaos

                  33.5k767112




                  33.5k767112












                      Popular posts from this blog

                      Peggy Mitchell

                      Palaiologos

                      The Forum (Inglewood, California)