This post explains for how to manually assign a dedicated IP address to a subdomain by command line,
Assume that, the below details are subdomain username and Dedicated IP,
Sub-Domain: linuxfaq.domain.com (linuxfaq)
User Name : domain
IP Address: 1.2.3.4
Step 1: Assign IP Address
Once logged into your server via SSH with root privilege open to the /var/cpanel/userdata directory.
# cd /var/cpanel/userdata/domain/
open the subdomain file by any text editor vi, vim, nano, remove the existing IP and add to dedicated IP address, ip: 1.2.3.4
# vi linuxfaq.domain.com
documentroot: /home/domain/public_html/linuxfaq
group: domain
hascgi: 0
homedir: /home/domain
ip: 1.2.3.4
ipv6: ~
no_cache_update: 0
owner: root
phpopenbasedirprotect: 1
serveradmin: webmaster@linuxfaq.domain.com
serveralias: www.linuxfaq.domain.com
servername: linuxfaq.domain.com
usecanonicalname: 'Off'
user: domain
userdirprotect: ''
step 2: Rebuild and restart Apache
After changes the file rebuild and restart Apache,
# /scripts/rebuildhttpdconf
info [rebuildhttpdconf] Missing owner for domain host3.domain.com, force lookup to root
Built /usr/local/apache/conf/httpd.conf OK
Step 3: Reserve IP Address for subdomain:
Open the domainips name
# vim /etc/domainips
#domainips v1
1.2.3.4: linuxfaq.domain.com
step4: Rebuild IP Pool
To execute below script assign free ip's
#/scripts/rebuildippool
The system has 1 free IP.
step5: DNS configuration
Open a main domain named db file and Set the A record,
# vim /var/named/domain.com.db
linuxfaq 3600 IN A 1.2.3.4
www.linuxfaq 3600 IN A 1.2.3.4
Verify the named zone,
# /usr/sbin/named-checkzone domain.com /var/named/domain.com.db
zone domain.com/IN: loaded serial 2014100302
OK
Restart named service
# /etc/init.d/named restart
Stopping named: . [ OK ]
Starting named: [ OK ]
To check whether the named is working fine,
# ps aux | grep named
named 732080 17.6 0.8 402720 33852 ? Ssl 15:15 0:01 /usr/sbin/named -u named
root 732125 0.0 0.0 6384 700 pts/2 S+ 15:16 0:00 grep named
Also check the name server, and A record,
# dig linuxfaq.domain.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> linuxfaq.domain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48207
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;linuxfaq.domain.com. IN A
;; ANSWER SECTION:
linuxfaq.domain.com. 3600 IN A 1.2.3.4
;; AUTHORITY SECTION:
domain.com. 86400 IN NS ns5.domain.com.
domain.com. 86400 IN NS ns6.domain.com.
;; ADDITIONAL SECTION:
ns6.domain.com. 288 IN A 192.168.0.1
ns5.domain.com. 288 IN A 192.168.0.2
;; Query time: 45 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Sep 27 15:16:13 2014
;; MSG SIZE rcvd: 142
Comments (0)