LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   centos as router problem (https://www.linuxquestions.org/questions/linux-networking-3/centos-as-router-problem-4175495212/)

amr.es 02-17-2014 06:52 AM

centos as router problem
 
hello, I need your help please

I have centos 6.5 server with two NICs cards to work as a router without nat
first eth0 is connected to a router1 with subnet 10.10.10.0/30 (centos has 10.10.10.2 IP and the router has 10.10.10.1 IP)

second eth1 is connected to another router2 with public subnet for example 8.8.8.0/30 (centos has IP 8.8.8.2 and router IP 8.8.8.1)

I have configured the default gateway to be 8.8.8.1
I have enabled IPV4 forwarding

router1 can ping to 8.8.8.1 through the server successfully, the traffic get forwarded from eth0 (10.10.10.2) to eth1 (8.8.8.2) and back successfully

now if there is a client behind router1 wants to reach hotmail.com for example lets assume client ip is 1.1.1.1 wants to reach 2.2.2.2, the communication should be as follow
1- router1 will handle the traffic to server eth0
2- eth0 will forward the traffic to eth1 (because there is only one route which is the default gateway to 8.8.8.1)
3- eth1 will forward the traffic to router2 8.8.8.1
4- router2 will return the answer to the client but through another route not through the server

I had centos 5.3 and it worked properly with this design, when i issue tcpdump -i eth0 i see the traffic from the client (EX 1.1.1.1.port > 2.2.2.2.port)
also tcpdum -i eth1 show the same traffic (EX 1.1.1.1.port > 2.2.2.2.port)
also iptables -nL -v show the forwarding chain packet count increase

now the new server Centos 6.5 does not do the same I see the traffic enters the server on eth0(10.10.10.2) with tcpdump -i eth0, but I can't see it forwarded to eth1 (8.8.8.2) with tcpdump -i eth1, and also iptables doesn't show increase in the forwarding chain packet count, why is this happening?

PLease any help because this issue is driving me crazy, am i missing something or what?!!

sorry for my long post.

jpollard 02-17-2014 07:35 AM

Have you enabled forwarding? You can check by "cat /proc/sys/net/ipv4/ip_forward", and it should have a "1" value.

You can do it temporarily for testing by "echo 1 /proc/sys/net/ipv4/ip_forward", though this will only last until the next reboot.

A permanent setting (as in, set at each boot) by editing /etc/sysctl.conf and set "net.ipv4.ip_forward = 1".

amr.es 02-17-2014 10:32 AM

thanks yes forwarding is enabled, i made sure it is enabled by

router1 can ping to 8.8.8.1 through the server successfully, the traffic get forwarded from eth0 (10.10.10.2) to eth1 (8.8.8.2) and back successfully

if the forwarding is not enabled router1 can not reach 8.8.8.1

myatthu 02-18-2014 09:11 AM

Can you try Reverse Path Forwarding (RPF) filtering in loose mode?

Code:

echo 2 > /proc/sys/net/ipv4/conf/default/rp_filter
echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter

If it is working, you should configure at /etc/sysctl.conf
Code:

net.ipv4.conf.default.rp_filter = 2

amr.es 02-22-2014 07:09 AM

Thank you very much, this solved the problem and also this is the difference between centos 5 and centos 5 the extra boolean of Reverse Path Forwarding in loose mode 2 as described here: https://access.redhat.com/site/solutions/53031

Thanks again :)


All times are GMT -5. The time now is 06:00 PM.