Calculating IP address from the following statement - networking

I would like to not be so specific with my question, but I do not understand it and would like to get some help. The statement says:
The interface should be addressed in the next (upwards) available /27
subnet in the 192.168.20.0/24 address space.
I do not understand what it means. I understand that:
192.168.20.0/24 would mean a subnet mask of 255.255.255.0, and the address range would be 192.168.20.0 - 192.168.20.255. But what does the statement mean with the next upward available /27 subnet in that address space?

The next /27 that's not used by something else. If 192.168.20.0/27 is available, take it. Otherwise, if 192.168.20.32/27 is available, take it. Otherwise, if 192.168.20.64/27 is available... etc. Which address within that subnet you should use, and how you determine what is "available" are both unclear from the context you gave, but probably provided somewhere.

Related

Subnet CIDR: Does the ip need be the first ip in the subnet?

When define a subnet, such as 1.2.3.0/24, it means 255 hosts in the subnet start from 1.2.3.0 to 1.2.3.255.
But what if I wrongly define the subnet with 1.2.3.64/24? Does it then mean the range is start from 1.2.3.64 to 1.2.3.255?
I could not find a formal document about this.
EDIT: in Java ipaddress lib (5.2.1), the 1.2.3.64/24 will be treated as range from 1.2.3.64 to 1.2.3.255, instead of 1.2.3.0 to 1.2.3.255!. The code is: new IPAddressString("1.2.3.64/24").getSequentialRange()
EDIT: My apology: the above description of ipaddress lib's behavior is wrong. It was other things that caused me think the the range become 1.2.3.64 to 1.2.3.255.
Indeed, the
new IPAddressString("1.2.3.64/24").getSequentialRange().getLower()
is 1.2.3.64,
and
new IPAddressString("1.2.3.64/24").getSequentialRange().getUpper()
is also 1.2.3.64,
so I think this is a reasonable implementation!. I have no problem of that.
The
new IPAddressString("1.2.3.64/24").getAddress().toPrefixBlock().getLower()`
will be the expect one: 1.2.3.0.
And the `.getUpper()` is 1.2.3.255.
so this is the perfect way to get correct ip range.
There is no formal specification indicating that setting the un-fixed bits (the host bits) to 0 is a convention. However, it is common practice when describing a subnet as opposed to a single address, that you leave the host bits as zero. It is an informal convention. If you are describing a subnet, why would you set those bits to anything other than zero if they are intended to be ignored? So that is what all network engineers and most other people do, they leave the bits as zero when they are describing the full subnet, when the host can take on any value.
The specification for something like 1.2.3.64/24 is that the network part of the address is the first 24 bits, and the host part of the address is the remaining 8 bits. So, the network is 1.2.3.0 and the host is 0.0.0.64. The specification says nothing else.
Likewise, 1.2.3.0/24 indicates the network is 1.2.3.0 and the host is 0.0.0.0. However, like I said, when the host is 0, that is commonly used to refer to the entire subnet, meaning the host can take on any value. When people write down a string for that subnet of 255 addresses, they will write 1.2.3.0/24.
In fact, it is unusual to see 1.2.3.0 used as a single address because many routers do not accept a host of 0.
How you parse those things is specific to any library. Some libraries parse 1.2.3.64/24 as the whole subnet, throwing out the 0.0.0.64. Some libraries parse 1.2.3.64/24 as 1.2.3.64. Some libraries have separate methods to do one or the other.
With the IPAddress library, the same parser parses both addresses and subnets. When it parses 1.2.3.64/24 or 1.2.3.0/24, the parser needs to decide what you mean by each. For the former, it interprets 1.2.3.64/24 as the address 1.2.3.64 with prefix length 24, because why else is the 0.0.0.64 there at all if you do not intend that 64 to mean something? Why throw it out?
For 1.2.3.0/24, it interprets that as the whole subnet, because, like I said, a host of 0 is commonly used to refer to the entire subnet, and it is rare to use 1.2.3.0 as an address.
However, if you wish to choose some other meaning when parsing those things, the library provides other options.
There is no formal specification for this. In fact, there is no formal specification for a lot of the different aspects of IP addressing, a lot of it is informal and simply evolved over the years to the common practices in use.
new IPAddressString("1.2.3.64/24").getSequentialRange() is parsed as the range "1.2.3.64 -> 1.2.3.64". Earlier versions of the library behaved differently, but that is how all the latest releases for the last few years parse it.
Disclaimer: I am the project manager of that library.
It's interesting because I too can't seem to find any formal specification on why setting the un-fixed bits to 0 is the convention. Looking at RFC 4632 says:
[Classless prefixes] make explicit which bits in a 32-bit IPv4
address are interpreted as the network number (or prefix) associated
with a site and which are the used to number individual end systems
within the site.
Even with the convention of setting the un-fixed bits to 0, you may have CIDR notation that has an IP ending in a non-zero number. For example: 192.168.1.254/31 which represents the range of IPs from 192.168.1.254 to 192.168.1.255.
CIDR notation only specifies the number of bits that are fixed, so even if you put .64 it would appear that the /24 still represents only 24 fixed bits of the IP address.
You can see that the CIDR Calculator from ARIN shows that 1.2.3.64/24 still represents all IP addresses from 1.2.3.0 to 1.2.3.255.
Screenshot here.
Now it may be that different systems are implemented to handle this situation differently, so I would personally follow the convention, but from the perspective of CIDR notation (and what I can seem to find in the RFC) it should still represent the entire range.

Maximum address Space range that can be utilize in a micro-controller

I have below assignment problem and I do not know my answer is correct or not.
the question is,
"A micro-controller is having only 8 address lines and another additional signal lines through a special register. compute the maximum address space range that can be utilize by the designer ?"
my answer is 2^(16) memory spaces. is my answer is correct? any help is appreciated.
All depends on how many "additional signal lines from a special register" are there.
If that other register gives 8 more lines, without further limitations, and the hardware is correct for such scenario, then yes, your reply is correct, you have 2^16 addresses.
But you didn't state how wide that registers is, and whether that register uses all its bits as address (or paging) lines, or whatever. But generally you are right, the address space width is 2^number_of_lines.

Subnet range notation

The question is really basic, but I could not find reliable sources after googling for a while.
What are the standard ways to indicate subnetworks or network segments as a range of IP addresses?
For instance, the range 1.2.3.0/24 corresponds to the set of IP addresses whose first 3 octets are 1.2.3. I think this could be written as 1.2.3.0-1.2.3.255, if the notation $firstip-$lastip is valid.
Is this notation valid? Would something like 1.2.3.0-255 be valid as well?
I'm interested to both IPv4 and IPv6.
Normally, you don't use ranges, you use CIDR notation.
With CIDR, a suffix /n is used to indicate the length of the network mask. 10.0.0.0/8 represents 10.0.0.0-10.255.255.255 and so on.
Anything else is not really standard and depends on the context. Essentially, you can use any notation that is not ambiguous. I'd accept a range in the last octet or for the full address but nothing in between (like 1.2.3-5.0-255).
With IPv6 there's little necessity to use 'crooked', non-binary ranges due to the vast address space. Just use subnets indicating the prefix length at all times.

How do IP Addresses Relate to Countries?

I have a general question about IP Addresses. I am not sure if this question is better suited for another S/O Network (like Server Fault), but I thought I'd ask it here.
I want to try to hone in on the relationship between an IP Address and a Country. Is it fair or accurate to say that an IP Address like 100.*.*.* relates to ISPs in the US solely or is it possible that one of the octets with the 100.*.*.* range gets assigned to other Countries?
I am looking for a way to relate IP Address ranges, at their highest level, to Countries on a one-for-one basis.
Thanks.
I don't think there's an explicit rule for that. Check here.
Strictly-speaking, it is my understanding that location roughly correlates with location via IPv4 address blocks. There's a Wikipedia reference for these here.
However, more often than not this isn't particularly accurate - from personal experience relying on these results in more false results than positive. Part of the problem is that these addresses tend to shift with time and use.
MaxMind offer a free geoIP database called GeoLite 2 (link here) which I've used on a few occasions to detect an IP's origin country with a really high success rate, you just have to make sure that you update the database fairly regularly to keep up-to-date.

Using a non conventional subnet mask

A normal mask for example; 255.255.255.0
this gives us 1111 1111.1111 1111.1111 1111.0000 0000 binary where ones represent network id, and zeroes represent host id.
Would it be possible to use a layout which doesn't have all ones to the left and zeroes to the right?
example: 170.170.170.170
or 10101010.10101010.10101010.10101010 in binary.
Maybe just one additional bit at the end?
11111111.11111111.11111111.00000001 or 255.255.255.1
Maybe reverse the whole mask?
0.255.255.255
Of course you would have to use the specified id-type for the (by the mask) specified place.
As far as I know, subnetting is defined in RFC 950, which says the following:
Since the bits that identify the subnet are specified by a bitmask, they need not be adjacent in the address. However, we recommend that the subnet bits be contiguous and located as the most significant bits of the local address.
Using the most significant bits to identify the subnet is mostly a practical choice to simplify everyday operations—such as figuring out a network or host address—without having to make complex calculations.
That said, just because the RFC says that you could use non-contiguous masks, that doesn't necessarily mean that there are devices out there that support it.

Resources