How to check if a given IP # is a subnet # address? - ip

Is there a way to check if a given IP address is a subnet IP address ?
For example :
16.100.134.0 /19
this IP address is a subnet ip address (I saw it in the solution ) but I still don't know how they figure it out.

The /19 at the end tells you that this is a subnet address.
A complete IPV4 address is 4 lots of 8 bits or octets (each shown as a decimal in the range 0 -255) so 32 bits long. /19 tells you that this is the address of a subnet where the first 19 bits are reserved for the network and subnet address and the remaining 13 are for hosts within the subnet. A subnet means that part of the host space has been used to divide up the network into smaller networks. In this case the network address may be 16.100.0.0 /16 and the subnet uses the first 3 significant bits of the host space to split it into up to 8 subnets.
So that 13 bits means up to 2¹³-1 different IP addresses available - the last octet can take values between 0 and 255, and the second last between 134 + 0 and 134 + 31
It's maybe easier to see that in binary. The address you have there is 00010000.01100100.10000110.00000000 and valid IP addresses should be in the range 00010000.01100100.10000000.00000000 and 00010000.01100100.10011111.11111111 which makes me think you have the address of a host in the subnet - the subnet address would have all 0s for the 13 least significant bits, meaning the third octet would only have it's 3 most significant bits available ie it would have a value one of 0, 32, 64, 128, 96, 192 or 224

Related

classless address block from the block adress

Consider the following classless address block:
154.78.177.3/27
List the addresses from this block that would be used as:
a) the network address,
b) the direct broadcast address, and
c) the range available for hosts to use
Show the steps you took to arrive at your answers.
154.78.177.3/27 means that this ip address is having network address to be 27 bit long ( most significant bit). i.e if we consider the ip address to be 32 bit long. So, in 154.78.177.00000011 ( last 3 number is represented as binary for simplicity) upto 154.78.177.000 (8+8+8+3 = 27) is network address and remaining 5 bit (00000) is for host ip addresses.
Note-
Network address is the first ip address of the total ip's of host.
Direct broadcast address is the last ip address of total ip's of host.
So final conclusion:
1. Network address is 154.78.177.0. This is calculated by setting all 5 bits of host id to 0.
2. Direct broadcast address is 154.78.177.31. This is calculated by setting all 5 bits of host to 1.
3. Range available for host is from 1 to 30 in the last octect. I.e from 154.78.177.1 to 154.78.177.30 ( As first and last ip is reserved for network address and direct broadcast address respectively)

Is subtracting 2 from subnet ID necessary?

The address of a class B host is to be split into subnets with a 6-bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet?
62 subnets and 262142 hosts.
64 subnets and 262142 hosts
62 subnets and 1022 hosts.
64 subnets and 1022 hosts.
My attempt :
In class B network ID is 16 bits. Given 6 bits for subnet ID, so remaining bits for host ID is = 32- (16+6) = 10 bits.
Maximum number of hosts in each subnet = 2^(number of bits for hosts) - 2(all 0's and all 1's not allowed in hosts IDs, because first is subnet ID while last is broadcast ID) = 2^10 - 2 = 1022.
I've read somewhere :
Subtracting 2 from host IDs is necessary while subtracting 2 from
subnet IDs is not necessary.
So, maximum number of subnet IDs is = 2^(number of bits for subnet ID) - 2(not compulsory) = 2^6 = 64 is maximum.
Can you explain please, Is subtracting 2 from subnet ID necessary?
Many years ago, you had to subtract 2 from the number of subnets, and older network documentation and training still states this. This was clarified in an RFC to not be the case. With the IPv4 address shortage, you need to be able to use every subnet available.
FYI, there is one exception to the rule about not using the subnet and broadcast addresses for hosts: you can use a /31 subnet for point-to-point links. The RFC which clarifies this is 15 years old, but many people still use /30 thinking it is the smallest subnet available. Using /31 will double the number of point-to-point links which you can have.

How to remove IPv6 values belongs for country and city?

