5

Please see the picture first.

Let someone ping from PC1 to PC2 (which has no default gateway). Would it be possible for the ping to successfully reach to PC2 and then come back in the fashion mentioned in the picture?

I have got this question in my mind because of the NAT. I think one would be able to ping PC2 successfully because the router will forward that ping to PC2 and the PC2 would assume that the 192.168.2.1 (which is in its network) has pinged it so now it would reply to 192.168.2.1 which will in turn send that reply back to PC1.

Am I right, or am I in complete darkness?

Can you please tell me what would happen in this scenario?

enter image description here

1
  • gateway === 0.0.0.0 is different from no gateway. Zero is proxy-arp -- the 1970's way of saying "the entire internet is on this wire" (and in the 70's could've been )
    – Ricky
    Oct 2, 2017 at 23:51

3 Answers 3

3

Well I suppose it is without gateway but only works if you have network address translation which really takes place on routers. The details of the addresses aren't however correct on segment 1. (The first ping packet would ping the router and get a direct reply.)

  1. PC1 sends src=192.168.1.2 dst=192.168.2.2 to routerether1 on seg1
  2. Router sends src=192.168.2.1 dst=192.168.2.2 to PC2ether on seg2
  3. PC2 receives it and replies to src=192.168.2.2 dst=192.168.2.1 to routerether2 on seg2 as it is local
  4. Router sends src=192.168.2.2 dst=192.168.1.2 to pc1ether on seg1

NAT requires considerable complexity and remembers a great deal in order to remember which connection is supposed to go where; NAT for ping is especially complex in maintaining the table of mappings.

NAT might be very common on domestic routers and inside 4g networks and so on, but you've really got to get the base case super clear before understanding NAT.

Hope that helps,

Jonathan.

6
  • Jonathan, in number 1 case, should not the dst be the gateway? I mean 192.168.1.1? Becuase the PC1 doesn't even know to what other network router is connected on the other side?
    – Shuji
    Oct 2, 2017 at 15:17
  • Jonathan, I am getting a lot of good points from your answers and I hope today I will clear up a lot of concepts.
    – Shuji
    Oct 2, 2017 at 15:20
  • As in my example, the IP range is private 192.168.x.x so I have got another question, would the NAT will translate it? I have read that NAT is used for translating IP address from a private network to a public IP address.
    – Shuji
    Oct 2, 2017 at 15:29
  • I got the answer to my above question in comment here: networkengineering.stackexchange.com/a/44615/40372
    – Shuji
    Oct 2, 2017 at 15:52
  • 1. When you say "Let someone ping from PC1 to PC2" that means they type "ping 192.168.2.2" from PC1, which will generate dst=192.168.2.2, src=192.168.1.2. Otherwise they're not "pinging PC2".
    – jonathanjo
    Oct 2, 2017 at 17:33
4

From the perspective of routing, packets have the source and destination IP (layer-3) addresses on them, but they do not have any intermediate hop (router) addresses. It is layer-2 that delivers frames on a LAN (a router is just a host on a LAN). A host will encapsulate the layer-3 packets with layer-2 frames. If the destination layer-3 address is on a different network, then the host will use the layer-2 address of its configured gateway for the layer-2 destination. If it has no configured gateway, then it cannot send packets to a different LAN.

NAT really has nothing to do with routing. NAT can be used on devices other than routers, and routers do not need to use NAT. In the diagram you have, PC2 cannot send anything to PC1 (even a reply to an ICMP echo request) because it has no idea how to send traffic off its LAN. A gateway on a LAN is just a host on a LAN that knows how to reach other LANs, but PC2 has no gateway, and it cannot reach other LANs without that.

-1

No ! It's not feasible to configure PC2 gateway as 0.0.0.0

Hence both PC2 & PC1 networks are directly connected networks . Both PC2 and PC1 should ping each other . But changes PC2 default gateway address from 0.0.0.0 to 192.168.2.1

Onces traffic is intiàted from PC2 to PC1 . ANDing process will trigger in PC2 and founds that source and destination are in different networks . And decides packet to forwarded on gateway . . So now packet is forwarded to router in router ARP table is verified according to ARP table packet is forwarded to destination.

2
  • The default gateway cannot ever be 0.0.0.0. 0.0.0.0/0 is the route entry that matches any address, but it must point to a valid gateway IP address.
    – Zac67
    Jan 3, 2021 at 8:10
  • Thanks for your inputs sir . Answer is edited accordinglly.. Jan 3, 2021 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.