Ping and subnetting

Hello INE, thank you for your videos on YouTube. Pls, I have a question and I would be very grateful if you can give me some clarifications.

Question 1.

If I have two routers or hosts with the same ip address but different subnet masks and if I am pinging the ip address which host would  respond? Supposed that the network is connected by layer 3 switches.

Host A: Ip address default gateway

Host B: Ip address default gateway

If I have a pc in the first network ( and if I ping, which of the hosts (A or B) is going to respond? Also what if the PC sending the ping is on a different subnet from host A or host B?

Also, why is it that when we ping public addresses on the internet, we don't put a subnet mask? How can someone determine what class that ip address on the internet is or are the addresses given by IANA across all classes for that particular ip?

Thank you very much.



  • peetypeety ✭✭

    Your scenario isn't going to work. Your L3 switch won't allow you to put the same IP address, or even overlapping IP addresses, on two different interfaces, nor would it allow you to put two overlapping addresses/subnets onto the same interface with secondary addresses.

    As far as public IP addresses on the Internet, I think you're over-thinking this puzzle of subnetting and definitely too addicted to the (outdated) concept of classful addresses. An IP address is an IP address, period, and it comes down to this:

    1) Your PC has an IP address with a subnet mask. That subnet mask basically says "out of the entire IPv4 address space, this much of it is local to my segment", and that's about all that your PC can talk to, directly. The default gateway has to live within that subnet, or it's essentially non-functional.

    2) Your default gateway corresponds to a router. It has (at least) two interfaces (your LAN, and perhaps a WAN port), which means it has at least two routing entries (one for each interface), plus at least one more routing entry that is probably a "default route", which means "if you don't have any better information on where a particular IP address lives, send it to this address on one of your interfaces and hope that it can get it to where it's going".

    3) This process repeats on every router between here and there: routing entries are created for interfaces, a default route is probably in place, and other routes might get learned from a dynamic routing protocol to fill in the gaps. Sometimes those routes learned from dynamic routing protocol(s) correspond to the particular subnets in place, and other times it may correspond to a larger "aggregate" / "summary" / "supernet" network that represents lots of smaller networks.

    4) The actual subnet mask only matters on the routers and hosts that sit on it, and the routers that live within the larger aggregate routes that make up the Internet. Otherwise, the larger aggregate route is sufficient information to get the packet close enough to a point where the specific route matters.

    As an analogy, think of the postal service. It's a little different at the beginning, but the rest is fairly similar:

    1) The mail vehicle drives up to your mailbox, and picks up any outgoing mail (we'll ignore incoming mail for a moment). In this case, the routing table is rather simple: no matter what the envelope says, bring it back to the post office.

    2) At the post office, the stamp is cancelled so it can't be used again. Then, a very simple routing process takes place: if the destination zip code is <self>, the mail is routed to the correct route and sorted into the correct order for easy delivery. Else, send the mail to the regional sorting facility.

    3) Mail sent to the regional sorting facility is pre-sorted by zip code, most likely using the first three digits. Anything in the same three digits as the regional sorting facility is sorted by which post office it goes to, whereas anything else is sorted into huge contiguous ranges of zip codes for transfer to the correct regional (or intermediate) sorting facility to get it to or closer to the correct regional sorting facility.

    4) Mail leaving the regional sort facility for a particular post office is then routed to the correct route and sorted into the correct order for easy delivery.

    5) The driver picks up the mail for their route, and drives along the route, depositing the outgoing mail into the correct mailbox.

    Notice that the regional sorting facilities don't care what the street address is, and the local post office only cares about the street address if the destination zip code is the same as its own zip code.

  • MartinlMartinl ✭✭✭

    Unique IP public is assigned on internet. In case of different masks, longest one wins. 

Sign In or Register to comment.