Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Assigning IP Addresses

Featured Replies

Hi there,

Thanks for all the great advice on these forums. They are invaluable.

A kind soul once gave me a great script, back on the old FMMagazine forums, for assigning IP addresses based on very simple criteria. Now I find myself needing it again, but those forums are gone, I have no copy of the text, and no access to the DB where I originally used it. I'm hoping one of you can help me through the problem once more (I promise I won't lose it this time!).

Basically, I'd like the address serial to move up through both the third and fourth octets, and then loop back around at a certain point to fill in addresses no longer being used. More specifically, I'd start at 1.1.100.1 and move up through 1.1.250.255 before going back to the start. The 1.1 would be changed to accomodate different organizations, of course, but you get the picture.

I really appreciate any help you can give, even if you happen to have grabbed that script from the other forum and can paste it here, or know of a cache I can look through.

Do you mean this one:

Let ( [

B = Int ( Mod ( SerialID ; 256 ) ) ;

G = Div ( Mod ( SerialID ; 256^2 ) ; 256 ) ;

R = Div ( Mod ( SerialID ; 256^3 ) ; 256^2 ) ;

W = Div ( Mod ( SerialID ; 256^4 ) ; 256^3 )

] ;

W & "." & R & "." & G & "." & B

)

  • Author

That's exactly it, and now I remember that you're the one who shared last time, too. Thanks for the second time, Comment!

Now, I am having a little trouble modifying it to the current needs. I've changed your W and R variables to simple calls to global fields in another DB, since they won't change at all for this project, and B looks fine, too, but I just can't figure out how to make G start and wrap at different places - specifically going from 100 to 250, but if you can explain how to start and end at various numbers that would be fine.

Also, I'm wondering if it is possible to pull these numbers only when necessary, with no break in the sequence. For example, I might create 25 new records, but only 15 need an IP address. The way I have it set up now, the IPs I do assign jump from say .1.19 to .1.25 right along with the number of records. I'm thinking that I can just add a short piece to the beginning of this script that assigns the SerialID field based on the last highest entry (as opposed to leaving it a straight serial number field). Does that sound about right?

Sorry if that's confusing. I really appreciate any help you can offer, especially on the first problem, since I think my solution will work for the second.

Assigning serial numbers to only some records (or assigning different series of serial numbers to records in the same table) is always a problem. Using the last highest entry is not reliable in a multi-user scenario: 2 users working simultaneously can end up with duplicate ID's. I believe using a separate numerator table would be a better solution.

Regarding the first question, try changing G to:

G = 100 + Mod (Div ( SerialID ; 256 ) ; 150 )

Note that 150 is the size of the allowed range, obtained by 250-100=150.

  • Author

Thanks, Comment. Sorry for taking so long to reply - it's been a busy week.

I've got Everything working as suggested, assigning the IP via scripted button and using a numerator table. The button sets an inventory ID field in a new record of the numerator table matching the inventory ID field of the current record in the main table. From there, a standard auto-enter serial is entered in the IP_ID field of the record in the numerator table, and the IP address calculation takes care of the rest. It's all quite simply awesome, and your help is much appreciated.

I do have a couple of remaining questions. How should I handle deleted records? I assume the related record in the numerator table should also be deleted; is that correct? Also, If I do that am I right in thinking that the IP addresses will, should I ever get to the end at .250.255, loop back around and start filling in missing entries, or is there something different I should be doing to make that behavior occur (if possible)?

For reference, here is my current IP assignment script:

Let ( [

B = Int ( Mod ( Numerator::IP_ID; 256 ) ) ;

G = 100 + Mod ( Div ( Numerator::IP_ID ; 256 ) ; 150 ) ;

R = Int ( Globals::Octet2 ) ;

W = Int ( Globals::Octet1 )

] ;

W & "." & R & "." & G & "." & B

)

My gut tells me that something different from what I expect is going to happen, as the IP_ID field in the numerator table will continue to go up and up and up, but I'm not an expert on these things yet.

I'm off to do some testing. As always, thanks.

  • Author

OK, now I see what happens (40,000-some records later). The IP loops back as expected, but doesn't do any validation until field exit. So now I'm wondering how best to have my script check for duplicates and move to the next available value, and what to have it do in the case that no IP addresses are available at all.

As I think about it, since the IP is based on a calculation that depends on an auto-entered serial, I'm guessing it would take another approach to make something like this happen.

I'll be pondering, but in the meantime - any suggestions?

Thanks!

If you want the IP numbers to mean something, then perhaps you do need to take another approach. The calculation above takes a serial number and converts it into IP form. But it's still only a serial number, and Filemaker does not have a built-in mechanism to re-assign deleted serials.

Of course, you could just assign meaningless IPs in serial order, and use your database to store and lookup the meaning.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.