Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Script to list all domain with its dedicated IP address under a reseller.  (Read 4255 times)

0 Members and 1 Guest are viewing this topic.

lathu_official

  • Guest
In a cPanel server, the dedicated IP address usage is listed in the “/etc/domainips” file. You can simply find the dedicated IP address of a particular domain from here. Here, I am explaining a simple backend script for listing all domains which has dedicated IP address under a reseller account. You must have an idea about the following cPanel backend files for listing this.

/etc/trueuserdomains - Have domain name with username.
/etc/trueuserowners - User name with true owner.
/etc/domainips - Have domains with dedicated IP address.

Step 1

Find the username(reseller) from “/etc/trueuserdomains”

Step 2

Find all users under the reseller from “/etc/trueuserowners”

Code: [Select]
grep $username /etc/trueuserownerstouch dedicatedip
Step 3

Find all domains from “/etc/trueuserdomains”

Code: [Select]
grep $username /etc/trueuserdomains
Step 4

Find dedicated IP address associated with domains from “/etc/domainips”

Code: [Select]
grep $domain-name /etc/domainips

========================================================
Script to list all domain with its dedicated IP address under a reseller.
========================================================

Create a file with executable permission and copy the below pasted script.

Step 1

Code: [Select]
touch dedicatedip
Step 2

Code: [Select]
chmod 755 dedicatedip
Step 3

Code: [Select]
vi dedicatedip

Code: [Select]
### Dedicated IP address usage of domains under a reseller ###

#Enter the user name (Reseller)
echo "Enter the username here"
read username

#Store all accounts under reseller to a file
grep $username /etc/trueuserowners|cut -d: -f1 > unames.txt

#Fetch domain name details using for loop
for i in `cat unames.txt`; do grep $i /etc/trueuserdomains;done|cut -d: -f1 > dnames.txt

#Fetch IP usage from /etc/domainips
for i in `cat dnames.txt`; do grep $i /etc/domainips;done > ipusage.txt

#Listing IP usage
cat ipusage.txt

#Removing files
rm -r ipusage.txt dnames.txt unames.txt

echo completed


Step 4

Code: [Select]
./dedicatedip
Please see the sample output:

Code: [Select]
[root@vps ~]# ./dedicated
Enter the username here
testresel
---
1.1.1.1: test1.com
1.1.1.1: test2.org
1.1.1.1: test3.com
1.1.1.1: test4.com
2.2.2.2: test5.com
2.2.2.2: test6.net
2.2.2.2: test7.com
2.2.2.2: test8.com
3.3.3.3: test9.com
3.3.3.3: test10.com
completed

Try this and let me know your suggestions.