Figuring out Subnet ID and Host ID from an IP address - networking

I have an exam practice question which reads: a class B network node has an IP address 10.10.155.59 and subnet mask 255.255.248.0. What's the subnet ID and host ID in decimal?I know the answer is 38 and 827 so it's not homework help - would just love a simple explanation of how it got there. Thanks for any help :)

I think this is what you mean? Yet I think your 38 is incorrect.
10.10.155.59 = 00001010.00001010.10011011.00111011
So a class B network is /16 and you have a /21 network. So you would get this:
00001010.00001010 - 10.10 = Network ID (16 bits)
10011 - 19 = Subnet ID (5 bits)
01100111011 - 827 = Host ID (11 bits)
Also have a look here.

You have to check that in which octet the change is going to occur, so in your question it is 3rd octet so take the 3rd octet (155) & change it to binary then and (multiply) it with the subnet mask /21 in which two octets are already completed (/16) just the 3rd octet is there in which the change is occurred means some bits of 3rd octet are on & some are off.
3rd octet binary is 11111000 & and (multiply) it with the 155 binary 10011011 whatever the answer will be that will be considered the network ID of the given IP

Related

How does a CIDR range specify the IP addresses within it?

I have read a number of articles and posts about VPCs, CIDR and subnets but I still find the explanations confusing.
Many of the explanation can't help avoiding using domain knowledge or technical terms.
Is there a more basic explanation for someone who gets basic programming, binary, etc. ?
I am wondering in the context of aws VPCs.
How does a CIDR represent an IP address range ?
Start with an IP address:
xx.xx.xx.xx
This actually represents Four 8 bit numbers.
With a dot between each.
As they are 8 bit numbers, they can be from 0 up to 255 (decimal).
They are frequently shown as xx.xx.xx.xx because this is referring to them as four 8 bit numbers, shown in hexadecimal (base 16) format. In 'hex' format 255 (decimal) is written as FF
So the numbers range from 00.00.00.00 to FF.FF.FF.FF - in hex
Or 0.0.0.0 to 255.255.255.255 in decimal
For the purpose of considering how many IP 'addresses' this represents - i.e. how many individual IP addresses - you can do 255 * 255 * 255 * 255 which is 4228250625. Because you have used FOUR 8 bit numbers you multiply them together to produce that number. It is 2*32. You'll notice that the 32 is 8 + 8 + 8 + 8 and that is the four 8 bit numbers in xx.xx.xx.xx
OK, so now to CIDR. Where all the above 8 bit, base 16 and hexadecimal / binary information will be useful...
So a CIDR is a range of IP's.
For example you might want a range of 10.0.0.0 to 10.0.0.255 which is 255 IPs. You can write this using the above format, i.e. 10.0.0.1 to 10.0.0.255 but there is another way to do it and that is by using CIDR - Classless Inter Domain Routing. Lets stick with calling it CIDR. so with CIDR you refer to a range using a format like this:
10.0.0.0/24
and that means the range 10.0.0.0 to 10.0.0.255, i.e. 255 numbers.
So has does that work ? !
ok, first we are given which might be thought of as the starting address of the range - 10.0.0.1, although this is actually a bit misleading because the CIDR number is going to affect it.
So lets go piece by piece.
The "/24" refers to the number of bits on the left that stay fixed.
This is probably the hardest but also most essential piece to understand.
So taking "24". this means (conveniently with 24!) that you consider the first 24 bits, i.e. the 10.0.0 to be fixed (see bitmask). Only the last 8 bits of the xx.xx.xx.xx can change, i.e. you have a range and it is from 10.0.0.0 to 10.0.0.255
Here's one of the most surprising facts initially:
The larger the CIDR number, e.g. /28, /30, etc. the smaller the available range of IP addresses !!!
This is because the /nn CIDR number refers to how many bits are FIXED and the more bits are FIXED the less bits are can be changed to produce a range, and thus the smaller the range. This is why with /32 there is NO range because you are saying all 4 xx.xx.xx.xx numbers (8 + 8 + 8 + 8 = 32) are fixed. Whereas with 10.0.0.1/24 you can have from 10.0.0.0 to 10.0.0.255 because the 24 indicates the first three numbers (again 8 + 8 + 8 bits = first 3 numbers) are fixed) and only the last 8 bits, i.e the 'zz' in xx.aa.bb.zz can change for this range. One more example: 10.0.0.0/16 (so first two 8 bit numbers are fixed) means 10.0.0.0 to 10.0.255.255.
Because this behavior is due to a netmask 10.0.0.0/24, which produces the range 10.0.0.0 to 10.0.0.255 would produce the same result if you supplied 10.0.0.0/24, 10.0.0.73/24 or 10.0.99.17/24
See an online converter at https://ipaddressguide.com/cidr
With aws you are given 10.0.0.0/16 as your VPC which means the "10.0" part will stay fixed. so that means if you want a subnet within that you want something smaller such as 10.0.0.0/24 or 10.0.1.0/24 of which you will be able to have many.
The next thing that may be a bit unexpected is that within a VPC subnets must not overlap. However you can have multiple VPCs using that range. The second piece takes some explanation:
There are three IP ranges set aside as PRIVATE so they are never used 'publicly'. These lets each network use those as 'internal' addresses. They are the, probably familiar
10.0.0.0 to 10.255.255.255
172.16.0.0 to 172.31.255.255
192.168.0.0 to 192.168.255.255
So when you get a VPC that uses a 10.0.0.0/16 range you are getting ONE private network within "a' network. As if you were 'one' user at home using your single network. You can create another VPC because that uses another network (like having a second router in your house) and on that network 10.0.0.0./16 is available.
You currently have a default limit of 5 VPCs per region. As each VPC is using private subnet ranges, they can actually be the same for different ones as well as different, however if you ever want the VPCs to be able to communicate with each other (using VPC peering) this will be a problem because the subnets can't overlap when you do that (otherwise the router wouldn't know which subnet to pick for a given address that exists in both).
Any other corrections I am happy to incorporate wiki-style. I am not defending my knowledge, just trying to share what I think I know and help others understand this confusing concept!
Here's how you do it in aws:
Nope! You have to avoid within 10.0 - the existing public subet !
Result

