A large number of consecutive IP address are available starting at 198.16.0.0. Suppose that four organizations, A, B, C and D request 4000, 2000, 4000, and 8000 address, respectively, and in that order. For each of these, I need to give the first IP address assigned, the last IP address assigned, and the mask int the w.x.y.z/s notation. Please explain for each organization.
Now, a few years after this question was asked I was struggling with the same task.
Actually it is a problem from Andrew Tanenbaums Computer Networks Book and you are not allowed to sort stuff :)
To solve this one you need to do as follows:
You are starting with 198.16.0.0
Now company A requests 4000 IPs. You have to round this number (and any later request too) up to a power of two - 4096.
Now let's think: An IP-address consists of 32 Bit. Some of them are network Bits and some are host Bits (if this is new for you read this). How many host Bits do you need, so company A gets 4096 hosts? Right: log²(4096) = 12. So the remaining 20 Bits (32-12) are reserved for the network. Now we already have the start IP-address for company A and also the subnet mask: 198.16.0.0/20 (again if this confuses you read the link above).
Now we need to determine the last IP-address for company A.
To do so we look at our IP and subnet-mask in binary (consider "|" the boundary between network part and host part of the ip-address):
Start-IP (A):
11000110.00010000.0000|0000.00000000
Subnet-Mask(/20):
11111111.11111111.1111|0000.00000000
As you can see, now you have 12 Bits for your hosts, all of them are free to change so you have all in all 2^12 possibilities = 4096..
The last available IP would be the one, where all hosts are equal to 1:
End-IP:
11000110.00010000.0000|1111.11111111
In dezimal this would look like:
198.16.15.255
Now let's look at company B:
it requests 2000 - we round it up to the power of two: 2048
log²(2048)= 11 host-bits = 21 network-bits = /21
Now remember the last IP we assigned to A was:
End-IP:
11000110.00010000.00001111.11111111
So the next available one should be bigger by at least 1 right?
11000110.00010000.00001111.11111111 +1 = 11000110.00010000.00010000.00000000 = 198.16.16.0
We should be able to use this one as the start IP for company B
Lets try this out with our netmask of /21:
Start-IP (B):
11000110.00010000.00010|000.00000000
Subnet-Mask(/21):
11111111.11111111.11111|000.00000000
Seems to be working! We have 11 host Bits so we can connect 2^11 hosts =2048.
The last usable IP-address however will be the one where all host bits are equal to one:
11000110.00010000.00010|111.11111111 = 198.16.23.255
Now with company C things start to get complicated, please bear with me:
The problem here is, that they require more IPs then their predecessor. But we will handle it anyway :)
Company C wants 4000 IPs we round it up to 4096 and calculate the number of hosts bits as before: hosts=20.
Now we will try the same approach as before, so that you can see the problem:
We take the last assigned IP-address and increment it by one:
11000110.00010000.00010111.11111111 + 1=
11000110.00010000.00011000.00000000
Now let us apply our netmask of /20 on this IP:
Start-IP (B):
11000110.00010000.0001|1000.00000000
Subnet-Mask(/21):
11111111.11111111.1111|0000.00000000
Now you should see the problem:
We have have a 1 in our host-bit section. Therefore we can not use all 12 Bits but only 11 which would give us only 2^11 =2018 hosts.
So you might wonder: What if we just turn the 1 in the host part to a 0? Well in that case you would completely collide with the IP-addresses you provided to company B. So this is not an option. The only way is to "push" the 1 in to the network-bit section by applying the increment to the network section only, so that instead of:
11000110.00010000.0001|1000.00000000
you get (incrementing network part only: 11000110.00010000.0001 + 1)
11000110.00010000.0010|0000.00000000
which is equal to 198.16.32.0
the last ip would be again, where all host-bits are equal to 1 so
198.16.47.255
Now you can do the same thing with company D :)
The results should be:
A: 198.16.0.0 – 198.16.15.255 written as 198.16.0.0/20
B: 198.16.16.0 – 198.16.23.255 written as 198.16.16.0/21
C: 198.16.32.0 – 198.16.47.255 written as 198.16.32.0/20
D: 198.16.64.0 – 198.16.95.255 written as 198.16.64.0/19
I'm going to keep it short. You should learn the basics of subnetting by Googling for information, I can suggest Cisco for excellent learning material.
Your network, 198.16.0.0 /16, offers you 16 bits to use as subnet/host bits. This entire network offers a bit more than 65.000 hosts.
Step 1 - Sort your subnets, starting with the subnet requiring the most amount of hosts. 8000, 4000, 4000, 2000
Step 2 - How many host bits do you need for 8000 usable hosts? 13 host bits: 2^13 = 8192 hosts - 2 = 8190 usable hosts
Step 3 - We know we need 3 subnet bits, so we can add 3 towards the 16. Our new subnet mask for this subnet is /19.
Now we'll need to use binaries to figure out the complete first subnet. All zeroes in the host part gives you the network id and all ones in the host part gives you the broadcast id.
198.16.000|00000.00000000 = 198.16.0.0
198.16.000|11111.11111111 = 198.16.31.255
Step 4 - Your subnet for Organisation with 8000 usable hosts is 198.16.0.0/19.
Network ID: 198.16.0.0
First usable host: 198.16.0.1
Last usable host: 198.16.31.254
Broadcast ID: 198.16.31.255
Now we repeat those steps for the remaining 3 Organisations.
Step 1 - We know our next subnet needs to support 4000 usable hosts.
Step 2 - How many host bits do you need for 4000 usable hosts? 12 host bits: 2^12 = 4096 hosts - 2 = 4094 usable hosts
Step 3 - We know we need 4 subnet bits, so we can add 4 towards the 16. Our new subnet mask for this subnet is /20.
Now we'll need to use binaries to figure out the complete first subnet. All zeroes in the host part gives you the network id and all ones in the host part gives you the broadcast id.
Because we have already subnetted the network, we start where we ended.
198.16.0010|0000.00000000 = 198.16.32.0
198.16.0010|1111.11111111 = 198.16.47.255
Step 4 - Your subnet for Organisation with 4000 usable hosts is 198.16.32.0/20.
Network ID: 198.16.32.0
First usable host: 198.16.32.1
Last usable host: 198.16.47.254
Broadcast ID: 198.16.47.255
I have shown you the way for the first two. You can do the last two yourself as practice. Remember to first do the subnet with 4000 hosts and then the subnet with 2000 hosts. If you have any questions, don't hesitate to ask.
To start with, all the requests are rounded up to a power of two. The starting address, ending address, and mask are as follows 1:
A: 198.16.0.0 – 198.16.15.255 written as 198.16.0.0/20
B: 198.16.16.0 – 198.16.23.255 written as 198.16.16.0/21
C: 198.16.32.0 – 198.16.47.255 written as 198.16.32.0/20
D: 198.16.64.0 – 198.16.95.255 written as 198.16.64.0/19
Related
I have an Ipv4 180.3.0.0 (class B, network bits reserved - 16bits).
What are my possible subnet masks if i want my network to have at least 22 subnets and 120 maximum hosts?
I can understand that i need to give 5 bits for 22 subnets and 7 bits for 126 usable hosts but i can't undestand how when the question ask a minimum 22 subnets and a maximum 120 hosts each subnet.
What i tried so far is i tried to give certain bits to the subnet part and the others to hosts part, creating a range of possibilities but i don't see how that solves my problem.
Anyone can help me understand the logic behind this?
As I see it, the "at least" and "maximum" constraints indicate the priority of the values: the 120 maximum hosts carries a bit more weight as it dictates the size of mask you will need to use even after you've satisfied the number of subnets constraint. With a /16 network it would be easy to subnet it to provide more than enough large networks. For example, you could subnet it to a /24 and get 256 subnets (which is fine given the at least 22 networks condition) each with 254 host addresses. However, this fails the maximum 120 hosts constraint. So to satisfy the scenario you must select a mask that still provides many more subnets than required but that are each smaller in size (less than 120 hosts).
Lets suppose I get given the network (57.70.32.0/21) and I need to divide it into 4 equally sized networks.
I know the mask at the moment is (255.255.248.0) but would I need to change the prefix length of the network given to 26 so I can get the 4 equal size subnets? Basically that's my biggest question and also if I should then use the 4th octet for subnetting or stay with the 3rd to do it.
Any help would be extremely appreciated.
you can divide your ips into 4 networks with 510 IPs each, not counting gateway, broadcast, and net id.
each net will have a cidr of /23 which would equate to subnet 255.255.254.0
you could divide them into subnets as follows:
57.70.32.0/23
first address: 57.70.32.0
last address: 57.70.33.255
57.70.34.0/23
first address: 57.70.34.0
last address: 57.70.35.255
57.70.36.0/23
first address: 57.70.36.0
last address: 57.70.37.255
57.70.38.0/23
first address: 57.70.38.0
last address: 57.70.39.255
I have found this website calculator that explains the ip class's (A,B,C,D,E ) and also how to get the subnet mask, he was not very clear about how to configure the number of nodes (formula for figuring out the number of 'host' bits), he says 'Since you know the number of nodes, you need to find 'n'.' to get 2^6 - /26. I don't understand how he knows to use 64 nodes.
subnet calculator
First depict the ip address in binary. Take 61.246.19.18 and convert to binary:
ip address: 00111101.11110110.00010011.00010010
First we determine what class of address it is:
If the first bit is 0 it is a Class A address If the first two bits are 10 it is a Class B address If the first three bits are 110 it is a Class C address If the first four bits are 1110 it is a Class D multicast address If the first four bits are 1111 it is a Class E experimental address
Your example is a Class A address. The default subnet mask for a Class A address is:
subnet mask: 11111111.00000000.00000000.00000000
The formula for figuring out the number of 'host' bits in a subnet mask is
2^n=(number of nodes ) (2^n means '2' to the power of 'n')
Since you know the number of nodes, you need to find 'n'.
Because you want 64 node(s), you want to leave 6 - '0' bits in the subnet mask since 64 = 2 ^ 6.
This will give you the following subnet mask:
subnet mask: 11111111.11111111.11111111.11000000
Which is referred to as /26 or in dotted decimal notation as 255.255.255.192
Most of the topics here i have searched say this cannot be done to find the /cidr range from a given ip address, but this webpage subnet calculator does create the range from a given ip. I understand how to convert ip to binary and also get the class subnet mask, but he did not use these to get his 64 host bits result, I think he skipped how to configure the hosts bits after he converted the class subnet mask.
also alot of the online calculators also require you to manually put the cidr range, to get the ip's range, etc. this seems to be the only calculator example i can find that will create the ip information with only the given ip address.
I need to collect the ip range from just the given ip to block a user from my website from registering, if they have already been banned for chargeback reasons. So I would like to create a php script to compare a new user ip to the banned ip's list ranges. which would determine if they are ban evading by creating new accounts.
Thanks for any help.
From Networking point of view:
/26 means 26 Network bits and 6 hosts bits.
For simplification you can use this formula
Network Bits (NB) + Host Bits (HB) = 32
/26 represents netmask or we can say NB= 26, which means HB = 32-26 = 6
Which means you will have 64 nodes (2^HB => 2^6 = 64) in single subnet.
This simple CIDR Tutorial can be helpful.
You can also identify smallest possible network size from given IPs.
Convert those IP to binary.Then calculate the common bits in IPs, that will be the network bits, based on which you can find subnet mask.
For example
Let's say we have 2 IPs
192.168.24.12 and 192.168.24.76
192.168.24.12 in binary 11000000 10101000 00011000 00001100
192.168.24.76 in binary 11000000 10101000 00011000 01001100
Here first 25 bits are common bits. Which means these IPs can be from /25 subnet.
In this example, the number of nodes is your own input. This is you saying, I have 64 machines and I need to find enough IPs for them all on my given network. Then you use this calculation method to determine the subnet mask and IP allocation.
The article does a poor job explaining this, though.
This was one task I had as homework I just can't seem to understand. And my teacher is having a hard time explaining it to class. So here I am:
The problem:
What is the subnet mask of following host-address range? 99.224.0.1 - 99.239.255.254
My solution (or as far as I got)
First i wrote down the IPs in binary:
99.224.0.1
01100011.11100000.00000000.00000001
99.239.255.254
01100011.11101111.11111111.11111110
What I know is this is a A class network. And I thought it must have something to do with the difference in the bits, so I started to compare. (highest first)
01100011.11101111.11111111.11111110
01100011.11100000.00000000.00000001 (diff)
-----------------------------------
00000000.00001111.11111111.11111111
I ignored the last bit, because of the network / broadcast address.
Now I can turn it around and have my subnet mask?:
11111111.11110000.00000000.00000000
255.240.0.0
My question is: Is my approach correct? Is there an easier way to do it (by hand, or calc)?
If I'm very far from the correct way to do it, could someone help me understand?
Thanks for any help.
Your answer is correct, except that classful addresses don't exist anymore. The internet moved to Classless Inter-Domain Routing (CIDR) in 1993 so your terminology is a bit outdated ;)
IP networking these days works with routing prefixes. A prefix is a range of IP addresses defined by the first address in that range and the number of fixed bits at the start of the address. Your example shows this nicely.
Your example range is 99.224.0.1 - 99.239.255.254. Actually it is 99.224.0.0 - 99.239.255.255 because when used on a subnet the first and last addresses are reserved (but still part of the subnet and prefix).
The first address in the prefix we already have: 99.224.0.0. You can see the prefix length from your binary calculation (slightly modified):
01100011.11101111.11111111.11111111
01100011.11100000.00000000.00000000
----------------------------------- (xor)
00000000.00001111.11111111.11111111
----------------------------------- (not)
11111111.11110000.00000000.00000000
Just count the number of 1s at the beginning: 12. So your prefix is 99.224.0.0/12. This prefix covers all addresses that match 01100011.1110****.********.********.
When writing the prefix length down as a subnet mask you indeed get 255.240.0.0.
A little off-topic here because it is about networking and not about the algorithm to calculate the subnet mask, but maybe helpful: an example of how you can plan network addressing:
Lets say that for my office building I get IP addresses 192.0.2.0/24 (that is 192.0.2.0 - 192.0.2.255, subnet mask 255.255.255.0, 256 addresses). I need 50 addresses for servers, 100 addresses for employee devices and 40 addresses for guests.
Because addressing works with prefixes everything you get is a power of 2. If you use a /24 you have a prefix with 256 addresses. The full address is 32 bits, the first 24 are fixed so you have 8 bits left to use. 28 = 256. If you use a /25 you have a prefix 128 addresses, a /26 has 64 addresses etc.
That way you can also split up a prefix. 192.0.2.0/24 can be split up into 192.0.2.0/25 and 192.0.2.128/25. And those can be split again and again until you have a prefix that covers only a single address: a /32.
back to the example. To get (at least) 50 addresses for the servers I need to round up to the next power of 2. That is 26 = 64. To have that many addresses I need a /26 prefix. For the client devices I need to round up to 128 (27) so we need a /25. For the guests the next power of 2 is 64 (26) so a /26.
So we need to split up out /24 into a /25 and two /26s. One possible solution is:
Client devices: 192.0.2.0/25
Servers: 192.0.2.128/26
Guests: 192.0.2.192/26
Once we configure these subnets on our devices the first and last address of each subnet become special (the network and broadcast address) so we can use these ranges for our devices:
Client devices: 192.0.2.1 - 192.0.2.126
Servers: 192.0.2.129 - 192.0.2.190
Guests: 192.0.2.193 - 192.0.2.254
Rgd: Subnetting about 370 hosts on a /24 Network
I am doing subnetting for the following.
There is a school, which got level 1 which is main lobby and 5 levels of classrooms ( level 2 to 6 )
I calculated that level 1 will use 161 hosts.
Level 2-6 - each will use 55 hosts per level
So i was wondering how do i subnet it .
For the main IP address is 203.218.71.0/24
I was thinking to subnet 3/4 to Main Lobby - I can split the main lobby into 3 sections with about 60 hosts each section
I was thinking to subnet 1/4 to level 2-6 floor
Which then further subnet them by slicing into 2 slice ( 4 levels per slice )
Each slice will have about 60 hosts ( can settle 4 levels )
Total we will use 5 out of 8 slices ( 1/2 x 1/4 ) - 5 levels
But for the ip address, how do i do it, is my subnetting workable ?
My main purpose is to link the whole school and cover the internal network, which the one connect to the internet is the main router > which then distribute to the switch & access point and do the linking.
Thanks
Hope to see your comment & thanks for helping.
You can't put 370 hosts in a single /24 - there's only room for 254 hosts in a /24.
In any event, subnetting should be split by function and not by physical location.
Rather than looking at levels, look at what groups of systems actually need to be in the same broadcast domain. Use VLANs to allow machines to exchange traffic directly on the same subnet, even if they're on different floors.
Keep student accessible machines separate from school administration, and put a firewall between them.
Look at using NAT where appropriate (class room machines?).
Unless you have a specific need for every host to have a public IP address (which you can't do anyway, see Alnitak's response above), I would stay away from it, for a number of reasons. You don't need a /24, a /30 would likely suit your needs just fine, using .1 as your provider gateway and .2 as your main WAN IP.
Use NAT for your segments, and use a logical RFC1918 scheme. For example, use 192.168.1.0/24 for the first floor, 192.168.2.0/24 for the second floor, etc.. Factor in eventual growth, so maybe bump each segment up to a /22. Private IP space is free and plentiful. Use 10.0.0.0/8 and give out a /16 to each floor if you want, whatever works for your eventual needs.
Overall, good design trumps all. The alternative is a lot of wasted time and energy to re-number everything after the fact. If you need additional public IPs for a specific reason, change to suit your needs, but public IPs for classroom use is a big waste of precious IPv4 resources that can easily be served by NAT.
Also, when listing your equipment, it would be helpful to note the actual devices you are using, so appropriate procedures can be pointed out. As a start with NAT, here is the main Cisco doc for it (again, I have no idea what equipment you are using, so take this link with a grain of salt if you're not using Cisco gear):
http://www.cisco.com/en/US/tech/tk648/tk361/technologies_tech_note09186a0080094e77.shtml