Skip to main content
cPanel Technical Support has been heavily impacted by hurricane Beryl and our ability to respond to tickets has been hindered as a result. We appreciate your understanding and patience as we address these delays.

Add ipv6 to spf bulk

Answered

Comments

10 comments

  • cPRex Jurassic Moderator

    Hey there!  Unfortunately I don't have any such tool available.  When this question has come up in the past (https://support.cpanel.net/hc/en-us/community/posts/19129342635799-Bulk-Edit-SPF) we've recommended careful scripting of the affected domains in order to achieve this.  I'm sorry I don't have more useful details.

    0
  • rbairwell

    Have all the records got something in common - such as ip4:xx.xx.xx.xx ? If so, a regular expression can be easily made to "key off" of that entry and append additional entries after it? If it doesn't, a regular expression can still be written but will be a bit more tricky..

    (see also https://support.cpanel.net/hc/en-us/community/posts/19164956760855-CPANEL-43352-using-spf-installer-to-remove-entry

    0
  • Unnamed User

    he guys!

     

    Thanks for the reply rbairwell i want to add the following. ip6:*******

    Now the record is:
    v=spf1 a mx  ip4:***  include:****** -all

    it need to be: 
    v=spf1 a mx  ip4:*****ip6:*****  include:****** -all 

     

    But iwhout changing the rest of the spf (people have their own spf policy added, so that need to be unchanged. so jus tadding an ip6:**** to all users..

     

    Thanks again!

    0
  • rbairwell

    Try the following:

    cp -rf /var/named{,.backup}
    find /var/named/*.db -exec perl -pi -e "s/(\Qip4:192.168.1.0\E) ?/$1 ip6:2001:db8:abcd:ef01:2345:6789:0abc:def /g" '{}' \;
    find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s?(?i)serial/i) { my $i = $1+1; s/$1/$i/;}' '{}' \;
    /scripts/restartsrv_named


    which should replace any occurrences of the text ip4:192.168.1.0 with itself (the $1) and followed by the text ip6:2001:db8:abcd:ef01:2345:6789:0abc:def . If anything goes wrong, then backups should be available in /var/named ending in .backup .

    0
  • Unnamed User

    hi rbairwell that replaces the ip4. instead of leaving that one alone and just add the ipv6. I very appreciate how you think with me. Thank you so much! i hope you can help me with the code! 

    0
  • Unnamed User

    I have the solution with this one: 

    https://support.cpanel.net/hc/en-us/articles/4403818107927-How-to-add-an-SPF-entry-to-all-domains-on-the-server?

     

    But it changes all my hard fail (-all) to soft fail  (~all) :( I nead to have it stay hard fail. 

    0
  • quietFinn

    If you run:
    /usr/local/cpanel/bin/spf_installer --help

    you see that you can use <is-complete>, i.e. in your case 1

     

    0
  • Unnamed User

    hi already tried. but its deleting the other spf records. and it is not in bulk. 

    0
  • rbairwell

    hi rbairwell that replaces the ip4. instead of leaving that one alone and just add the ipv6. I very appreciate how you think with me. Thank you so much! i hope you can help me with the code! 

    It shouldn't replace the IPv4. I've just done a quick test:

    # perl -e 'my $spf="example ip4:192.168.1.0 spf";print "$spf\n";$spf=~s/(\Qip4:192.168.1.0\E) ?/$1 ip6:2001:db8:abcd:ef0
    1:2345:6789:0abc:def /g;print "$spf\n";'
    example ip4:192.168.1.0 spf
    example ip4:192.168.1.0 ip6:2001:db8:abcd:ef01:2345:6789:0abc:def spf

    and as you can see, the regular expression took the string "example ip4:192.168.1.0 spf" and changed it to "example ip4:192.168.1.0 ip6:2001:db8:abcd:ef01:2345:6789:0abc:def spf" (keeping the bits before the IPv4 address, the IPv4 address and the bits after - just inserting the ip6 bit in the middle).

     

    0
  • Unnamed User

    Aaah i see it! 

     

    Excellent solution. I have fixed it. Thank you again. Lifesaver!

    1

Please sign in to leave a comment.