17

I have a Red Had Linux machine with two NICs:

  • eth0 - 10.0.1.253 | 255.0.0.0
  • eth1 - 10.0.1.1 | 255.255.255.0

So the first one is on a class A subnet, the second is on a class C subnet.

This is what my routing table looks like:

Destination  Gateway   Genmask        Flags Metric Ref Use Iface
10.0.1.0     *         255.255.255.0  U     0      0     0 eth1
link-local   *         255.255.0.0    U     1002   0     0 eth0
10.0.0.0     *         255.0.0.0      U     0      0     0 eth0
default      10.0.0.1  0.0.0.0        UG    0      0     0 eth0

The two NICs are connected to separate physical (actually virtual) LAN segments and I have a host connected to the same LAN segment eth0 is with IP 10.0.1.3 | 255.0.0.0 but I can't ping it from this machine because it appears its getting confused and sending out eth1. When I disable eth1 to force the packet to go out eth0 it connects but I need both enabled.

I'm thinking the solution is to add a manual route to my host 10.0.1.3 to force it to go through eth0. I'm not sure given the information above what the command would be to manually the route. Basically I need to send any traffic to 10.0.1.3 out eth0. Any help would be great!!

2 Answers 2

14

# route add -host 10.0.1.3 dev eth0

0
29

On a newer machine using the ip binary the syntax to add a route is slightly different (but thankfully really consistent for hosts/networks/etc).

ip route add 10.0.1.3 via 10.0.0.1 dev eth0

If you were going to add a new default route for a new 10.0.2.0 network through the eth1 interface it might be something like this.

ip route add 10.0.2.0/24 via 10.0.1.1 dev eth1

Source: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-networkscripts-static-routes.html

You must log in to answer this question.

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