knowledge

Lecture 2

IP and Subnets

The Internet Protocol (IP) runs at the network layer, in the middle of the five layers.

LayerRole
Applicationcommunication
Transportend-host connectivity
Networkinterconnection of all hosts, across LANs
MACinterconnection within one LAN
Physicalpoint-to-point transmission of bits

IP forwards packets from router to router by packet switching, based on their destination IP addresses.IP is best effort: it gives no delivery guarantee.Packets wait briefly in router buffers, and packets of one flow can take different paths.So packets can be dropped, delayed or reordered.

The devices of a subnet connect at the data link layer and share one IP-address prefix, such as 128.178.71.The subnet mask marks the prefix bits with 1s.On an EPFL IPv4 LAN, the prefix has 24 bits:

mask, binary    1111 1111  1111 1111  1111 1111  0000 0000
mask, dotted    255.       255.       255.       0
slash notation  128.178.71.34/24

Prefixes have 26 bits on ETHZ's IPv4 LANs and 64 bits on EPFL's IPv6 LANs, as in 2001:620:618:1a6:0a00:20ff:fe78:30f9/64.

The Two Rules of IP Unicast

IP rule 1 says that only routers interconnect different subnets.Inside a subnet, traffic crosses only data-link devices, such as switches and WiFi base stations.Two subnets have different prefixes, with the same or different masks.

Ethernet, 10.10.2.0/23WiFi, 10.10.1.0/24WPSwitchgateway routerBase stationBEW to P:no routerB to E:no routerW to E:through the router
Dashed: traffic inside one subnet. Blue: traffic between the two subnets.

Example 1. The destination IP address inside a LAN.

Host W sends an IP packet to host P through the switch.

Ethernet, 10.10.2.0/23W1SwitchP1MAC headerMAC(W)sourceMAC(P)destinationIP headerIP(W)sourceIP(P)destination
The frame at point 1.

The IP header names P as its destination, with no router on the path.An IP packet always carries its destination IP address, even in a LAN.The switch appears in neither header.

IP rule 2 says that IP addresses have structure.IP aims to interconnect every system in the world by IP address.So each address tells something about delivery, in a form that makes forwarding in hardware easy.

Unicast. A unicast packet goes to exactly one interface.

Host part. The host part of an address is the bits after the prefix.It is also called the suffix.In 128.178.71.202/24, the prefix is 128.178.71 and the host part 202.Interfaces of one subnet share the prefix, and so the subnet mask.They differ in their host parts.

Longest Prefix Match

Next hop. The next hop is the router or host on an attached link to which a system forwards the packet.

Forwarding table. A forwarding table maps each destination prefix to a next hop, an outgoing interface, or both.It is also called the routing table.Every host (end system) and every router (intermediate system) has one.

Longest prefix match (LPM). LPM is the forwarding rule of IP unicast.A system forwards each packet by the closest entry of its table:the longest prefix that the destination address starts with.

Letters stand for prefixes, and a host's name follows its prefix.So A.H1 is host H1 in prefix A, and B.* matches every address in B.

LettersPrefix
A2001:620:8::/48
B.C2001:620:618:1a5::/64
B.D2001:620:618:1a6::/64

Example 2. Two packets from Alice.

Alice sends one packet to Bob, at B.D.H2, and one to Bart, at B.C.H2.

AliceA.H1BartB.C.H2BobB.D.H2R1R2R3R4tointerfaceB.*2A.*0tointerfaceA.*1B.D.*2B.*3tointerfaceA.*1B.D.*1B.C.*0tointerfaceB.*2A.*10211321012both packetsto Bartto Bob
Four routers and their forwarding tables. The numbers beside the links name each router's interfaces. Dark arrows trace Alice's two packets.
RouterEntry for Bob, B.D.H2Entry for Bart, B.C.H2
R1B.*, the only matchB.*, the only match
R2B.D.*, longer than B.*B.*, the only match
R3B.C.*, the only match

Aggregation. Aggregation replaces many long prefixes by one shorter prefix that covers them all.R1 and R4 need a single entry, B.*, for every subnet of B, so their forwarding tables stay small.

Multicast, Broadcast and Anycast

Multicast. A multicast packet goes to every interface that joined its group.Each member listens to its own address and to the group's multicast address.LPM is not enough to forward it: routers also need group membership, distribution trees and packet replication.

