Multi-IP per User & Domain

dudek888

Verified User
Joined
Jun 21, 2009
Messages
24
Location
Szczecin / Poland
I can not add additional IP

Hello

After upgrade DA to version 1.37 on my servers I have the same issue what swordfox. I can`t add additional IP on user modification page. In DA 1.38 the problem still exist...
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,921
Hello,

1) Ensure is set correctly:
Code:
cd /usr/local/directadmin
./directadmin c | grep unified_ftp_password_file
If not, add a blank line to the bottom of the directadmin.conf (a newline character is needed after each config line)

2) Do a brute force restart of DA to be sure it's restarted in correctly
Code:
killall -9 directadmin
./directadmin d
John
 

AndriesLouw

Verified User
Joined
Jan 4, 2008
Messages
28
Location
Sneek, Netherlands
I've some trouble with an old IP on my box, which is added each time to the httpd.conf of the user.

My virtual_host2.conf states:
<VirtualHost |IP|:80 |MULTI_IP|>

This generates for each user:
<VirtualHost 178.239.49.XXX:80 194.110.67.198:80 >

But that second IP, isn't used anymore! (XXX's added to first IP)

Things I've tried:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
echo "action=rewrite&value=ips" >> /usr/local/directadmin/data/task.queue

Multiple times each, but still, on start of http, the following error (10 times or so):
[Fri Apr 15 11:10:18 2011] [warn] VirtualHost 194.110.67.198:80 overlaps with VirtualHost 194.110.67.198:80, the first has precedence, perhaps you need a NameVirtualHost directive

And:
cd /usr/local/directadmin/data/users
cat */httpd.conf | grep 194.

Gives indeed, multiple times (10 or so):
<VirtualHost 178.239.49.227:80 194.110.67.198:80 >


I've checked the user, he hasn't any additional IP's anymore. Is there a way to check into directadmin, and remove any occurrences of this old IP manually?

Thanks in advance!
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,921
Hello,

Related files:
Code:
cd /usr/local/directadmin/data/users
*/user.conf   ip=
*/user_ip.list
*/domains/domain.com.conf    ip=
*/domains/domain.com.ip_list
I'd be suspect of the domain.com.ip_list.

This should be listed at:
User Level -> Domain Setup -> domain.com

if the domain has many IPs, then they should be listed there.

John
 

AndriesLouw

Verified User
Joined
Jan 4, 2008
Messages
28
Location
Sneek, Netherlands
Hello,

Related files:
Code:
cd /usr/local/directadmin/data/users
*/user.conf   ip=
*/user_ip.list
*/domains/domain.com.conf    ip=
*/domains/domain.com.ip_list
I'd be suspect of the domain.com.ip_list.

This should be listed at:
User Level -> Domain Setup -> domain.com

if the domain has many IPs, then they should be listed there.

John
Thanks John!
You were right, it was in the */domains/*.ip_list files, couldn't find the right option in DirectAdmin (maybe because of my custom skin), but I hand-removed the IP out of all the ip_list files of one user, and everything is fine now.
Thanks again! :)
 

pppplus

Verified User
Joined
Dec 19, 2008
Messages
518
Hi

I will ask you for some help to understand multiple IP per domain.

I have to move 200 domains in a new server, and I will loose actual IP.

My idea, is to set up the new IP in my actual server.
So domains will have old IP (1.2.3.4), and new IP (4.3.2.1)

Is that possible ?
Doing this, I hope all domains can always answer, first in old IP, then after DNS propagation, in new IP

After 72h, all domains will answer on new IP, and I can move all accounts and this IP to my new server.

It is what I understand, reading : http://help.directadmin.com/item.php?id=346

Is it ok ?
 

pppplus

Verified User
Joined
Dec 19, 2008
Messages
518
Hi

I already test that, with a small TTL (600), but domains can be unreachable for some hours, or 1-3 days.

So I want just domain is not reachable during the time I backup then restore to the new server.

So, if I can have 2 IP for the same domain, it solves my problem.

Are you sure what I understand can't work ?
 

pppplus

Verified User
Joined
Dec 19, 2008
Messages
518
I think this script can change everything, as to change IP for each user and each domains

Code:
#!/bin/sh 

###
# 1- add new IP do USER in /usr/local/directadmin/data/users/USER
# 1bis- add new IP to each domains in  /usr/local/directadmin/data/users/USER/DOMAINS
# 
# 3- replace IP1 by IP2 in dans /var/named
# 3bis- modify TTL to 600
# 3ter- modify serial
#
# 5- restart named
###

IP1=A.B.C.D
IP2=D.C.B.A

# 1- Add IP2 to user in /usr/local/directadmin/data/users/USER
for USER in `ls /usr/local/directadmin/data/users/`
  do
#if [ $USER = "prgsrv3" ] Just to test on only ONE user named prgsrv3
#then
	echo $USER
	#list all domain for USER then add IP2 if IP1 exists
	for DOM in `cat /usr/local/directadmin/data/users/$USER/domains.list`; do
		#add $IP2 if IP1
		sed -i -e "s/$IP1/$IP2\n$IP1/g" /usr/local/directadmin/data/users/$USER/domains/$DOM.ip_list 
		#delete double IP2 if script is run several times
		sed -i -e ':a;N;$!ba;s/'$IP2'\n'$IP2'/'$IP2'/g' /usr/local/directadmin/data/users/$USER/domains/$DOM.ip_list 
	echo $DOM OK
	done

	#add l'IP2 in list of USER ips
	sed -i -e "s/$IP1/$IP2\n$IP1/g" /usr/local/directadmin/data/users/$USER/user_ip.list
	#delete double IP2 if script is run several times
	sed -i -e ':a;N;$!ba;s/'$IP2'\n'$IP2'/'$IP2'/g' /usr/local/directadmin/data/users/$USER/user_ip.list
#fi
  done

# 3- replace all IP1 by IP2 in /var/named
for domaineDB in `ls /var/named/`
  do
    if [ -f /var/namedTEST/$domaineDB  ]
      then
	 case  $domaineDB in 
	   *.db )
	   
		#echo /var/namedTEST/$domaineDB
		#modify l'IP
		sed -i -e "s/$IP1/$IP2/g" /var/namedTEST/$domaineDB 
		#modify TTL
		sed -i -e "s/14400/600/g" /var/namedTEST/$domaineDB 
		#modify serial
		SERIAL=`grep -E "[0-9]{10}" /var/namedTEST/$domaineDB`
		DATE=`echo $SERIAL | cut -c1-8`
		ORDRE=`echo $SERIAL | sed s/"$DATE"/""/g`
		  
		DATE_JOUR=`date +%Y%m%d`
		if [ $DATE = $DATE_JOUR ]
		    then
	    		#ORDRE=$ORDRE+1
			ORDRE=`echo $(( $ORDRE+1 ))`
		else
		    ORDRE=0
		    DATE=$DATE_JOUR
		fi
		NEW_SERIAL=$DATE`printf "%.2d" $ORDRE`
		sed -i -e "s/$SERIAL/                                                $NEW_SERIAL/g" /var/namedTEST/$domaineDB 
		#echo OK
	   ;;
	 esac
    fi
  done

# add to queue to update named 
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
I think all is done in my script
(it's probably possible to do better, but I'm beginner in bash scripts)

Do you think it's ok ?
It seems ok, because all appears ok in directadmin
(new IP added to user, and new IP assigned to domains)
 
Last edited:

pppplus

Verified User
Joined
Dec 19, 2008
Messages
518
It seems there is something else to change, but I do not find what.

When I do it manually, it works, when I change with my script, I have message shared IP instead of domains

Someone has an idea ?
 

pppplus

Verified User
Joined
Dec 19, 2008
Messages
518
Thanks for your reply, but it is not what I need.

Actually, all my users and domains are registered on main IP (where directadmin in installed).
I want to send them to a second IP. Because I can move this new IP between my servers.

On my new server, directadmin is already installed on new IP, but I don't want to put domains on this IP but to a second IP.

I am not sure to be clear... :(

I just add :
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue

at the end of my script, and all seem to work like I want !
 
Last edited:

pppplus

Verified User
Joined
Dec 19, 2008
Messages
518
something is missing, I need to modify httpd.conf for each user
Then reload httpd

Code:
#!/bin/sh 

###
# 1- add new IP do USER in /usr/local/directadmin/data/users/USER
# 1bis- add new IP to each domains in  /usr/local/directadmin/data/users/USER/DOMAINS
# 
# 3- replace IP1 by IP2 in dans /var/named
# 3bis- modify TTL to 600
# 3ter- modify serial
#
# 5- restart named
###

IP1=A.B.C.D
IP2=D.C.B.A

# 1- Add IP2 to user in /usr/local/directadmin/data/users/USER
for USER in `ls /usr/local/directadmin/data/users/`
  do
#if [ $USER = "prgsrv3" ] Just to test on only ONE user named prgsrv3
#then
	echo $USER
	#list all domain for USER then add IP2 if IP1 exists
	for DOM in `cat /usr/local/directadmin/data/users/$USER/domains.list`; do
		#add $IP2 if IP1
		sed -i -e "s/$IP1/$IP2\n$IP1/g" /usr/local/directadmin/data/users/$USER/domains/$DOM.ip_list 
		#delete double IP2 if script is run several times
		sed -i -e ':a;N;$!ba;s/'$IP2'\n'$IP2'/'$IP2'/g' /usr/local/directadmin/data/users/$USER/domains/$DOM.ip_list 
	echo $DOM OK
	done

	#add l'IP2 in list of USER ips
	sed -i -e "s/$IP1/$IP2\n$IP1/g" /usr/local/directadmin/data/users/$USER/user_ip.list
	#add $IP2 si IP1 in httpd.conf
	sed -i -e "s/${IP1}:80/${IP1}:80 ${IP2}:80/g" /usr/local/directadmin/data/users/$USER/httpd.conf 
	#delete double IP2 if script is run several times
	sed -i -e ':a;N;$!ba;s/'$IP2'\n'$IP2'/'$IP2'/g' /usr/local/directadmin/data/users/$USER/user_ip.list
	sed -i -e ':a;N;$!ba;s/'$IP2':80 '$IP2':80/'$IP2':80/g' /usr/local/directadmin/data/users/$USER/httpd.conf 
#fi
  done

# 3- replace all IP1 by IP2 in /var/named
for domaineDB in `ls /var/named/`
  do
    if [ -f /var/namedTEST/$domaineDB  ]
      then
	 case  $domaineDB in 
	   *.db )
	   
		#echo /var/namedTEST/$domaineDB
		#modify l'IP
		sed -i -e "s/$IP1/$IP2/g" /var/namedTEST/$domaineDB 
		#modify TTL
		sed -i -e "s/14400/600/g" /var/namedTEST/$domaineDB 
		#modify serial
		SERIAL=`grep -E "[0-9]{10}" /var/namedTEST/$domaineDB`
		DATE=`echo $SERIAL | cut -c1-8`
		ORDRE=`echo $SERIAL | sed s/"$DATE"/""/g`
		  
		DATE_JOUR=`date +%Y%m%d`
		if [ $DATE = $DATE_JOUR ]
		    then
	    		#ORDRE=$ORDRE+1
			ORDRE=`echo $(( $ORDRE+1 ))`
		else
		    ORDRE=0
		    DATE=$DATE_JOUR
		fi
		NEW_SERIAL=$DATE`printf "%.2d" $ORDRE`
		sed -i -e "s/$SERIAL/                                                $NEW_SERIAL/g" /var/namedTEST/$domaineDB 
		#echo OK
	   ;;
	 esac
    fi
  done

# add to queue to update named 
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
then /etc/init.d/httpd reload

Not sure this script can really be usefull for other persons... but it works now
 
Top