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.
Find the username(reseller) from “/etc/trueuserdomains”
Find all users under the reseller from “/etc/trueuserowners”
grep $username /etc/trueuserowners
Find all domains from “/etc/trueuserdomains”
grep $username /etc/trueuserdomains
Find dedicated IP address associated with domains from “/etc/domainips”
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.
chmod 755 dedicatedip.txt
### 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
Please see the sample output:
[[email protected] ~]# ./dedicated.txt
Enter the username here
[[email protected] ~]# ./dedicated.txt Enter the username here testresel --- 22.214.171.124: test1.com 126.96.36.199: test2.org 188.8.131.52: test3.com 184.108.40.206: test4.com 220.127.116.11: test5.com 18.104.22.168: test6.net 22.214.171.124: test7.com 126.96.36.199: test8.com 188.8.131.52: test9.com 184.108.40.206: test10.com completed
Try this and let me know your suggestions.