Broadcast. A broadcast packet goes to every interface on its subnet.Each interface listens to its own address and to the broadcast address.Routers never forward a broadcast packet.

Anycast. An anycast packet goes to the nearest of several interfaces that hold the same address.An anycast address looks like a unicast one, but several places announce the same address, or the same prefix.Routers forward it by LPM, as a unicast packet.

IPv4 Addresses

An IPv4 address has 32 bits.It is usually written in dotted decimal: four integers of 8 bits each.It can also be written in binary, or in hexadecimal: 8 hex digits of 4 bits each.

binary          1000 0000  1011 1111  1001 0111  0000 0001
dotted decimal  128.       191.       151.       1
hexadecimal     80         bf         97         01
 
binary          1000 0001  1100 0000  1100 1000  0000 0010
dotted decimal  129.       192.       200.       2
hexadecimal     81         c0         c8         02

In base BB, an integer is a string over an alphabet of BB symbols, starting from 0.

BaseAlphabet200 in this base
binary, B=2B = 20, 11100 1000
decimal, B=10B = 100 to 9200
hexadecimal, B=16B = 160 to 9, then a to fc8

Nibble. A nibble is four bits, written as one hexadecimal digit.So binary and hexadecimal convert digit by digit:c is 1100 and 8 is 1000, so c8 is 1100 1000.

A calculator is the best tool to convert binary or hex to decimal.By hand, add the powers of 2 at the 1 bits:

1100 1000bin=27+26+23=128+64+8=200.1100\,1000_{\text{bin}} = 2^7 + 2^6 + 2^3 = 128 + 64 + 8 = 200.

The largest hex digit f is 1111, or 15, so the largest byte ff is 1111 1111, or 255.

Example 3. From hexadecimal to dotted decimal.

The 32 bits 0102:ffff hold four bytes: 01, 02, ff and ff.Here 01 is 1, 02 is 2 and ff is 255.So in dotted decimal, 0102:ffff is 1.2.255.255.

A mask can end inside a byte.The byte 254 is 1111 1110, so 255.255.254.0 is 23 ones, then 9 zeros: the mask of a /23.A prefix also drops its trailing zero bytes:128.178/16 is 128.178.0.0/16.

Example 4. A valid address for H.

A router's north interface is 2.4.8.1/23, and its south interface is 2.4.7.1/23.A switch connects host H to the north interface.

south LANRouterSwitchH?.?.?.?south: 2.4.7.1/23north: 2.4.8.1/23
The switch puts H on the LAN of the router's north interface.

Is 2.4.8.2 or 2.4.9.1 a valid address for H?

mask255.255.254.011111111111111111111111000000000router, north2.4.8.100000010000001000000100000000001H, first candidate2.4.8.200000010000001000000100000000010H, second candidate2.4.9.100000010000001000000100100000001router, south2.4.7.100000010000001000000011100000001prefix: 23 bitshost: 9 bits
Outlined bits differ from the north interface's address. Tinted bits are the 23-bit prefix.

H shares a subnet with the north interface, so H needs its 23-bit prefix.Both candidates match it, because 8 and 9 differ only in a host bit.So 2.4.9/23 and 2.4.8/23 are the same prefix, and both candidates are valid.The south interface differs in prefix bits, so it lies in another subnet.

Reserved block. A reserved block is a prefix kept for a special use.

BlockUse
0.0.0.0absence of address, or any address
127/8loopback: this host (e.g. 127.0.0.1)
10/8, 172.16/12, 192.168/16private addresses (e.g. at home)
100.64/10private addresses for internet service providers (ISPs) only: carrier-grade NAT
192.88.99/24IPv6-to-IPv4 relays (deprecated, not reassigned)
169.254/16link-local addresses
224/4multicast
240/4reserved for experimental or future use
255.255.255.255/32link-local (LAN) broadcast

Global address. A global address identifies one interface uniquely in the public internet.It is also called a public address.Every IPv4 address outside the reserved blocks is global.

Private address. A private address is an IP address that any network can use inside itself, but never in the public internet.Internet routers drop packets destined to a private address.So many private LANs can use the same addresses without routing conflicts.

Link-local address. A link-local address is an IP address that is valid only on one LAN, so no router forwards it.

