1 NIC - Need two gateways due to local sip

So if I have eth0 and eth0:sip, how do I determine which is the default route? It doesn’t seem like I can make this change in the GUI. Is this a command line fix in the eth0 file

defaultroute=yes

or something like this?

1 Like

I am working with Mark on this issue and have been doing some testing of my own. Here is what we have at our office. Two ISPs, with two routers. One router acting as DHCP server at 192.168.0.1/23 and the other at 192.168.0.2/23. there are two Proxy IPs that this SIP provider uses. They are 10.7.32.20 and 10.7.32.36. I created a new file at etc/sysconfig/network-scripts/route-eth0 with the entries like so:
10.7.32.20/24 via 192.168.0.2 dev eth0
10.7.32.36/24 via 192.168.0.2 dev eth0
I restarted the network with service network restart
Then a route -n provided this:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
192.168.0.0 0.0.0.0 255.255.254.0 U 0 0 0 eth0

I also tried these entries in the route-eth0

ADDRESS0=10.7.32.20
NETMASK0=255.0.0.0
GATEWAY0=192.168.0.2
METRIC0=10
ADDRESS1=10.7.32.36
NETMASK1=255.0.0.0
GATEWAY1=192.168.0.2
METRIC0=11

Again restarting the network and running route -n got the same results. A traceroute to 10.7.32.20 goes out the 192.168.0.1 gateway.

The system I am using to test is a FPBX 14.0.3.13 64 bit
The system firewall is not enabled.
Everything I have read says this should work, but it isn’t. Did I miss something?

Thanks for any ideas

How are you assigning the IP to your FreePBX?
On a side note, is there a specific reason you’re using 23 instead of 24

Assigning the ip using system admin. Our office network is a 23. We use both 192.168.0.x and 192.168.1.x addresses

Sorry, I meant static or DHCP?

Well, there are a couple of places that might be biting you.

Try this:
ADDRESS0=10.7.32.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.0.2
METRIC0=0

This covers both your addresses (if you want two entries, use 255.255.255.255 as the netmask) and sets the Metric low enough that it will be used. At 10, if you have access through the default route, all of your traffic will go that way (because it’s a “better” route).

If you want to try to add the route manually, you’ll have to change the syntax on your route command (since both routes are through eth0). Instead of the route add 10.7.32.0/24 eth0, you’ll need to use a different syntax (route add 10.7.32.0/24 gw 192.168.0.2, perhaps). I don’t have the specifics for you, but the “man route” command should get you close.

Static

Thanks Dave, I will try that out

Sorry for the question but have you correctly defined the gateway? If the traffic is going through.1 instead of .2 then somewhere in your config .1 is defined as the default.

Thanks to help from Lorne and Gerardo of the sangoma support team we have made this work:

Step 1: From the command line run

route add -net < network_address> gw < gateway> <interface_name>

so for us it was

route add -net 10.7.0.0/16 gw 192.168.2.240 eth0

This sends all traffic to the onsite sip out the .2.240 gateway

Running route -n confirms the static route was added and showed that the default gateway for traffic 0.0.0.0 is going to 192.168.1.1

The only problem is that with a reboot this static route is deleted. So solve this we navigated to /etc/asterisk/rc.local and added the route command above to the file.

We then needed to make the file executable upon reboot

chmod +x /etc/rc.d/rc.local

Tested and all works

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.