CIDR and number of ip-addresses

I read 10.240.0.0/24 can host to up 254 ip-addresses. How?
How do I intuitively understand what /24 is doing here to help give 254 unique ip-addresses?
TL; DR;
A short way to compute the number of hosts would be
2 ^ ( 32 - 24 ) - 2 = 256
Because:
We are doing bit operations (0, 1, two possible values)
An IP is a set of 4 octet, when an octet is 8 bits (4 * 8 = 32)
24 is your CIDR
There is two reserved IP on every subnet, the broadcast address and the subnet zero, they shouldn't be used for hosts
CIDR is computed with the help of bitwise operations.
An IP is a set of 4 octet, each separated with a dot.
255.255.255.255
=
11111111.11111111.11111111.11111111
When you specify a CIDR of /24 you are asking for a subnet for your IPs with a mask that would be padded with 24 bits set to 1
11111111.11111111.11111111.00000000
=
255.255.255.0
Your IP is
10.240.0.0
=
00001010.11110000.00000000.00000000
Now we can apply a bitwise AND between your IP and your subnet
11111111.11111111.11111111.00000000
&
00001010.11110000.00000000.00000000
=
00001010.11110000.00000000.00000000
So you end up with 10.240.0.0 being your IP prefix.
The same subnet could be applied to subsequent IPs
10.240.0.1
11111111.11111111.11111111.00000000
&
00001010.11110000.00000000.00000001
=
00001010.11110000.00000000.00000000
Giving the same 10.240.0.0 IP prefix
10.240.0.2
11111111.11111111.11111111.00000000
&
00001010.11110000.00000000.00000010
=
00001010.11110000.00000000.00000000
Giving the same 10.240.0.0 IP prefix
And so on, and so forth
All in all, the bitwise operation is pretty straight forward:
each time you have a 0 & x it will equal 0
each time you have a 1 & x it will equal x
So that means that with 10.240.0.0/24, you have a subnet of 255.255.255.0 and so a range of IP from 10.240.0.0 up to 10.240.0.255.
That still gives you 256 possible addresses you would say?
Well, yes, but you have to remember that in IPv4, you have two addresses that are not usable:
the subnet zero (the first address of your range)
and the broadcast address (the last address of your range)
Special Addresses:
From the Assigned Numbers memo [Reynolds, J., and J. Postel, "Assigned Numbers", RFC-943, USC/Information Sciences Institute, April 1985.]:
"In certain contexts, it is useful to have fixed addresses
with functional significance rather than as identifiers of
specific hosts. When such usage is called for, the address
zero is to be interpreted as meaning "this", as in "this
network". The address of all ones are to be interpreted as
meaning "all", as in "all hosts". For example, the address
128.9.255.255 could be interpreted as meaning all hosts on
the network 128.9. Or, the address 0.0.0.37 could be
interpreted as meaning host 37 on this network."
It is useful to preserve and extend the interpretation of these
special addresses in subnetted networks. This means the values
of all zeros and all ones in the subnet field should not be
assigned to actual (physical) subnets.
Source: https://www.ietf.org/rfc/rfc950.txt
So now, if you do 256 - 2, you have your 254 available hosts.
To sum up:
CIDR: 10.240.0.0/24
Subnet mask: 255.255.255.0 (24 times a 1 when the IP is shown as groups of octet)
IP range: 10.240.0.0 - 10.240.0.255
Subnet zero: 10.240.0.0
Broadcast address: 10.240.0.255
Hosts IP range:10.240.0.1 - 10.240.0.254

