Class C network, calculating next subnet range. - networking

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

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

Calculate a network between two 2 IP address non CIDR

I have problem Where I have given two IPv4 address and I have to calculate best possible network between them . For example I have 10.240.204.160 and 10.240.220.160 and I have to find all minimum available subnets between.
Please note that these two IP addresses are not CIDR notation.
The solution which I thought .i.e
get the number of host between them (it is 4096 here)
find set bit in 4096 which is 12th bit
Now create a subnet mask of 20 i.e 255.255.240.0
This way I will get subnet masks in between those two IP addresses
Now the question is suppose I got 255.255.240.0 then anding it with start IP it will give network 10.240.192.0/20 which will serve
10.240.192.1 to 10.240.207.255 but I started with 10.240.204.160 to 10.240.220.160 hence It would be breaking wrongly
Feels like I will be doing huge mistake If I go with my version of story.
Anyone here please help me.
I was looking for pre-made code and stumbled on this thread. I ended up writing the following in python. You always have the chance that you will span 2 subnets. You were just missing the last step here to check and expand by one bit on the netmask if necessary.
def calc_inclusive_subnet(ip1, ip2): #accepts 2 IP strings
#make IP Address objects
ip1_obj=ipaddress.IPv4Address(ip1)
ip2_obj=ipaddress.IPv4Address(ip2)
if ip1_obj<=ip2_obj:
min_ip=ip1_obj
max_ip=ip2_obj
else:
min_ip=ip2_obj
max_ip=ip1_obj
distance = int(max_ip)-int(min_ip)
ip_range=0 #increment powers of 2 until you have subnet distance
while 2**ip_range < distance:
ip_range += 1
net = ipaddress.IPv4Network(str(min_ip) + '/' +str(32-ip_range), strict=False)
if max_ip not in net:
# i.e. if the distance implies one size network, but IPs span 2
ip_range+=1
net = ipaddress.IPv4Network(str(min_ip) + '/' +str(32-ip_range), strict=False)
return net
You're using the wrong mask. You should use a /19 instead of /20.
A /20 offers you 16 subnets. Simple math learns us 192+16 = 208 (192 is the result of 0 + 16 = 16, 16 + 16 = 32, 32 + 16 = 48, etc)
A /19 offers you 32 subnets --> 192 + 32 = 224
Keep in mind 224 is the start of the next network. Your /19 network will have subnets starting from 10.240.192.0/24 to 10.240.223.0/24.
10.240.204.160 and 10.240.220.160 belong to the 10.240.192.0/19 network.

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