0

I'm sure this is an easy routing question, but I've been banging my head over it for hours now.

Centos 5. eth1 private. 10.0.0.12/24 gw 10.0.0.1 eth0 public 216.234.x.x gw 216.234.x.x

route command

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
216-234-x-x.  216-234-x-x.    255.255.255.255 UGH   0      0        0 eth0
216.234.x.x   *               255.255.255.248 U     0      0        0 eth0
10.0.0.0        *               255.255.255.0   U     0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
default         10.0.0.1        0.0.0.0         UG    0      0        0 eth1

responds fine to pings on private interface. can route to the internet. But I can't get it to respond to pings on it's public interface.

This is a FreePBX server. The route to the 216.234.x.x is to my sip provider.

I'm a bit of a linux idiot. I've searched every linux route q and A possible but I think I'm not looking for the correct one.

Thanks!

EDIT. I only want SIP and SSH to go in and out of the public interface. Otherwise, everything else should go out the private interface.

1

I assume that you're not pinging from the SIP provider IP.

The problem is that the route for the ping responses is via eth1, which isn't going to get to the source. You need source policy routing to get the responses to go back out eth0.

Assuming that 216.234.0.1 is your gateway and 216.234.0.10 is your public IP.

  1. Create a new routing table (only needs to be done once).

    echo 10 eth0 >> /etc/iproute2/rt_tables
    
  2. Add a default route to the new routing table going out eth0.

    ip route add default via 216.234.0.1 table eth0
    
  3. Add a rule to match packets with the public IP as the source and use the new table.

    ip rule add from 216.234.0.10 lookup eth0
    
  • Thanks. I get an error on the last command. Error: argument "src" is wrong: Failed to parse rule type – Dayton Brown Feb 22 '13 at 21:23
  • @DaytonBrown Sorry, should be from. – mgorven Feb 22 '13 at 21:24
  • Magic! One last question. Is there a quick way to have it only respond to pings from a few specified addresses? – Dayton Brown Feb 22 '13 at 21:29
  • @DaytonBrown That should be done with a firewall. – mgorven Feb 22 '13 at 21:32
  • 1
    oops. One more last question. What is the format of the commands to add them into the routing files to persist them across reboots – Dayton Brown Feb 22 '13 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.