0

I'm not familiar with CentOS and I need help doing the routing for this. I have a CentOS box with 3 NICs.

eth0      Link encap:Ethernet  
          inet addr:10.50.121.16  Bcast:10.50.121.255  Mask:255.255.255.0


eth1      Link encap:Ethernet  
          inet addr:10.50.128.134  Bcast:10.50.128.255  Mask:255.255.255.0

eth2      Link encap:Ethernet  
          inet addr:10.50.140.97  Bcast:10.50.140.255  Mask:255.255.255.0

eth0 was an existing interface and it has the default route, I've added eth1 and eth2. There are gateways on eth1 and eth2 segments (the .1 address on both). I need to have some network flows between the eth1 and eth2 NICs (through their respective gateways) to do some testing. So I guess I need to set up policy routing for this?

Edit: Sorry to be clear, I'm not saying I'm trying to route packets between the two new interfaces. I need to send some packets out from eth1's IP to eth2's IP through some infrastructure (thus simulating a conversation between vlan of eth1 and vlan of eth2). So I want to do this eth1 -> eth1-vlan-router -> ??? -> eth2-vlan-router->eth2 and then be able to reply using the reverse route. My bad for not being completely clear here.

0

2 Answers 2

0

Modify /etc/sysctl.conf and enable ipv4 routing.

net.ipv4.ip_forward = 1

Then run sysctl -p to apply the settings.

To show the current value of net.ipv4.ip_forward , use :

sysctl net.ipv4.ip_forward
1
  • Thanks for the reply, but I'm not trying to route packets between the interfaces. See my edit where I clarified the question.
    – Brad
    Commented May 18, 2015 at 16:30
0

You will not be able to do this using standard networking APIs.

The Linux network stack uses the so-called weak host model, which implies in particular that any address that is assigned to a local interface is considered as local. If you try to send a packet to a local interface, it will be looped locally, and never hit the network.

While you could probably hack something up using raw sockets, the best solution is most probably to use a second host, perhaps implemented as a virtual machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .