I want a shared IP (not the server IP) to be shared among many Resellers


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » DirectAdmin » Custom Scripting

I want a shared IP (not the server IP) to be shared among many ResellersLast Modified: Feb 7, 2020, 5:35 pm
"global" IP type for future DA implementation:
https://www.directadmin.com/features.php?id=2322



At the moment, only the server IP can be shared to many Resellers.
Shared IPs can only "officially" exist in one Reseller at a time.

However, there might be a case where you don't want to give your Resellers the server IP, and only let them all share 1 "shared IP" between them.

Assumptions:

  • - Server IP
  • - Shared IP
  • - Additional Shared IP (Optional)

  1. Ensure the shared IP has been created in the

    Admin Level -> IP Manager


           Assign it to the "admin" account on that page, then go to:

    admin -> Reseller Level -> IP Manager


           and ensure the 1.2.3.5 IP is set as "shared".  Do the same for 1.2.3.6 if you want to add multiple shared IPs.
  2. Now we want all newly created Resellers to have the server IP swapped with this shared IP upon their creation.
    To do this, create the following script

    /usr/local/directadmin/scripts/custom/user_create_post_confirmed.sh

    and in it, add the code:

    #!/bin/sh
    IPL=/usr/local/directadmin/data/users/$username/ip.list
    SERVER=1.2.3.4
    SHARED=1.2.3.5

    function add()
    {
           echo $1 >> ${IPL}
    }

    if [ -s ${IPL} ]; then
           STR="perl -pi -e \'s/^${SERVER}\\$/${SHARED}/\' ${IPL}"
           eval ${STR}
           echo "Swapped server IP ${SERVER} with shared IP ${SHARED} for $username";

           add 1.2.3.6
           #add 1.2.3.7
    fi
    exit 0;

  3. Be sure to chmod the script to 755:

    /usr/local/directadmin/scripts/custom/user_create_post_confirmed.sh

  4. Lastly, when you create your Reseller, just make sure you assign them to the server IP, and it will be swapped with the shared IP for their control.
    Note that "add"ing more IPs (1.2.3.6+) will always be added, based on how that's scripted, regardless if the account was created on the server IP or not.  More coding would be needed if you need other scenarios.

Note that their User Level domain will still be set to the server IP. More perl regex calls would be needed to accomplish that (user.conf, user.ip_list, httpd.confm domains/domain.com.conf, domains/domain.com.ip_list, /var/named/domain.com.db)

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST