Bug in IP management

Webcart

Verified User
Joined
Jan 14, 2004
Messages
367
Hello,

I think I've found a bug that was introduced just recently.

DA v1.31.5 running on CentOS 5.x 64-bit:

When I remove IP via CMD_IP_MANAGER, it's removed from the list on CMD_IP_MANAGER page, but it's not removed from ifconfig for some reason, so adding this IP to another server in the same subnet causes IP conflict.

Here is the version where it works fine: DA v1.27.2 running on CentOS 4.x 64-bit.

If you encounter this problem, you can fix it by running the following commands as root (Linux only):
Code:
ifdown eth0; ifup eth0
service startips start
 
Hello,

According to the "removeip" script's datestamp, I have not touched it since April 1, 2005...

What's the result of running the IP removal manually?

/usr/sbin/ifconfig eth0 del 1.2.3.4

does that work?

Also, what is the output of the following command:
Code:
ifconfig |grep eth0: | cut -d\  -f1
(there are 2 spaces after the -d\ ... both spaces are needed). It should give you a listing of all eth0 device names. The removeip script will then go through each one and check to see if the IP is on it, then if there is a match, the IP is removed via that first command.

John
 
Hello,

According to the "removeip" script's datestamp, I have not touched it since April 1, 2005...

What's the result of running the IP removal manually?

/usr/sbin/ifconfig eth0 del 1.2.3.4

does that work?

Thank you for your reply.
The command used for removing IP address explains it all:

Code:
[root@srv30 ~]# /usr/sbin/ifconfig eth0 del [i]123.456.789.1[/i]
-bash: /usr/sbin/ifconfig: No such file or directory
[root@srv30 ~]# whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

Apparently, the location of ifconfig utility has been changed. Here is an output of whereis command executed on Centos 4.x:
Code:
[root@pe2850 ~]# whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

Also, what is the output of the following command:
Code:
ifconfig |grep eth0: | cut -d\  -f1
(there are 2 spaces after the -d\ ... both spaces are needed). It should give you a listing of all eth0 device names. The removeip script will then go through each one and check to see if the IP is on it, then if there is a match, the IP is removed via that first command.

Code:
[root@srv30 ~]# ifconfig |grep eth0: | cut -d\  -f1
eth0:0
eth0:1
eth0:2
eth0:3
eth0:4
eth0:5
eth0:6
eth0:7
eth0:8
eth0:9
eth0:10
eth0:11
eth0:12
eth0:13
 
Sorry, that's only a typo in my post. The script does use /sbin/ifconfig, so that's not the issue.

How about, try to remove the IP using the script.
Code:
cd /usr/local/directadmin/scripts
./removeip [b]1.2.3.4[/b]
and see if that removes the IP from the device or not. Keep an eye out for errors.

John
 
How about, try to remove the IP using the script

It doesn't generate any errors, but IP is not removed either.
Code:
[root@srv30 /usr/local/directadmin/scripts]# ifconfig > asd
[root@srv30 /usr/local/directadmin/scripts]# ./removeip [I]123.456.789.1[/I]
[root@srv30 /usr/local/directadmin/scripts]# ifconfig > asd2
[root@srv30 /usr/local/directadmin/scripts]# diff asd asd2
5,6c5,6
<           RX packets:9879 errors:0 dropped:0 overruns:0 frame:0
<           TX packets:12265 errors:0 dropped:0 overruns:0 carrier:0
---
>           RX packets:9988 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:12350 errors:0 dropped:0 overruns:0 carrier:0
8c8
<           RX bytes:1283342 (1.2 MiB)  TX bytes:13943274 (13.2 MiB)
---
>           RX bytes:1293763 (1.2 MiB)  TX bytes:13956461 (13.3 MiB)
85,86c85,86
<           RX packets:1881635 errors:0 dropped:0 overruns:0 frame:0
<           TX packets:1881635 errors:0 dropped:0 overruns:0 carrier:0
---
>           RX packets:1881643 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:1881643 errors:0 dropped:0 overruns:0 carrier:0
88c88
<           RX bytes:195180450 (186.1 MiB)  TX bytes:195180450 (186.1 MiB)
---
>           RX bytes:195181112 (186.1 MiB)  TX bytes:195181112 (186.1 MiB)
 
Ok, then edit the removeips script, we'll add some debug info.

Find the line:
Code:
NUMIP=`/sbin/ifconfig $i | grep -c "$1 "`;
Just below it, add:
Code:
echo "found $NUMIP IPs on device number $i when looking for $1";
The NUMIP variable is likely not getting the required info needed.. it's likely not seeing the ip in the device. Note there is a space after the IP being searched for... could remove the space after it. "$1 " vs "$1".

John
 
Here we go:
Code:
[root@srv30 /usr/local/directadmin/scripts]# ./removeip 333.444.555.39
found 0 IPs on device number eth0:0 when looking for 333.444.555.39
found 0 IPs on device number eth0:1 when looking for 333.444.555.39
found 0 IPs on device number eth0:2 when looking for 333.444.555.39
found 0 IPs on device number eth0:3 when looking for 333.444.555.39
found 0 IPs on device number eth0:4 when looking for 333.444.555.39
found 0 IPs on device number eth0:5 when looking for 333.444.555.39
found 1 IPs on device number eth0:6 when looking for 333.444.555.39

