LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Network routing question (http://www.linuxquestions.org/questions/linux-networking-3/network-routing-question-927268/)

crazy4nix 02-02-2012 04:31 PM

Network routing question
 
I'm on a PC with ip 192.168.53.107 (192.168.53.0/24 network). My default gateway is a machine called GATEWAY-MACHINE with ip 192.168.53.1 on its eth0 interface. Now GATEWAY-MACHINE has another interface (eth1) which has an IP of 10.10.0.52 (10.10.0.0/24). Cat5e cable from this eth1 interface goes to a switch. Connected to this switch is a SERVER with ip 10.10.0.200 (10.10.0.0/24).

Now my question is: To be able to communicate with the SERVER (10.10.0.200) from my PC (192.168.53.107), do I need to create (add) a static route on GATEWAY-MACHINE?

Thanks guys!

eSelix 02-02-2012 04:43 PM

You should already have one, but if not then yes, you need a route to 10.10.0.0/24 network through eth1 to be able communicate with SERVER.

crazy4nix 02-02-2012 04:45 PM

Yeah I thought that too.. GATEWAY-MACHINE should be aware of both interfaces and shouldn't need a route be entered by an admin.

devilboy09 02-03-2012 10:14 AM

No.there is no need to add a route.your gateway machine knows about both networks, so the routing will be done automatically

crazy4nix 02-03-2012 10:27 AM

Quote:

Originally Posted by devilboy09 (Post 4592939)
No.there is no need to add a route.your gateway machine knows about both networks, so the routing will be done automatically

Thank you for the confirmation.

crazy4nix 02-03-2012 11:53 AM

So I applied the above into practice but I've run into a problem. Here is the situation.
I've turned server ns1 (a dual-homed linux box) into a router by enabling ip_forwarding on it (echo 1 > /proc/sys/net/ipv4/ip_forward)

Server ns1:

eth0: 10.10.0.200/24 (default gw: 10.10.0.51)
eth1: 192.168.53.198/24 (I've not set any default gw for this interface)

Routing table on server ns1:
----------------------------
Code:

[root@ns1 ~]# netstat -nr
Kernel IP routing table
Destination    Gateway        Genmask        Flags  MSS Window  irtt Iface
192.168.53.0    0.0.0.0        255.255.255.0  U        0 0          0 eth1
10.10.0.0      0.0.0.0        255.255.255.0  U        0 0          0 eth0
169.254.0.0    0.0.0.0        255.255.0.0    U        0 0          0 eth1
0.0.0.0        10.10.0.51      0.0.0.0        UG        0 0          0 eth0


I'm trying to ping a webserver (having an ip of 10.10.0.54) from a workstation BUT NOT SUCCEEDING. The properties of workstation are:

eth0: 192.168.53.150/24
default gateway: 192.168.53.198

Here is the routing table on my workstation:
--------------------------------------------
Code:

root@workpc:~# netstat -nr
Kernel IP routing table
Destination    Gateway        Genmask        Flags  MSS Window  irtt Iface
192.168.53.0    0.0.0.0        255.255.255.0  U        0 0          0 eth0
0.0.0.0        192.168.53.198  0.0.0.0        UG        0 0          0 eth0


Why is my workstation not able to reach 10.10.0.54? I believe I've setup everything correctly. Please help. Thank you.

eSelix 02-03-2012 04:58 PM

Show
Code:

tracepath -n 10.10.0.54
from your workstation, and
Code:

iptables -nL
on its gateway 192.168.53.198 (you can asterisk public IPs).

devilboy09 02-04-2012 04:58 AM

i think the problem is with the reply.what message do u get?
i think it's probably time out.so i guess you should have a route from your web server to the workstation too.check your routing table on web server.i think you will find your problem there

amilo 02-04-2012 06:24 AM

Probely Gateway 10.10.0.51 does not now where network 192.168.53/24 lives. So add a router entry with network 192.168.53.0/24 with gateway 10.10.0.52 on router 10.10.0.51

When 10.10.0.54 recieves a packet from 192.168.53.107 it will send it back to his default gw eg 10.10.0.51. This router wil send back an icmp redirect to 10.10.0.54 with the information "send it back to 10.10.0.52.

baldy3105 02-04-2012 09:25 AM

There are 2 types of route, direct (or connected) and indirect. Direct routes are know about by a host or router (gateway means the same thing as router in IPv4 speak) because they have configured interfaces in those networks. So for PC 192.168.53.0/24 is a direct route. It knows the route without being told as it is connected to the network.

For PC 10.10.0.0/24 is an indirect route. PC only knows about this network if it is told about it by being given an indirect route. This indirect route can be static or dynamic. If the route is configured by the PC administrator then its a static route. If the PC is learning about the route via RIP, OSPF etc then the route is a dynamic route, but this is usually only gateways do this..

For GATEWAY 192.168.53.0/24 and 10.10.0.0/24 are both direct routes so should not need static routes configuring for either.

For SERVER 10.10.0.0/24 is a direct route so should not need to be configured, but 192.168.53.0/24 is indirect so it needs to be given an indirect route to get to it via GATEWAY.

The reason I say "should" above is that there are exception. I have seen Linux distro's that even though configured with 10.10.0.1/24 on an interface will have the host specific interface route "10.10.0.1 255.255.255.255 via eth0" in the route table but will not generate the associated direct network route that is implied by the config. To make this work as it should I had to add a static 10.10.0.0 255.255.255.0 via eth0.

crazy4nix 02-04-2012 11:33 AM

Solved
 
thank you eSelix, devilboy09, amilo and baldy3105. All your suggestions were spot on and very helpful in figuring out the problem.

Quote:

i think it's probably time out.so i guess you should have a route from your web server to the workstation too.check your routing table on web server.i think you will find your problem there
You are right. The webserver (10.10.0.54) indeed did not know how to reach the 192.168.53.0 network. Adding a static route there solved the problem. Thanks again to all of you :)


All times are GMT -5. The time now is 11:54 AM.