Understanding subnetting - networking

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

Related

How to perform IP subnetting on 192.168.0.0/16?

I need to have at least 30 subnets.
Also, in this case, what is the number of bits borrowed, and bits left?
I am confused with the many information I got online. I appreciate any help. Thank you in advance.
For an easy explanation, I need to write down the subnet mask in binary format:
IP: 192.168.0.0/16
Netmask (Decimal Format): 255.255.0.0 or,
Net mask (Binary Format): 1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
As far as the Netmask and (/16) show 16 bits belong to network portion and 16 bits belong to host portion. In order to make 30 subnets, you need to add 5 bits of host portion to the network portion. Then 11 bits remain in host portion that provide {(2^11 = 2048), or [(2^3 = 8) * (2^8 = 256)] = 2048} IP address for each subnet.
As a result of adding 5 bits to the network portion, the new subnet mask becomes:
CIDR: /21
Decimal: 255.255.248.0
Binary: 1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.0.0.0.0.0.0.0.0.0.0.0
Note: This way, you can create (2^5 = 32) subnets. However, you should know that you can’t create exactly 30 subnets since the IP works in binary format. Therefore, you have to create either (2^5 = 32) subnets or (2^4 = 16) subnets. As far as 16 subnets don’t meet your requirement, you would choose 32 subnets.
Now you can assign each subnet 2048 IP address and write down as following:
1st subnet: (192.168.0.0 ~ 192.168.7.255)/21
2nd subnet: (192.168.8.0 ~ 192.168.15.255)/21
3rd subnet: (192.168.16.0 ~ 192.168.23.255)/21
…
30th subnet: (192.168.232.0 ~ 192.168.239.255)/21
31st subnet: (192.168.240.0 ~ 192.168.247.255)/21
32nd subnet: (192.168.248.0 ~ 192.168.255.255)/21

What is the subnet (network and CIDR) for "half" of the IPv4 address space?

What is the subnet (network and CIDR) for "half" of the IPv4 address space? I do not mind if this includes (it inevitable will) private/reserved IP subnets.
To put it even more in context: the subnet/CIDR for the whole IPv4 range is 0.0.0.0/0
The two ranges 0.0.0.0/1 and 128.0.0.0/1 cover the whole IPv4 space.
CIDR format is a.b.c.d/x where a, b, c and d are the decimal representation of the 4 bytes in the IPv4 address and x is the length of the subnet mask.
To divide the whole range
00000000.00000000.00000000.00000000 to 11111111.11111111.11111111.11111111
in two parts you just consider the ranges
00000000.00000000.00000000.00000000 to 01111111.11111111.11111111.11111111
+
10000000.00000000.00000000.00000000 to 11111111.11111111.11111111.11111111
I hope this answers your question.
there are 32 bits in an ipv4 address. All CIDR(classless Interdomain Routing) does is count the number of bits that are ones in sub net mask in the format /32 = 32 1's. Also called running ones from left to right. For 0.0.0.0/0 the cidr is /0 bc the subnet has 0 running ones in it.
Ex: 192.16.0.0 /16 = subnet mask 255.255.0.0 because there are 16 running one from left to right 11111111.11111111.00000000.00000000
In binary 8 ones = 255
Similarly, this concept is used for calculating VLSM(Variable length subnet masking)
Ex.
172.30.64.1 /18 = subnet mask 255.255.192.0
11111111.11111111.11000000.00000000 bc /18 means there are 18 running ones in the subnet mask. The third octet is 192 bc 11000000 in decimal is 128+64=192.
Hope this helps! -j

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

CIDR / subnet mask

I am trying to understand how subnetting is involved in CIDR notation. As far as I understand, there is a network and host portion to every IP address. The netmask specifies how many leading bits should be used in this network portion, while the remaining bits become the possible hosts. Before CIDR was created, I understand that there were different classes A-D (0, 10, 110, 1111 leading bits) that had very specific netmasks, and that you could add a subnet mask by taking away some of the host bits.
What I am confused about is if you want subnets using CIDR notation, do you still need a separate subnet mask along with the CIDR notation? As far as I am aware, CIDR simply supports more flexible netmask length (so you don't end up having something like 65536 possible hosts when you only need like 400). But something like 174.43.8.0/23 still only has 1 single subnet, and 512 possible hosts. If you wanted subnets for this wouldn't you still need to add a subnet mask like 255.255.255.0 if you wanted 2 different subnets?
You're on the right track. CIDR provides a classless way of allocating subnets that is more versatile than the original Class A-C system. It is another way of specifying a subnet mark, but with a more compact notation than specifying a netmask like 255.255.255.0.
To understand CIDR, you have to first understand that that a subnet mask is four eight bit numbers (called octets) that form a 32 bit value. A CIDR of /24 or /8 is just a way of representing how many of the leftmost bits in that 32 bit value are 1's, with the 0's on the right side representing the size of the subnet (stay with me here...I'll make that clearer in a second).
If you want a subnet with 16 IP's, you need a netmask of 11111111 11111111 11111111 11110000. You'll notice that there are four zeros in that mask, and there are sixteen possible values that you can specify with four bits. Written in CIDR notation, this would be a /28 network (32 minus the four "zero" bits)
Similarly, if you want a subnet with 512 IP's, you need to set nine of the bits in your 32-bit subnet mask to zero (because a nine bit binary number has 512 possible values from 0-511). So that would be 32-9=23, or a /23.
Now one last thing you need to remember. For every CIDR, you will always have some IP addresses that can't be used for hosts (these are used for broadcast and gateway). You can find a nice cheat sheet showing the actual numbers here:
http://www.rjsmith.com/CIDR-Table.html
Hope that helps!

Calculating range of IPs from subnet mask

Say, I have a subnet of 255.255.255.242 and I have a known IP within that subnet say 192.168.1.101.
Now the way I calculate the range of IPs is this:
In the subnet mask, find the first octet that is not a 255. In my example, its the 4th octet, and its 242. So take 256 and subtract 242, which gives us 14. So we now know that these networks, the 192.168.1.x networks, all have a range of 14. So just start listing them...
192.168.1.0
192.168.1.14
192.168.1.28
....42
....56
....70
....84
....98
....112
Here we can stop. My address, 192.168.1.101 falls into the .98 network. .98 encompasses all ip addresses from 192.168.1.98 to 192.168.1.111, because we know that 192.168.1.112 starts the next network.
I want to confirm, whether this is the right and the easiest process to do so.
A netmask is a series of 1 bits. The bits must be sequential with no 0 gaps. Anything using a 1 bit is part of the network, anything remaining is valid for host assignment within that network. A 255.255.255.224 has 27 "1" bits, which means it's a /27 network.
To calculate this right, you need to convert IPs to a numeric representation. For example, 255.255.255.224 is 11111111 11111111 11111111 11100000 which is 4294967264. 192.168.1.101 is 3232235877 (11000000 10101000 00000001 01100101).
If you take the IP and bitwise AND it with the netmask, that gives you the network address. This is the bottom end of the range:
11111111 11111111 11111111 11100000 (mask)
11000000 10101000 00000001 01100101 (ip)
-----------------------------------
11000000 10101000 00000001 01100000 = 192.168.1.96 (network address)
The complement (bitwise NOT) of the mask gives you the size of the range:
00000000 00000000 00000000 00011111 = 31
Thus, the range for that IP is between 192.168.1.96 - 192.168.1.127. (127 = 96 + 31)
Thanks to both of you Joe and dig_123 but, Joe's answer could have been clarified with a /28 subnetinstead of the stated /27 witch would have been closer to his example and fallen between 92-112.
so, Joe if I get your point right you are saying that you take the subnetted octet; determine the increment bit value and add it to the subnet value in the SN octet, this should give the range and provide the values for the Network, first host, last host, and broadcast addresses. Is that correct? i.e. in my example the 4th octet would be a 240 and the increment would be 16. Since the value in the 4th octet is 96, it falls within the calculated range for a 16 bit increment, in fact it falls between 96 and 112 which is one of the 16 bit ranges so we can conclude that our network address for this example is:
0-15
15-31
32-47
48-63
64-79
80-95
96-111
112-127
128
NW 192.168.1.96 /28
1st 192.168.1.97 /28
Last 192.168.1.110 /28
Bcast 192.168.1.111 /28
To add something to Joe's answer: if you want to do the operations more programmatically (assumes knowledge on bitwise operators).
You already know that only the last number will change, but this method could be used in a slightly different way for other cases as I show later.
Number from mask: 224
Number from IP: 101
Using e.g. python or your favourite calculator program:
Start address byte: 224 & 101 = 96
End address byte: (~224 & 255) | 96 = 127
(~224 & 255) just sets to one every bit that wasn't one in 244 (that is, the last 5 bits); OR'ing the result with 96 just copies the first 3 bits from the first address.
So, the result is the expected: 192.168.1.96 - 192.168.1.127.
If the mask ends before the last number there is a very similar procedure; let's do an example:
Let's use 255.224.0.0 as mask, and the same IP address (192.168.1.101).
Again there is only one number to take care of, which is now the one in second position: 168.
Start address byte: 224 & 168 = 160
End address byte: (~224 & 255) | 160 = 191
Now, the number on the left (first position) remains the same (192) and the rest of the numbers on the right range from 0 to 255 (depending on what they ask, it may also be from 1 to 254).
So the solution would be: 192.160.0.0 - 192.191.255.255

Resources