Simple script to list dedicated IP address usage of domains under a Reseller – WHM/cPanel

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”

grep $username /etc/trueuserowners

Step 3

Find all domains from “/etc/trueuserdomains”

grep $username /etc/trueuserdomains

Step 4

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.

Step 1

touch dedicatedip.txt

Step 2

chmod 755 dedicatedip.txt

Step 3

vi 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

Step 4

./dedicatedip.txt

Please see the sample output:

Step 1

[[email protected] ~]# ./dedicated.txt
Enter the username here

Step 2

[[email protected] ~]# ./dedicated.txt
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.

 

Also,
Keep a log for total number of connections to a particular port from Foreign Address

Post navigation

Arunlal Ashok

Operations Engineer at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com
We like to travel. Our travelogues are published at Trip Mentor

Leave a Reply

Your email address will not be published. Required fields are marked *