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

  • 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 Beam Oct 2 '17 at 23:51
2

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.

  • 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? – Shujaat Ali Khan Oct 2 '17 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. – Shujaat Ali Khan Oct 2 '17 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. – Shujaat Ali Khan Oct 2 '17 at 15:29
  • I got the answer to my above question in comment here: networkengineering.stackexchange.com/a/44615/40372 – Shujaat Ali Khan Oct 2 '17 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 '17 at 17:33
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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