But what happens in case of IPv6? Do they share a subnet ID as well?
Yes. They don't share the whole address, but they do usually share the subnet prefix.
For example, if your address/mask is 2001:db8:42:0:13f3:59d2:41a5:45bf/64
, then all hosts in the same subnet will also usually have addresses beginning with 2001:db8:42:0:
(i.e. the same 64 bits) as you do.
Of course, if you're just analyzing remote IPv6 addresess (e.g. seen in log files), then you won't know their subnet size. You can still make a rough guess like "same /64 ≈ same subnet", but it's not guaranteed to be correct 100% of the time, as non-/64 subnets are also allowed.
And you cannot really deduce whether the addresses belong to the same customer purely based on address itself.
I know that two computers that share the same network also share external IPv4 address.
That's not necessarily the case. There are still IPv4 networks where all hosts have external addresses of their own – and in that case they too would only share the subnet prefix and not the whole address. (Sure, these days it's mostly seen just in server datacenters, but regardless it has not gone extinct yet.)
For example, if your IPv4 address/mask were 212.71.255.217/24
, then that would mean that all hosts in the same subnet also have addresses beginning with 212.71.255.
(the same 24 bits) as you did.
In other words, subnet masks work the same way in both IPv4 and IPv6.
There are some other less common situations:
- There could be multiple address prefixes (IP subnet IDs) configured for the same physical network. For example, the same LAN could simultaneously have ISP-provided and VPN-provided IPv6 addresses.
- In IPv4, even if address sharing (NAT) is in use, the same router could still have more than one public address (i.e. NAT pool). For example, it could use one public address for guest Wi-Fi and another public address for employee PCs.
- In IPv6, address sharing (NAT) is possible too. It is not normally used because it's unnecessary most of the time, but sometimes there are unusual circumstances.