NotionCommotion Posted April 9, 2017 Share Posted April 9, 2017 Network masking has always been a little bit of a mystery to me, and I would like to better understand. It is my understanding that there can only be about 4 billion IPv4 IP addresses in the world (4^32). Some of these are special such as 127 loopback and 255 broadcast. And then their are some which are non-routing or private and can be used by everyone without chance of conflict. For these private networks, there appears to be 3 types: Class A networks where only one can existing on a given network? and which can have 2^24 IPs (16,777,216) where the remaining 8 bits are used to specify it is a class A network? Class B networks where only 16 can existing on a given network? and which can have 2^20 IPs (1,048,576) where 8 of the remaining 12 bits are used to specify it is a class B network and the remaining 4 bits are used to specify which of the 16 (172.16 to 172.31) it is? Class C networks where only 256 can existing on a given network? and which can have 2^16 IPs (65,536) where 8 of the remaining 16 bits are used to specify it is a class C network and the remaining 8 bits are used to specify which of the 256 (198.168 to ???) it is? Is this basically correct? Please correct me as appropriate. So, to allow these private IPs to be used by multiple networks without conflict, we need a mask of 8, 12, or 16 bits for Class A, B, and C networks, respectively. Why does doing so allow them to be reused? Thanks! PS. Sorry, I am sure this isn't really PHP specific, but didn't know where else to post it. Quote Link to comment https://forums.phpfreaks.com/topic/303668-understanding-network-masking/ Share on other sites More sharing options...
Jacques1 Posted April 9, 2017 Share Posted April 9, 2017 Network classes are obsolete and have been mostly replaced with classless routing (CIDR). Historically, the private address ranges are indeed based on the class concept. The first block is equivalent to one big class-A network. The second block can be interpreted as 16 medium-sized class-B networks. And the last block contains 256 small class-C networks. But in practice, none of this matters. You just have to know the available ranges, and then you can define your own address structure. With CIDR, the length of the network prefix is arbitrary and must be specified together with the network identifier. For example: 10.2.3.0/24 This means the first 24 bits are the network prefix, and the remaining 8 bits are for the hosts identifiers. So within this network, you can have 254 hosts (10.2.3.1 … 10.2.3.254). If you want bigger networks, you make the network prefix shorter. For example: 10.1.0.0/16 This network can have up to ~65,000 hosts (10.1.0.1 … 10.1.255.254). You could also define /11 or /23 networks – whatever you need. Conflicts are only prevented in the sense that private addresses aren‘t used on the public Internet. So as long as your LAN isn‘t connected to my LAN, we can use the same addresses. However, there will be conflicts if you merge LANs which use the same private addresses. 1 Quote Link to comment https://forums.phpfreaks.com/topic/303668-understanding-network-masking/#findComment-1545253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.