# Ip address restriction

Discussion in 'Kernel Questions' started by Harsh Shah, Dec 3, 2019.

1. ### Harsh ShahBanned

Hi
I want to know that Is it possible that maximum number of hosts in a network, can restrict class of ip address that can be used for network ?
I have tried to get the answer for it but didn't get proper answer.

2. ### TalemanWell-Known MemberHowtoForge Supporter

I admit I do not understand the above question.
So just some random thoughts here. The maximum number of hosts is restricted by the number of IP-addresses in the subnet. One of the addresses is used by the network address, one is broadcast address and usually one address is for the gateway. So subscract 3 from the number of IP-addresses. The Class A, B, C networks are I believe deprecated nowadays, but C class network is 255 IP-addresses and so allows 252 hosts.
https://en.wikipedia.org/wiki/Subnetwork
http://www.subnet-calculator.com/

3. ### nhybgtvfrWell-Known MemberHowtoForge Supporter

number of possible hosts/ip's is controlled by the netmask

eg 192.168.0.0 mask 255.255.0.0 allows 65536 addresses, including the network address and broadcast address, so 65534 possible host IPs'
192.168.40.0 mask 255.255.255.0 (192.168.40.0/24) allows 256 addresses, including network and broadcast, so 254 possible host ip's.

Basic rules:
1. The total number of IP addresses in a subnet is a power of two. So that's: 1, 2, 4, 8, 16, ... etc.
2. The first IP address in a subnet is a multiple (0, 1, 2, 3 ...) of the number of IP addresses in the subnet.
3. 'x' in netmask '255.255.255.x' is 256 - number of IP addresses in the subnet.
4. In slash-notation, the netmask is '/y', where y = 32 - n, and 2ⁿ is the number of addresses in the subnet.
So if we want 4 addresses in our subnet, the first address in this subnet is either 0 or 4 or 8 or 12 or ... etc.
And 'x' in netmask '255.255.255.x' is: 256 - 4 = 252. So the netmask is: '255.255.255.252'.
4 = 2², so n = 2 and y is 32 - 2 = 30. The slash-notation netmask is therefore: '/30'.

Note: You can't actually use IP addresses a.b.c.0 or a.b.c.255

Size