Showing results for 
Search instead for 
Did you mean: 

simple routing in linux

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
i have machine A with IP
machine B with IP

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

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 !!

s. vater

Re: simple routing in linux

On machine A, the default gate has to be

On B default gateway:

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

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

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

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

i changed it the other way arnd jus to check. no success.!!
the centos machine with 2 NICs has IPs and
any clues
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
Super Advisor

Re: simple routing in linux

thanks for your replies
i see the following
sysctl -a | grep ip_forward

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

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