2

Topology:

C1 --192.168.111.0/24 -- R1 -- 172.30.0.0/24 -- Switch -- C6
                                                  |-- R2 -- 172.30.10.0/23 -- C5

I am a newbie in networking and I have a question about routing through subnets.

I want to ping computer C5 from computer C1 (see below). If I want to do so, I have to define a static route on R1, because R1 knows only its direct connected subnets and not the other ones. Without a static route on R1, C5 is unreachable from C1.

Static route on R1: 
Destination: 172.30.10.0 Subnetmask: 255.255.254.0 Gateway: 172.30.0.2

With this static route I still can't ping computer C5, but I have a timeout, that means that C5 is reachable. Why is this?

When I go further and define a static route on R2.

Static route on R2
Destination: 192.168.111.0 Subnetmask: 255.255.255.0 Gateway: 172.30.0.1 

then the ping works.

I think its because: Without static route on R2: The ping goes until C5, but it can't find the way back. With the static route on R2, the way back is defined. Is this explanation right?

But, why does it work, without static routes on R1 and R2, when I ping C6 from C1 (the default gateway on C6 is R2)? How does the ping find the way back, when the default gateway on C6 is R2.

(C6 and R2 are connected to the Switch)

C1
IP: 192.168.111.11/24
default gateway: R1

C5
IP: 172.30.10.15/23
default gateway: R2

C6
IP: 172.30.0.11/24
default gateway: R2

R1
IP int.: 192.168.111.1
IP ext.: 172.30.0.1

R2
IP int.: 172.30.0.2
IP ext.: 172.30.10.2
Jeff Ferland
  • 20,547
  • 2
  • 62
  • 85
reneton
  • 21
  • 2
  • 1
    This is not an answer to your question but a suggestion: If you enable a routing protocol on R1 and R2 (like RIP or OSPF) and advertise the networks that each router is connected to then you wouldn't need static routes at all, unless this configuration is strictly being used for educational purposes. – joeqwerty Sep 28 '12 at 17:43
  • What's the Default Gateway on R2? – joeqwerty Sep 28 '12 at 17:49
  • Thank you guys for your fast answers, your awsome! This is just an example I crated. I think C1 can ping C6 because the packet is not only send back to the default gateway of C6, R2, but to R1 too and R1 knows where to send it. Could this be? On C6 a default route is not configured. @ joequerty: R2 is the Router and I am not sure if I can define a default gateway on a router? Is it always posible to enable routing protocols? The given network could be for example an industrial network where the computers could be programmable control station. So I am not sure if routing protovols would work. – reneton Sep 28 '12 at 19:15
  • A router needs a default gateway in order to route packets for networks/hosts for which it doesn't have an explicit route. It's not required to have a DG, but that would seriously impede it's ability to function as a router, except for routing to networks and hosts that it has explicitly defined route for. If it's a "real" router then it should have the ability to implement routing protocols. Can you check the routing table on R2 and post it here. – joeqwerty Sep 28 '12 at 19:20
  • "I think C1 can ping C6 because the packet is not only send back to the default gateway of C6, R2, but to R1 too and R1 knows where to send it. Could this be?" No, that cannot be. The explanation is something else, possibly ICMP redirects or NAT. – David Schwartz Sep 28 '12 at 21:43
  • @David, yes... I didn't consider an ICMP redirect, but that would imply a static route somewhere. no? – joeqwerty Sep 28 '12 at 22:00
  • Sure, like in R1. – David Schwartz Sep 29 '12 at 01:57
  • no, there are no static routes defined. see below my comment, when i captured the traffic. – reneton Sep 29 '12 at 06:58
  • If there were no static routes, no traffic would ever get anywhere. – David Schwartz Oct 01 '12 at 06:52

2 Answers2

1

Your answer is essentially correct. Just because the internet knows how to get a packet to a destination is no reason to assume that the internet knows how to get a packet back from that destination to you. The routes have to be actively constructed in both directions.

Given your information, I can't explain why C6 can ping C1. I would check C6 to see if it has a route for 192.168.111 set on it.

David Mackintosh
  • 14,293
  • 7
  • 49
  • 78
-1

With this static route I still can't ping computer C5, but I have a timeout, that means that C5 is reachable. Why is this?

I think its because: Without static route on R2: The ping goes until C5, but it can't find the way back. With the static route on R2, the way back is defined. Is this explanation right?

Yes. A ping sends information to the destination and the destination has to respond. The destination computer needs to know the path to send the information back along.

But, why does it work, without static routes on R1 and R2, when I ping C6 from C1 (the default gateway on C6 is R2)? How does the ping find the way back, when the default gateway on C6 is R2.

I think this is where your misunderstanding is. Your set-up for pinging C6 from C1 essentially equals C1---R1---C6
From C1 to C5 it is C1---R1---R2---C5.
This is a routing question and the switch can basically be thought of as transparent for this explanation.

C6 is connected to the switch and knows that the ping came from R1. Therefore, the response is sent back to the switch, which sends the information out the switch port connected to R1 and never talks to R2 at all even if that is the default gateway. C6 knows the ping came from R1 and sends its information back to it whereas C5 sends its response back to R2 (where the packet came from) which needs to know how to get to R1. The default gateway is only used if the computer does not know a route to the IP address. In the C1 to C6 instance the computer knows the route to C1 because the request came from R1 which is the route back to C1.