Private and link-local addresses differ in how they are allocated.A local network administrator allocates private addresses, either statically or through one configured server of the Dynamic Host Configuration Protocol (DHCP).A computer allocates itself a link-local address automatically, e.g. by stateless address autoconfiguration (SLAAC), when it has no static address and finds no DHCP server.

Link-local addresses have their own block.So they never conflict with the addresses of a local but temporarily unavailable DHCP server.

IPv4 Packets and Forwarding

An IPv4 packet is a header, then a payload.The header is protocol overhead, and the payload carries the useful bits.

08162431VersionIHLType of ServiceTotal LengthIdentificationFlagsFragment OffsetTime to LiveProtocolHeader ChecksumSource AddressDestination AddressOptions, if anyPayloadhigher-layer dataheader20 bytes
Tinted: the two addresses and the Protocol field.

The Protocol field names the higher-layer protocol:1 for ICMP, 6 for TCP and 17 for UDP.

Internet Control Message Protocol (ICMP). ICMP is the protocol that carries network-layer error messages.

SWITCH is the Swiss academic network.Router ed0-swi links EPFL to SWITCH, and through it to the internet.Router ed0-swi holds this forwarding table.

DestinationNext hopInterface
128.178.29/24128.178.100.2, ed2-elsouth
128.178/16128.178.100.3, ed2-insouth
0/0128.178.47.3, sw-la-01north
SWITCH, then the internet0/0sw-la-01128.178.47.3north.5ed0-swisouth.12EPFL-Backbone, 128.178.100.3ed2-in.2ed2-el.1rest of EPFL128.178/16LEMA128.178.29/24
Router ed0-swi and its three next hops. Interfaces show their host part. In bold: the table entry that reaches each destination.

Each destination is in aggregated or subnet form:128.178/16 aggregates all of EPFL, and 128.178.29/24 is the subnet of LEMA.Each next hop is named by both its IP address and the interface.

Default route. The default route is the entry 0/0, with an empty prefix.It matches every address, so longest prefix match picks it only when nothing longer matches.

Longest prefix match turns the table into nested tests, with the longest prefix innermost:

if destination in 128.178.*
    if destination in 128.178.29.*
        forward to ed2-el
    else
        forward to ed2-in
else
    forward to sw-la-01

The IPv4 Address Shortage

IPv4's 32 bits give about 4⋅1094 \cdot 10^9 addresses, too few for every device.Public IPv4 addresses are now traded and charged.

Addresses go down a hierarchy:from the Internet Assigned Numbers Authority (IANA) to a regional internet registry (RIR), then to an ISP or organization.

Free pool. A registry's free pool is the stock of unallocated addresses that it still holds and can hand out on request.

IANA's IPv4 free pool ran out in February 2011, and its last five /8s went one to each of the five RIRs.The RIRs then ran out in turn.

RIRRegionIPv4 free pool ran out
APNICAsia-Pacific2011
RIPE NCCEurope2012, and fully in November 2019
LACNICLatin America2014
ARINNorth America2015
AFRINICAfrica2017

So an organization can no longer request IPv4 addresses from its RIR.It buys them from someone who already holds them.On this secondary market, an address costs roughly $20 in mid-2026, down from a peak near $60 in 2021.About 30 million addresses changed hands in the first half of 2026.

Since 1 February 2024, Amazon Web Services (AWS) bills each public IPv4 address attached to a resource:$0.005 per hour, or about $3.60 per month.Before that date, an address in use on a resource was free.

IPv6 Addresses

IPv6 redefines the packet format with 128-bit addresses, about 3⋅10383 \cdot 10^{38} of them.It offers the same services as IPv4.

Hextet. A hextet is one 16-bit group of an IPv6 address.It is written with 1 to 4 hex digits, or with none when it lies inside a ::.

An IPv6 address is 8 hextets separated by colons, in hexadecimal with lowercase letters.

A hextet may omit its leading 0s:0c26 becomes c26, and :0bad: becomes :bad:.Only leading 0s go, so 0a00 becomes a00, never a.A double colon :: replaces one run of all-zero hextets.It appears at most once, because two would be ambiguous.

uncompressed  2002:0000:0000:0000:0000:ffff:80b2:0c26
compressed    2002::ffff:80b2:c26
 
uncompressed  2001:0000:0000:01a6:0000:20ff:fe78:30f9
compressed    2001::1a6:0:20ff:fe78:30f9

In the second address, :: already replaces the first zero run, so the later zero hextet stays 0.

