Search code examples
network-programmingipip-addresssubnet

Can IPV4 address exist between an IPV6 range?


I'm relatively new to the IP Address concept and trying to build a range checker.

USE CASE: The user gives one IP Address(can be IPv4/IPv6) and a range(can be 2 IPv4 addresses /2 IPv6 addresses/ 1 IPv4 and 1 IPv6 address).

I need to test if the given IP exists between the specified range.

I just wanted to know if the below cases are possible

  1. Can an IPv4 address exist between 2 IPv6 addresses?
  2. Can an IPv6 address exist between 2 IPv4 addresses?
  3. Can an IP range be 1 IPV4 address and 1 IPv6 address or do IP ranges implicitly mean the same types(like fromIPv4 - toIPv4, fromIPv6 - toIPv6)?

Note: When talking about IPv6 addresses, I mean all IPv6 addresses and not just those that can be mapped to IPv4.


Solution

  • IPV6 and IPV4 is two different protocols, that don't intersect at all

    Just check what pattern IPV4 matches and what pattern IPV6 matches

    IPV4 consist of four parts, each part has value from 0-255 and separated with dot.

    IPV6 consist of 8 octets, separated with colon sign.

    And main reason, why it's unreal to find out, is that IPV4 use netmask for dividing IP address on network part and host part

    At the same time IPV6 address is strictly divided on Routing prefix and interface id