Query on class B private address range

This is the range for class B private address range.
172.16.0.0 - 176.31.255.255
prefix notation for this is 172.16.0.0/12
As per prefix notation, 8 bits of left most octet and left most 4 bits in second octet can only be used to derive network ID in the IP address.
So, I can derive network address using x in xxxxxxxx.xxxx0000.00000000.00000000
My question:
Using leftmost 12 bits, How can i derive 172.17.0.0 and 172.18.0.0 network address? In general, How can i derive 172.16-172.31 range using left most 12 bits(mentioned as x)?
I am not clear about what you ask: the notation /12 leads to the net mask
11111111.11110000.00000000.00000000
NNNNNNNN.NNNNHHHH.HHHHHHHH.HHHHHHHH (network part / host part)
which can be combined with 172.16.0.0:
10101100.0001HHHH.HHHHHHHH.HHHHHHHH (H = host part)
This means that every IPv4 address which starts with these 12 bits belongs to this network.
This counts for all IPv4 addresses whose first octet is 172 and second one is between 16 (00010000) and 31 (00011111).
And this range includes 172.17.* and 172.18.* as well.
What we have talked about here is how the network part of the address forms. Inside one network, each host gets assigned an address, making use of the host part.
These addresses can essentially be freely assigned (except that the host part may not be all 0s or all 1s).
How you use/divide up your 172.16/12 is up to you.
You can see 172.16/12 see as one big network where all hosts are in, but you can as wee split it up even further:
maybe into 172.16/13 and 172.24/13
or into 172.16/14, 172.20/14, 172.24/14 and 172.28/14
or into 172.16/15, 172.18/15, 172.20/15, 172.22/15, 172.24/15, 172.26/15, 172.28/15 and 172.30/15
or into 172.16/16, 172.17/16, 172.18/16, ..., 172.29/16, 172.30/16 and 172.31/16
...
You can even mix that: you can as well have e. g. 172.16/13, 172.24/14 and 172.28/14.
Commenting on your comment:
can i say that as per prefix notation /12, the possible networks here are 172.00010000.0.0, 172.00100000.0.0, 172.00110000.0.0, 172.01000000.0.0, 172.01010000.0.0 , 172.01100000.0.0, 172.01110000.0.0 etc...
No. As said, 172.16/12 means 172 is constant and the first bits of 16 are constant.
As mentioned, that means 10101100.0001... is fix and the rest is variable.