Currently I'm converting IPv4 Address to IPv4 Number for finding country and city and then I'll save the other details in my database.
Example: IPv4 (172.16.254.1)
172 - Country
16 - city
254 - Host
1 - user
I'll save 254.1 in my DB .
some one please explain what is city and state from below address
IPv6 (2001:0db8:85a3:0000:0000:8a2e:0370:7334)
IP addresses, whether IPv4 or IPv6, don't work the way you seem to think. An IPv4 address does have four octets, but they are NOT Country.City.Host.User! An IP address is really two parts: Network and Host.
For IPv4, the exact number of bits in each part varies by the mask, but they add up to 32 bits.
IPv6 is a little different since the host part is, except in a few corner cases, always 64 bits. The entire address is 128 bits.
Nothing in the RFCs defines location.

Finding addresses of next hop

I have the next table:
Network adress NetMask Next Hop
128.96.166.0 255.255.255.0 1
128.96.166.0 255.255.252.0 2
0.0.0.0 0.0.0.0 3
I want to find the adreeses range, for which the router will send to each Hop. for example, the adress's IP: 128.96.166.0 would send to Hop 1.
I don't understand how the NetMak help me to detrmine it. Is it not always would go to hop 1?
The algorithm to decide is:
If (IP address BitwiseAND NetMask == NetwordAddress) Then
Forward to Next Hop
First, start reading the netmask in binary form. In this form the netmask is ALWAYS some 1s followed by 0s. The netmask tells you the length (in bits) of the relevant prefix (1 means relevant bit, 0 means not relevant bit). For instance
128.96.166.1 and 128.96.166.2 would be sent to Hop1 b/c if you only look at the first 24 bits both addresses have the same 24 first bits, just like the first 24 bits of the network address. However the address 128.96.167.1 would not be sent to Hop1, b/c the 24th bit is different.
But the entry for Hop2 has a different netmask. The netmask for Hop2 says to look only at the first 22 bits. When only looking at the first 22 bits 128.96.167.1 matches the network address for Hop2 and packets addressed to 128.96.167.1 would be sent via Hop2.
Further:
When looking at the first 22 bits the network addresses for Hop1 and Hop2 match 128.96.166.1 and 128.96.166.2. However, (normaly) any component will pick Hop1 for 128.96.166.1 and 128.96.166.2 because that rule matches more bits. This is called "longest prefix match" and concurs with the idea "if there are more matching bits this hop will get the packet closer to the final destination".
A simple ip subnet calculator online here: http://www.subnet-calculator.com/

How to calculate IP ranges

Hi would someone be able to assist with the following question? The question is from a past paper in preparation for an exam.
Consider a router that interconnects three subnets: Subnet 1, Subnet 2, Subnet 3. Suppose all of the interfaces in each of these subnets are required to have the prefix 223.1.17/24. Also suppose that subnet 1 is required to support up to 125 different hosts, and subnets 2 and 3 are each required to support up to 60 different hosts.
Provide three network addresses (of the form a.b.c.d/x) that define the beginning of the IP address range for each subnet, and explain your reasoning.
I think the answer is the following, but I'm not sure.
Subnet 1: 223.1.17.1/25
Subnet 2: 223.1.17.128/26
Subnet 3: 223.1.17.193/26
Regards.
Not quite, Network addresses are always the first Addresses in a Subnet, so the answers would be:
223.1.17.0/25, beginning of IP Address Range: 223.1.17.1 (until .126)
223.1.17.128/26, beginning of IP Address Range: 223.1.17.129 (until .190)
222.1.17.192/26, beginning of IP Address Range: 223.1.17.193 (until .254)
Other than that, your CIDR-Subnet Length is correct, 1 needs at least 126 Hosts (- BC and NA), which justifies /25 -> 24 bits for Class C, 1 bit for Subnet and 7 bit(=2^7 = 128 - Broadcast - Network Address = 126) for hosts, No. 2 and 3 need at least 62 Hosts (-BC and NA) each.
You can see that by using a IP calculator. There are many on the net that also show you some more details..
My favorite (including IPv6) is at http://netools.ch

Resources