OpenNetAdmin

Track. Automate. Configure.

Home About Features Community Develop
Download this project as a tar.gz file

change subnet mask requires redo of all hosts on the subnet?

yshollander

22-07-2009 14:46:35

So I entered a new subnet for the loopback interface of my router, and accidentally set the subnet mask to 255.255.255.0 instead of 255.255.255.255.

Of course, I had already entered the router and all its many interfaces into ONA.

ONA would not let me update the incorrect netmask as long as there were hosts on the network.

I ended up manually updating in the database after verifying the correct value with a hand-rolled php script:

#!/usr/bin/php
<?php
printf("%u\n", ip2long("255.255.255.255"));
?>

ONA handled the update happily. Nothing changed regarding the hosts since the netmask is stored in the subnets table,
and the interfaces table just contains a subnet_id as a foreign key to the subnets table.

I understand that netmask updates are dangerous if there are interfaces that would be excluded from the redefined
subnet. But couldn't that be determined programmatically? I'd rather not risk updating the DB by hand if at all possible...

Thanks

Isaac

Matt

23-07-2009 08:43:28

So there are a few issues that need to be worked out.

First off, the typical logic is that you add a subnet and it will automatically be aware of the broadcast and the network address. Then all addresses between are available for hosts. This becomes a problem for /32 and /31 subnets.

I still need to work out the details on how to track these types of addresses. There are a few challenging bits about it like the fact that adding a /32 subnet is easy, this does create an IP interface so you would be unable to search for the host using that IP. I think these things can be worked around, I just need to figure out the logic.

As far as changing a mask from a larger one to a smaller, or even just changing IP addresses in general. I do have an interface_move dcm module that allows you define a source and destination range. You can easily move in bulk, any addresses that would become abandoned. What I dont have is a GUI interface for it yet. I'll see about working one up as it should simple. Also I might add a method in it that allows you to "split" a subnet which is a similar but slightly trickier task due to the checks that are in place.

Hope that explains whats going on. No real fixes as of yet however...................

BTW you can use the subnet calculator tool to display what your little script did for you. Its the little icon hanging on the right of your screen below the top bar.

JoeLT

01-05-2012 05:21:38

Hi. Did anyone get anywhere with figuring out the logic for loopback addresses/subnets? I have the situation where I need to record numerous loopback addresses on devices and can't figure out a way to do this as when I create a subnet with a /32 mask, there are no IP addresses available to assign to a host or interface.

Ideal would be something like:

Block (defined range where loopbacks would be assigned from) -> Host/Interface

or

Block -> Subnet -> Host/Interface

I'm open to workarounds if anyone has one.

Many thanks.

Matt

02-05-2012 22:13:03

hrrmmmm.. I could have sworn I fixed this and made it possible to add subnets with a /32 and then assign the one IP to a host. I just tried it and it didnt work. I'll have to dig out some code and see what is up. It would seem I somehow didnt check in that set of changes?? silly me.

Hopefully I can find an old copy that still has this work in it. ............ That or I just try and remember what I did.

check back soon.

JoeLT

03-05-2012 03:49:15

Thanks for the fast response Matt. That would be fantastic if you have a fix. I'll keep a lookout for it.

Matt

03-05-2012 11:39:09

Well first off lets see if you have the php gmp module installed on your system. do a 'php -m' and look fo gmp. That is one factor in why this may not work. If you do not have it installed, try installing it and see if that fixes the problem.

I'm seeing the updates I would expect in the latest released version.. I'm just not seeing why its failing at the moment. Still looking into that one.

Anyway, give gmp a try.

JoeLT

04-05-2012 02:11:24

I see that the gmp module is installed:


[PHP Modules]
bz2
calendar
ctype
curl
date
dbase
exif
filter
ftp
gettext
gmp
hash
iconv
json
libxml
mbstring
mysql
mysqli
oci8
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
posix
pspell
readline
Reflection
session
shmop
SimpleXML
snmp
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
zip
zlib

Do the updates you mention also cover subnets with a /31 mask which we use for point-to-points? Thanks.

Matt

04-05-2012 08:56:02

Dang I was hoping for it to be something simple. well I have it working on the ONA install at work. not sure why its not working on the others as I see the same basic code. still digging through diffs on that...

Yes it supports /31 as well for P2P links.

JoeLT

23-05-2012 04:24:59

Hi Matt - were you able to find anything on the /31 and /32 subnets? Let me know if I can do anything to help out. Thanks.

Matt

24-05-2012 21:22:44

Well I can't explain it at this moment. I have just done a fresh install from the github code on my ubuntu 12.04 system. it worked with no issues. I've tried both with and without the gmp php module.

You might install from there if you have not yet. It "should" work for you.. I'm looking at the code that is in the latest tarball release and I dont see any differences there that should matter so I'm puzzled as to why its not working for you.

I'm pretty confident the code itself is capable. it would seem there is something else at play, maybe php related? Lets give the github code a try and see?

thanks

JoeLT

25-05-2012 10:46:41

I did an upgrade installation from the github code as suggested. I also upgraded PHP to 5.3.13. I created a subnet with a /31 mask and unfortunately still no difference - if I click to find available IP addresses to assign, the list is empty.

I think I will try a fresh install somewhere and see if I can figure out the differences. Will keep you posted. Thanks.

Matt

25-05-2012 18:53:55

hmm so more ideas. You mentioned no available IPs in the list. That is probably the case still, I dont believe I fixed that part of the code. Soooo.. if you are able to add the subnet with a /31 subnet you should be ok. You can still just type in the IP address as needed.

With that said, I have noted that there is still a problem that I need to fix. it seems that the top end check is still failing so on a /31 subnet I can add the first IP but not the second. On a /32 it wont work at all since there is only the one IP.

I must still be missing something because I know I have added /32 hosts before.. ... more to come....

Matt

26-05-2012 20:45:26

ok more testing.. I just fixed the available IPs dialog to work with /32 and /31 subnets.. it did not show anything before. my testing seems to work with both types of subnets as I would expect.. try pulling the latest stuff from github and give it a go.

JoeLT

13-06-2012 07:09:52

Hi Matt - I downloaded the github code and after a PHP upgrade, all is working. Many thanks for your help.

Matt

13-06-2012 08:07:54

Great, glad you got it working. And thanks for the update, I was wondering how it was going. Do you remember what version of PHP were you running? Just curious for future reference.

Thanks