Class C network, calculating next subnet range.

This is a very simple question with a very simple answer, I apologize for asking it however as I found the answer isn't readily available and this may help somebody else.
I have a class C address 193.50.0.1 and am using the mask 28 to split it into 16 subnets with 14 hosts.
I understand that my first address would be:
Network 195.50.0.0/28
Netmask 255.255.255.240
Broadcast 195.50.0.15
Host range 195.50.0.1 – 195.50.0.14
But I am confused where the boundaries of the next subnet start, would be simple a matter of incrementing the start and ending positions for the next 15 subnets? for example would the next network be:
Network 195.50.0.16/28
Netmask 255.255.255.240
Broadcast 195.50.0.27
Host range 195.50.0.17 – 195.50.0.26
If not, how do I calculate the next subnet?
Here is the answer:
Network 195.50.0.16/28
Netmask 255.255.255.240
Broadcast 195.50.0.31
Host range 195.50.0.16 – 195.50.0.31
You can get host range by separating IP to NET_ID and HOST_ID
NET ID = (28bits) 11000011.00110010.00000000.0001
HOST ID = (4bits) 0000 ~ 1111
So the host range is :
11000011.00110010.00000000.00010000 195.50.0.16
11000011.00110010.00000000.00011111 195.50.0.31
You can use 'AND' operation to get Broadcast
195.50.0.16 11000011.00110010.00000000.00010000
(HOST_ID are '1') 00000000.00000000.00000000.00001111
-----------------------------------------------------------------------------------
Broadcast 11000011.00110010.00000000.00011111 = 195.50.0.31

Understanding subnetting

Assume your company is given an address of 200.5.16.0/24, 5 subnets are required.
I found that:
Binary: 1111111.11111111.11111111.111000
Decimal: 255.255.255.224
Create a table that contains the network addresses of the subnets created within your network? Write down the Network Addresses, 1st and 2nd valid IP addresses in CIDR
(table displayed in below link)
http://gyazo.com/d93608e491c5197b21d0d64c34c3904a
Can someone do the first few for me and explain the process on how to do it? Thanks
The process of dividing a network into smaller network sections is called subnetting. This can be useful for many different purposes and helps isolate groups of hosts together and deal with them easily.
Each address space is divided into a network portion and a host portion. The amount the address that each of these take up is dependent on the class that the address belongs to. For instance, for class C addresses, the first 3 octets are used to describe the network. For the address 192.168.0.15, the 192.168.0 portion describes the network and the 15 describes the host.
By default, each network has only one subnet, which contains all of the host addresses defined within. A netmask is basically a specification of the amount of address bits that are used for the network portion. A subnet mask is another netmask within used to further divide the network.
Each bit of the address that is considered significant for describing the network should be represented as a "1" in the netmask.
For more details, please r
http://www.cisco.com/c/en/us/support/docs/ip/routing-information-protocol-rip/13788-3.html
You already figured out that with this mask 1111111.11111111.11111111.11100000 you can create 5 networks, just put numbers in them:
Mask: 11100000
Subnetworks:
00000000 = 0
00100000 = 32
01000000 = 64
01100000 = 96
10000000 = 128
10100000 = 160 - 192
The problem here is that you are not using the upper 64 addresses (192-255).
Alternative
You can make 4 subnetworks and split the last one:
Mask: 11000000
Subnetworks:
00000000 = 0
01000000 = 64
10000000 = 128
11000000 = 192 (split this one)
Subnetwork: 200.5.16.192/26
Mask: 11100000
Subnetworks:
11000000 = 192
11100000 = 224

Resources