Example 5. Expanding an IPv6 address.

The address 2001::ada:bada shows three hextets.The double colon fills in five zero hextets, to reach eight.The hextet ada expands to 0ada.

2001:0000:0000:0000:0000:0000:0ada:bada

It is not 2001:0000:0ada:bada.That string holds only four hextets, or 64 bits.

IPv6's link-local broadcast lies inside its multicast block.

BlockUse
::/128absence of address, or any address
::1/128loopback: this host
fc00::/7unique local addresses (ULA)
fe80::/10link-local addresses
ff00::/8multicast
ff02::1:ff00:0/104solicited-node multicast, used by the Neighbor Discovery Protocol (NDP)
ff02::2/128multicast to all routers on the link
ff02::1/128link-local broadcast (e.g. for periodic router advertisements)

A prefix length that cuts through a hex digit is read in binary.

BlockFixed bitsFirst hextet
2000::/30012xxx, 3xxx
fc00::/71111 110fcxx, fdxx
fe80::/101111 1110 10fe80 to febf

Unique local address (ULA). A ULA is a private IPv6 address, used only inside one site such as EPFL.A site's ULAs start with fd, then a 40-bit global ID that the site draws at random (RFC 4193).Two networks are very unlikely to draw the same ID.

Currently, only the block 2000::/3 holds global unicast addresses.A global address can be configured in several places at once, and it is then an anycast address.

BlockHolder
2001:620::/32SWITCH
2001:620:618::/48EPFL
2001:620:8::/48ETHZ
2a02:1200::/27Swisscom
2001:678::/29provider-independent addresses
2001::/32Teredo: tunnels IPv6 in IPv4
2002::/166to4: tunnels IPv6 in IPv4

Allocation is hierarchical:the networks a provider serves use blocks inside its block.EPFL's and ETHZ's /48s lie inside SWITCH's /32, and each EPFL subnet is a /64 inside EPFL's /48.

global2001:620:618:1a6::9privatefd24:ec43:12ca:1a6:a00:20ff:fe78:30f9SWITCH's /32EPFL's /48subnet /64host: 64 bitsrandom: 40 bits
Two EPFL addresses in subnet 1a6. The global 2001:620:618:1a6::9 lies in EPFL's /48, inside SWITCH's /32. The private one starts with fd and 40 random bits.

IPv6 Packets and Forwarding

An IPv6 packet also has a header, options if any, and a payload.

08162431VersionTraffic ClassFlow LabelPayload LengthNext HeaderHop LimitSource Address128 bitsDestination Address128 bitsOptions, if anyPayloadhigher-layer dataheader40 bytes
Tinted: the two addresses and the Next Header field.

The IPv6 header is twice as long as the IPv4 header, and its 16-byte addresses are four times longer.The Next Header field replaces IPv4's Protocol field:6 for TCP, 17 for UDP, and 58 for ICMPv6, the IPv6 version of ICMP.

A next hop always sits on an attached link, so its link-local address is enough to name it.

Zone index. A zone index %n names one interface of a machine with several interfaces, such as a router.So fe80::1%2 means destination fe80::1 on interface 2.Windows machines typically show zone indexes, but a zone index never appears inside an IP packet.

Router ed0-swi holds this IPv6 forwarding table.

DestinationNext hop%interfaceIPv4 counterpart
2001:620:618:1a4::/64fe80::4%2, ed2-el128.178.29/24
2001:620:618::/48fe80::1%2, ed2-in128.178/16
::/0fe80::1%1, sw-la-010/0
SWITCH, then the internet::/0sw-la-012001:620:618:10a::/64::1, fe80::1%1ed0-swi%2EPFL-Backbone, 2001:620:618:10b::/64::1, fe80::1ed2-in::4, fe80::4ed2-el::1rest of EPFL2001:620:618::/48LEMA2001:620:618:1a4::/64including LRC, 2001:620:618:1ad::/64,with host lrcmac4
The same routers in IPv6. Each next hop has a global and a link-local address, and ed0-swi names its two interfaces %1 and %2.

Routers sw-la-01 and ed2-in both use fe80::1 on different links, so each IPv6 entry also names the interface: %1 or %2.

Example 6. Three IPv6 destinations at ed0-swi.

DestinationMatching entriesNext hop
2001:620:618:1a4::1/64, /48, ::/0fe80::4%2
2001:620:618:1ad:a00:20ff:fe78:30f9/48, ::/0fe80::1%2
2001:620:8::1::/0fe80::1%1