I've initially added the debug info above NUMIP= line and posted the results. I've deleted that post after noticing the error.
 
Apparently,
Code:
/sbin/ifconfig eth0:6 del 333.444.555.39
command has no effect:

Code:
[root@srv30 /usr/local/directadmin/scripts]# ifconfig > asd1
[root@srv30 /usr/local/directadmin/scripts]# /sbin/ifconfig eth0:6 del 333.444.555.39
[root@srv30 /usr/local/directadmin/scripts]# ifconfig > asd2
[root@srv30 /usr/local/directadmin/scripts]# diff asd1 asd2
5,6c5,6
<           RX packets:98546443 errors:4 dropped:0 overruns:0 frame:4
<           TX packets:66799427 errors:189842 dropped:0 overruns:0 carrier:189842
---
>           RX packets:98546541 errors:4 dropped:0 overruns:0 frame:4
>           TX packets:66799512 errors:189842 dropped:0 overruns:0 carrier:189842
8c8
<           RX bytes:124836768500 (116.2 GiB)  TX bytes:34406415804 (32.0 GiB)
---
>           RX bytes:124836777261 (116.2 GiB)  TX bytes:34406470491 (32.0 GiB)
85,86c85,86
<           RX packets:359350 errors:0 dropped:0 overruns:0 frame:0
<           TX packets:359350 errors:0 dropped:0 overruns:0 carrier:0
---
>           RX packets:359358 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:359358 errors:0 dropped:0 overruns:0 carrier:0
88c88
<           RX bytes:34769293 (33.1 MiB)  TX bytes:34769293 (33.1 MiB)
---
>           RX bytes:34769955 (33.1 MiB)  TX bytes:34769955 (33.1 MiB)
[root@srv30 /usr/local/directadmin/scripts]# rm asd1 asd2
 
And what is result of
/sbin/ifconfig eth0 del 333.444.555.39
The result is nothing... literally :)
If you take a look at SSH snapshot above (which is a real thing other than replacing 3 bytes of a real IP address with a fictional 333.444.555), you will see that this command terminates w/o an error message.
 
Is there already a solution?

I do have the same issue with, remove an ip from mngt. ip addr still shows the ip address in use, when I try to add, it says that the ip is already on that server, and the entry is shown in the table of ip's.

Version :
Compiled on CentOS 5.0 64-bit
Server Version 1.32.2

I saw there was an update 1.32.3, but in the list their is nothing about ip management.

TIA,
Fossie
 
Hello,

if removing the IP directly via ifconfig has no effect, then it's a network device issue. Nothing in DA would fix it.

Try:
Code:
service network restart
which should dump out all IPs from the device except the main one. Check to confirm.

Then to re-add the other ones by typing:
Code:
service startips start
John
 
Manually it works fine, without any problems. But for some reason it doesn't remove it completly from the server.
 
When you run
Code:
# service network restart
and then do:
Code:
# ifconfig | grep inet\ addr
does the IP# appear? If so, then it's installed not just in DirectAdmin but also in your OS Distribution's IP management code. On my server that means there's a script in /etc/sysconfig/network-scripts which you need to remove (be careful to not remove the wrong one) and then restart the service again. The code and/or method of removing it may very well be different depending on your OS Distribution.

If the IP# doesn't appear, but does after you run:
Code:
service startips start
then you need to remove the IP# from the DirectAdmin IP administration system.

Remove the IP# from /usr/local/directadmin/data/admin/ip.list and then delete the entire file for that IP# at /usr/local/directadmin/data/admin/ips/.

Then rerun both commands above. That should remove it.

Jeff
 
Hello,

First thank you jlasman for your good reply.
I did what you asked, but the IP didn't exist anymore, because I removed them manually a few weeks ago with "ifconfig del eth0:2"

But what I saw was that they where removed from the DA ip list, but still assigned on ifconfig. So I guess DA uses the wrong command to remove them from the ifconfig.

I'm gonna test it now again with a free IP. I will let you know
 
I did the following steps

1) Added 1 IP address via IP Management
2) Checked with "ifconfig" if it exists, and Yes it is.
3) Removed it via IP Management
4) Checked with "ifconfig" if its removed, and No it isn't removed.

Also when I do "/etc/init.d/network restart and /etc/init.d/startips start" the IP isn't showed anymore

So I guess DA is using a wrong command to remove the IPs from the server.
 
Last edited:
..was running into the same issue, CentOs 5.3 x64, the hint from Webcart
(ifdown eth0; ifup eth0; service startips start) did the job.
 
Not on any of our servers ;).

Check with DirectAdmin Support.

jeff

I wonder if you are running CentOS 5.x 64 bit now without encountering this problem.

After some googling and reverse engineering of /sbin/dhclient-script script I found the following ways to remove IP alias:
PHP:
ifconfig eth0:6 down
PHP:
ifconfig eth0:6 inet 0
(check this link for explanation how it works)
It looks like ifconfig doesn't work the same across different Linux distributions *sigh*
 
Back
Top