Let's say I start a new company and lease a block of ip address 222.123.123.0/25 from Internet registry, so one of those ip address 222.123.123.4 is my main web server. A customer from a different country wants to send a packet to this ip address, how does the the router (an ISP's router at his country) know what is the network prefix of this ip address 222.123.123.4? because classful ip addressing deprecated, when it comes to CIDR ip addresses, it can be 222.123.123.4/25, 222.123.123.4/26, 222.123.123.4/27 etc, and ip header certainly doesn't have a header called "network prefix", so how does the router determine the network prefix of an ip address?
1 Answer
how does the the router (an ISP's router at his country) know what is the network prefix of this ip address 222.123.123.4?
It neither knows nor cares; it does not need to know. Packets are routed by the destination address, and that address may fit multiple networks in the routing table, but it is sent toward the destination in the routing table with the most-specific match (most address bits matching a prefix in the routing table).
For example, many end-networks, such as a home or small business network only have a one path out and use a default route ('0.0.0.0/0`) that is the least-specific match because it matches every network address.
Packets are routed hop-by-hop, each router making its own decision on where to route a packet without regard for any decisions made by any other routers.
-
so when 222.123.123.0/25 is assigned to me, do I need to manually enter the network prefix "/25" info into the my local router? then the routing rule (contains this /25 prefix) get propagated from my local router all the way to the different country's isp router's routing table, is my understanding correct?– whoisitCommented Jun 13, 2023 at 4:24
-
1@whoisit The prefix route isn't propagated from your router. The ISP propagates e.g. 222.123.0.0/16 to the world. Your packets are routed to the ISP who then knows how to route them to you.– Zac67 ♦Commented Jun 13, 2023 at 6:51