The first destination is ed2-el's interface on LEMA.The second is host lrcmac4 on LRC, in subnet 1ad, so the /64 misses it.The third is at ETHZ, outside EPFL's /48.

Source Address Selection

An IPv4 interface usually has one address.An IPv6 host interface typically has several:one or more link-local addresses, plus one or more global unicast ones.The global ones can include temporary addresses and secure, cryptographically generated addresses (CGA).Temporary addresses protect privacy.

The scope of an address is where it is valid:one link for a link-local address, the whole internet for a global one.

Source address selection. Source address selection is the algorithm by which the operating system picks a packet's source address, with these default preferences (RFC 6724).

  1. Prefer an address of the same scope as the destination.
  2. Prefer a temporary address over a stable one.
  3. Prefer the longest prefix match with the destination.

Dual Stack

IPv6 is incompatible with IPv4, so routers and hosts must handle the two separately.

Dual stack. A dual-stack system runs IPv4 and IPv6 side by side, under the same transport layer.A dual-stack router keeps two forwarding tables, one per version.

W, dual-stack hostHTTPTCPIPv6IPv4MACdual-stack routertwo forwarding tablesIPv6IPv4MACB, IPv6 onlyHTTPTCPIPv6MACA, IPv4 onlyHTTPTCPIPv4MACIPv6, IPv4IPv6IPv4
Each system's protocol stack. Each link is labelled with the IP version that crosses it.

W can talk to A over IPv4 and to B over IPv6.A and B cannot communicate at the network layer.

A dual-stack client also picks a destination address, because a name can have both kinds.DNS stores an IPv4 address in an A record, and an IPv6 address in an AAAA record.

Happy Eyeballs. Happy Eyeballs is the procedure (RFC 8305) by which a dual-stack client picks IPv6 or IPv4 for one destination.

IPv6 is preferred but never waited for.

  1. Ask DNS for both the A and the AAAA records.
  2. Sort the destination candidates (RFC 6724).
  3. Start the IPv6 connection first.
  4. If it has not completed within a short delay (about 250 ms), start IPv4 in parallel.

So a broken IPv6 path costs a few hundred milliseconds, not a failure, and operators could turn IPv6 on without breaking anything.

Network Address Translation

NAT box. A NAT (network address translation) box is a gateway that translates an internal IP address and port into a NAT IP address and a NAT port.Translating is also called masquerading.

The internal addresses are typically private, and the ports are UDP or TCP ports.From outside, only the public NAT IP address and a NAT port are visible.

A NAT lets n>1n > 1 devices share a single public IP address.So a private LAN hides its many private addresses behind one or a few public addresses.

  • An internet service provider gives a home one IPv4 address for its nn devices.
  • A virtualization platform hosts nn guest virtual machines (VMs).They reach the outside with the physical machine's single IP address.
physical host, running VirtualBoxvirtual networkVM110.0.0.2VM210.0.0.3NAT128.179.34.2the host's addressphysical network
Two guest VMs on VirtualBox's virtual network. The NAT gives them the physical host's single address on the physical network.

Middlebox. A middlebox is a device on the path that does more than forward packets.

A NAT is a network-layer middlebox, and it violates two principles.

  • Layering: a NAT rewrites transport-layer ports as well as network-layer IP addresses.
  • The IP rule that public addresses identify hosts uniquely:one NAT address stands for many hosts.

A NAT's internal network is also called its LAN, and its external network its WAN (wide area network).

NAT table. A NAT table holds one row per mapping:an internal IP address and port, the protocol, and the NAT IP address and NAT port that replace them.

At home, a NAT has internal address 192.168.10.1 and external address 130.104.228.200.Both interfaces of a NAT can hold private addresses, if they lie in different subnets (IP rule 1).

Host A, at 192.168.10.11, sends a DNS query from UDP port 1029 to server S, at 1.2.3.4, on UDP port 53.

On a packet from the LAN to the WAN, the NAT:

  1. translates the source IP address and port, in the IP header and in the UDP or TCP header,
  2. stores this mapping in the NAT table,
  3. forwards the packet.

On a packet from the WAN to the LAN, the NAT translates the destination IP address and port.

