Operating System - Linux
1752587 Members
3907 Online
108788 Solutions
New Discussion юеВ

Re: simple routing in linux

 
iinfi1
Super Advisor

simple routing in linux

i have seen n number of docs on the net abt routing but still the concept is unclear in my head.

assume a scnario where i have two networks
192.168.5.x 255.255.255.0
172.16.x.x 255.255.0.0
i have machine A with IP 192.168.5.2
machine B with IP 172.16.0.2

i have a centos machine with 2 NICs, once with IP 192.168.5.1 and another with 172.16.0.1.
with iptables service off and
cat /etc/sysctl.conf | grep net.ipv4.ip_forward
net.ipv4.ip_forward=1

with this, should machines on the two networks 192.168.5.x and 172.16.x.x not be able to communicate with each other.
could you please let me know what i am missing?
i am not able to !!
thanks

6 REPLIES 6
s. vater
Advisor

Re: simple routing in linux

On machine A, the default gate has to be 192.168.5.1

On B default gateway: 172.16.0.1

If you have/need other default gateways you have to add routes

On A:
ip ro add 172.16/16 via 192.168.5.1
On B:
ip ro add 192.168.5/24 via 172.16.0.1


HTH
iinfi1
Super Advisor

Re: simple routing in linux

thanks for you reply
i had already assigned the default gateway the way you suggested.
machine on the 192.168.5.x network has default gateway 192.168.5.1

machine on the 172.16.x.x network has default gateway 172.16.0.1

i changed it the other way arnd jus to check. no success.!!
the centos machine with 2 NICs has IPs
172.16.0.1 and 192.168.5.1
any clues
skt_skt
Honored Contributor

Re: simple routing in linux

if the communication needs to go to a different subnet it has to go thorugh a layer 3 device like router which will be actually having the routing difined for the target.

Is your machine cable of routing??
Ivan Ferreira
Honored Contributor

Re: simple routing in linux

You configuration is correct, you should also check that iptables is stopped at machine A and machine B.

Ensure that the ip_forward parameter is really enabled by running:

sysctl -a | grep ip_forward
sysctl -p
sysctl -a | grep ip_forward

Use the traceroute command to diagnose the problem.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Stephen P. Schaefer
Frequent Advisor

Re: simple routing in linux

Your /etc/sysctl.conf looks right, but check that it went into effect:

cat /proc/sys/net/ipv4/ip_forward

should result in "1"; if the result is "0", start looking for typos - or prehaps you didn't reboot? - in which case you can avoid the reboot with

echo 1 | sudo dd of=/proc/sys/net/ipv4/ip_forward
iinfi1
Super Advisor

Re: simple routing in linux

thanks for your replies
well
i see the following
sysctl -a | grep ip_forward
net.ipv4.ip_forward=1


cat /proc/sys/net/ipv4/ip_forward does show
1

i have a feeling i am not doing a few things correctly.
i initially started doing this stuff on a 3 physical machines and things didnt work correctly probably since i was making some mistake.
later i tried the same thing with vmware workstation on my laptop where in i was trying to ping an outside network when the laptop NIC didnt have an IP in the same network as the VM.
i think i have got the concept right now and i will try this in office tomorrow.

thanks all