ok, there is some misinformation going on here. Yes, what you described will work. But the mixed subnet masks is usually not a good idea just from a organization aspect. But it is certainly allowed.
So this may be more background than you wanted, but i wanted to set the record straight.
Class a addresses range from 1.0.0.0 - 127.255.255.255. So for example, 10.0.0.1 starts with a 10 so it is a class a address. Class a addresses use 8 bits to represent the network address and 24 bits to represent the individual hosts. So with class a i could have 128 individual networks with each network containing over 2 billion host devices.
Class b addresses range from 128.0.0.0 - 191.255.255.255. So for example, 172.16.0.1 starts with a 172 so it is a class b address. Class b addresses use 16 bits to represent the network address and 16 bits to represent the individual hosts. So with class b i could have 16,384 individual networks with each network containing over 65,000 host devices.
Class c addresses range from 192.0.0.0 - 223.255.255.255. So for example, 201.35.0.1 starts with a 201 so it is a class c address. Class c addresses use 24 bits to represent the network address and 8 bits to represent the individual hosts. So with class c i could have over 2 million individual networks with each network containing over 256 (actually 254) host devices.
We won't get into class d or e.
Class a typically use a subnet mask of 255.0.0.0
255 = 8 consecutive 1 bits followed by 24 consecutive 0 bits is often known as "/8"
class b typically use a subnet mask of 255.255.0.0
255.255 = 16 consecutive 1 bits followed by 16 consecutive 0 bits is often known as "/16"
class c typically use a subnet mask of 255.255.255.0
255.255.255 = 24 consecutive 1 bits followed by 8 consecutive 0 bits is often known as "/24"
this is what is known as classful addressing. This basically meant if 192.168.1.1 was your ip address, then 255.255.255.0 was your subnet mask. Automatic, no ifs ands or buts.
But once ip addresses started to dwindle in availability, we saw how wasteful this addressing scheme really can be. So today, it is not required and most networking people have abandoned it. We can instead use classless addressing. But, you don't really want to mix methods as it can be very confusing and frustrating.
So with classless it is now commonplace to see a mix of address classes and subnets. So your example of 192.168.1.2 with a subnet of 255.255.0.0 is a perfectly acceptable classless address. So the whole idea of class a, b, and c are not terribly relevant with the classless addressing scheme.
Your address of 192.168.1.x with a subnet of 255.255.0.0 is simply saying that this is a network identified as 192.168.0.0. The first ip address in the range is known as the network address. The mask is identifying that the last address on your network would be 192.168.255.255. Now the very first address and the very last are reserved so (256 x 256) - 2 = 65,534 devices could all be on the same network. That is potentially a very large network. One device sending a broadcast message would go to all of those devices.
Your address of 192.168.1.x with a subnet of 255.255.255.0 is saying that this is a network identified as 192.168.1.0. The mask is identifying that the last address on your network would be 192.168.1.255. So 254 devices. That is a much smaller network. One device sending a broadcast message would be contained to only go to those devices. 192.168.0.0 would be a completely separate network as would 192.168.2.0 and so on.
But what if your network didn't require 250+ devices. What if it only needed to handle 10 devices. If we assigned 192.168.1.x with a subnet of 255.255.255.0 we would potentially be wasting 240+ ip addresses that we could use elsewhere.
So the mask of 255.255.255.0 is typically referred to as "/24" as it represents 24 consecutive 1 bits representing the network. The remaining 8 zero bits is where we get how many hosts we can have. But if we change how many network bits are used then we can affect how many host bits are available. So are not stuck with 256 or 65,000 as our only choices.
255.255.252.0 or /22 = 1024 (-2 reserved) hosts per network
255.255.254.0 or /23 = 512 (-2 reserved) hosts per network
255.255.255.0 or /24 = 256 (-2 reserved) hosts per network
255.255.255.128 or /25 = 128 (-2 reserved) hosts per network
255.255.255.192 or /26 = 64 (-2 reserved) hosts per network
255.255.255.224 or /27 = 32 (-2 reserved) hosts per network
255.255.255.240 or /28 = 16 (-2 reserved) hosts per network
255.255.255.248 or /29 = 8 (-2 reserved) hosts per network
255.255.255.252 or /30 = 4 (-2 reserved) hosts per network
so using /28 as our mask we can "sub-network" a typical range into many separate networks.
We could have the network start at 192.168.1.0 and end at 192.168.1.15
we could have another network start at 192.168.1.16 and end at 192.168.1.31
we could have another network start at 192.168.1.32 and end at 192.168.1.47
etc, etc.....
This idea of sub-netting is much more common in the it world where they have a set number of ip addresses available and they cannot be wasted through a wasteful addressing scheme. In the controls world, we typically have had relatively small networks that have been isolated from the enterprise so our addressing methods didn't really matter all that much. Today though we are seeing our control networks connecting to the enterprise network and knowing these addressing schemes becomes quite important.
So i have gone on much longer than i intended and i am sure i lost people along the way. But i wanted to make sure we understand that classless addressing is here to stay which makes the whole idea of class a, b, and c mostly irrelevant.
Og