The NAT creates each entry on the fly, from outbound traffic, when an internal client contacts an external server.It chooses a NAT port that creates no collision in the table.On Linux, iptables implements the NAT table.

Host B, at 192.168.10.10, also sends a DNS query from UDP port 1029.NAT port 3441 already maps A, so B gets NAT port 3442.B's query leaves from 130.104.228.200, port 3442, to S at 1.2.3.4, port 53.

internal network (LAN)external network (WAN)dst1.2.3.4:53src192.168.10.11:1029src1.2.3.4:53dst192.168.10.11:1029NATdst1.2.3.4:53src130.104.228.200:3441src1.2.3.4:53dst130.104.228.200:3441internal IPportprotoNAT IPNAT port192.168.10.101029udp130.104.228.2003442192.168.10.111029udp130.104.228.2003441
Host A's DNS query and its answer through the NAT. Outlined: the fields the NAT rewrites, and the mapping it uses.

In both directions, the NAT finds a mapping by exact match, not by longest prefix match.B's next packet goes to 1.2.3.4, port 80.It matches B's entry exactly on 192.168.10.10, 1029 and udp, so it leaves again from NAT port 3442.If no entry matches a packet from the WAN, the NAT drops it.

If A only listens as a server on TCP port 5000, it sends no outbound packet.So the NAT creates no automatic mapping for this server.

Port forwarding. With port forwarding, the NAT sends every packet that arrives on a chosen public port to a fixed internal IP and port.An administrator configures this entry by hand.

For A's server, the administrator adds this entry to the NAT table.

Internal IPPortProtocolNAT IPNAT port
192.168.10.115000tcp130.104.228.2005000

Client C, at 11.12.13.14, then connects to A at 130.104.228.200, port 5000.A must know its NAT IP address in advance, and advertise it to clients like C.A can discover it through a STUN server (Session Traversal Utilities for NAT), or through UPnP (Universal Plug and Play) if the NAT supports it.

As a side benefit, the NAT protects the LAN.A server port is reachable from outside only through a configured entry, and every other server port stays unreachable.

NAT and IPv6

NAT was motivated by the lack of IPv4 addresses.In IPv6, home routers often use no NAT, because the provider typically allocates a block, not one address.A /60 block holds 16 subnets of /64.

Filtering router. A filtering router lets in outside communication only if an inside host initiated it, unless manually configured.It gives an IPv6 home the protection that a NAT gives an IPv4 one.So A's server on TCP port 5000 is reachable at A's own address, once the filter allows it.

Some systems still use NAT with IPv6, when the local network receives one IPv6 address, not a prefix.The internal network then uses link-local addresses, so it is a single LAN.This is typical in virtualization (e.g. VirtualBox's "NAT network").

Case 1: a /60 prefix allocatedhome network, 2020:1:2:b0b0::/60A, server on TCP port 50002020:1:2:b0b1::1B2020:1:2:b0b1::2filteringrouterinternetCase 2: one address allocatedinternal network, one LANAfe80::5c50:a598:efff:e1d5Bfe80::ed79:34d7:c2d9:3d02NATexternalnetwork2020:1:2:b0b0::12020:1:2:b0b0::1
Case 1 routes a /60 prefix into the home. Case 2 hides one link-local LAN behind one address.

Carrier-Grade NAT

Carrier-grade NAT (CGNAT). A CGNAT is a NAT that a network operator runs for many users' networks.It shares pp external addresses among n>pn > p internal hosts.

A virtual private network (VPN) connects remote users into a site's network.EPFL's VPN access uses a CGNAT with the block 128.178.15/24, so p=256p = 256.

home of user 1user 1192.168.178.34other host192.168.178.59NAT10.252.13.211home of user 2user 2192.168.178.34other host192.168.178.45NAT10.252.87.129EPFLVPNCGNAT128.178.15/24EPFLnetworkinternet
NATs behind NATs. Each home NAT holds an address inside EPFL's VPN; the CGNAT shares the block 128.178.15/24 on the EPFL network.

User 1 appears as 192.168.178.34 at home, as 10.252.13.211 in EPFL's VPN, and as 128.178.15.x in the public internet.User 2 holds the same home address, because each home is its own private network.In the public internet, user 2 can appear with user 1's address, or not.

Some ISPs use CGNAT to give end users fewer public IPv4 addresses.A home network behind the CGNAT can already use 10/8, so these ISPs use the block 100.64/10 inside instead.