Journal‎ > ‎

### Private Network IP Address Assignment

posted Feb 8, 2012, 8:19 PM by Sandy McArthur, Jr.
Recently I've been having fun interconnecting multiple private networks at both work and private locations. I wanted a method to deterministically assign static IP addresses and subnets without too much worry of overlap for when DHCP doesn't work. Below is what I've come up with for myself.

For my projects Class C networks in the 192.168.0.0 private network range are large enough. So I'm mapping the third octet to the network (N) and the fourth octet to a host (H). eg: 192.169.N.H

#### Calculating an Octet

To come up with the octet (0-255) decide on the text string describing that octet, normalize the name (lowercase it and remove any spaces) and then calculate the CRC32 of that string as an unsigned integer. That gives me a large number which I then divide by 256 and use the remainder (mod) as the octet.

For example: a private network located at '123 Any Street' would get the third octet of 15.
1. '123 Any Street' is normalized to '123anystreet'
2. CRC32 of '123anystreet' is 2973677327
3. The remainder of 2973677327 divided by 256 is: 2973677327 mod 256 = 15
4. Therefor the private network at 123 Any Street would be 192.168.15.0/24
For most private networks I'd let DHCP allocate the fourth octet and be done with it.

#### VPN Network Names

But for P2P VPN between hosts, like N2N or tinc, an address doesn't make sense as the key to naming the network and running a DHCP server might not make sense in such decentralized manner. In that case I'd repeat the steps above with a descriptive name such as company name or department name and a descriptive host name such as 'sandy-macbook' as the strings to CRC32.

Hope that is helpful. You can likely find commercial products that take care of much of this for you but I'm cheap and I enjoy the details.