user142485
  • 99
  • 3
  • DV, please elaborate on what is wrong with this answer and provide a better one. – user142485 Sep 28 '12 at 19:28
  • This isn't right. Routing ocurrs at layer 3, not layer 2. C6 knows that the ping came from 192.168.111.11 (which is C1 not R1) and responds in one of two ways: 1. C6 has an explicit route to 192.168.111.0 or to 192.168.111.11 and sends the response via one of those routes... or 2. C6 doesn't have an explicit route for 192.168.111.0 or 192.168.111.11 and sends the response back to it's DG (which is R2)... which does have an explicit route for the destination network or host... or sends it to it's DG, which by my guess is R1. – joeqwerty Sep 28 '12 at 19:33
  • C6 has no explicite route on it. It's default gateway is R2. R2 contains the following in its routing tabel: 172.30.0.0/24 directly connected to f0/0 172.30.10.0/23 directly connected to f0/1 My network is not a physical network, I simulate the network with gns3 – reneton Sep 28 '12 at 20:25
  • Run a packet capture on C6 and ping it from C1. Then look at the ICMP packets in the capture and see where the ping comes from and where C6 is sending it's response. – joeqwerty Sep 28 '12 at 20:42
  • tracert from C6 to C1, can you do that on your simulator? – user142485 Sep 28 '12 at 20:45
  • hy. I just done that. I captured the traffic between R1 and the switch with wireshark: The Ping REPLY from C6 contains the following: Destination: MAC-Addres of R1 Source: MAC-Addres of C6 It seems to be true, that the reply contains the mac-addres of R1, and now the way back is clear – reneton Sep 28 '12 at 20:51
  • the ping request: Destination: MAC-Address of C6, Source: MAC-Address of R1 – reneton Sep 28 '12 at 20:54
  • the tracert command shows only one way of the ping: C1 --> C6 but not the way back. The capture was very useful – reneton Sep 28 '12 at 20:57
  • @reneton Right, I meant tracert from C6 to C1 to see whether it goes directly to R1 or if it goes to R2 first. – user142485 Sep 28 '12 at 21:01
  • Yes, the destination MAC address will be R1 but the destination ip address should be the ip address of C1. As I said in my earlier comment, routing takes place at layer 3, not layer 2. When C6 replies to C1 it looks at the source ip address of the incoming ping (C1) and should then send the reply to it's DG since the source ip address of the incoming ping is not local. The only reason I can see for the source ip address to be R1 is if R1 is Performing NAT for C1. – joeqwerty Sep 28 '12 at 21:22
  • I setup the same scenario as you in my home lab and I can verify that the ICMP reply from my C6 to C1 goes to the DG of my C6 (which is my R2) and not to my R1, which is where the ping from my C1 comes from. – joeqwerty Sep 28 '12 at 21:22
  • @joeqwerty So, did you set the default gateway of R2 to R1 or how does the ping make it back? reneton Is your R2 default gateway set as R1? – user142485 Sep 28 '12 at 21:34
  • My R2 has a route to my C1 network through my R1 (using RIP), so that's how it works in my case, which is why I'm saying that R2 somehow has a route to the C1 network through R1 or that R1 is performing NAT for C1 so that the ping to C6 has a source ip address of R1. Reneton could verify this (or not) by looking at the source ip address of the incoming ping on C6. – joeqwerty Sep 28 '12 at 21:38
  • @joeqwerty He could not have rip enabled though if he had to add a static route to ping C5, correct? – user142485 Sep 28 '12 at 21:50
  • I also just confirmed that if I remove the route for my R1 from my R2 that the ping fails... because the reply goes to my R2 (the DG for my C6). The source ip address is C1, the source MAC address is R1, the destination ip address is C1, and the destination MAC address is R2. – joeqwerty Sep 28 '12 at 21:53
  • @joeqwerty So, you're saying its because of NAT that it works? – user142485 Sep 28 '12 at 21:56
  • user142485, I believe you're right about RIP, although it is possible that RIP is enabled but not advertising the C1 network. Which would mean that R1 knows how to get to the C5 network but that R2 doesn't know how to get to the C1 network. – joeqwerty Sep 28 '12 at 21:56
  • I'm saying that if R1 is performing NAT for C1 then the source ip address will be R2 (instead of C1) which means that C6 will send the reply to R1 because they both have an interface on the same network and are local to each other. – joeqwerty Sep 28 '12 at 21:58
  • For this particular test, R1 and R2 have no static route or NAT configured. RIP protocol is also not configured. I just configured the ports. – reneton Sep 29 '12 at 06:35
  • 1
    C6 cannot ping C1 because the default gateway on C6 is R2 but C1 can ping C6. When I capture the traffic I can see: ping reguest: src IP: C1, dst IP: C6, src MAC: R1, dst MAC: C6 ping reply: src IP: C6, dst IP: C1, src MAC: C6, dst MAC: R1 – reneton Sep 29 '12 at 06:46
  • Before the ping there is an arp from R1: arp: src:R1; dst: broadcast; who has 172.30.0.11 Tell 172.30.0.1 arp: src:C6; dst; R1; 172.30.0.11 is at MAC from C6 – reneton Sep 29 '12 at 06:47