Two network cards - unable to register on eth1

Hello,

I have a freepbx server with two network cards. eth0 is 192.168.180.5 and gateway 192.168.180.254 which is going to my customer LAN (point to point connection)

eth1 is my network which is 192.168.31.130 and gateway 192.168.31.254 (going through pfsense and assigned an external ip)

the client can register to my server using 192.168.180.5 just fine. however when I try to register from my office to the external ip address (eth1) most of the time the registration times out.

this morning I registered my softphone just fine but then few hours later I couldn’t register any more… ports are open on the firewall…

I have added the following to sip_nat.conf

externip=xxx.xxx.xxx.xxx (my external ip)
localnet=192.168.0.0/255.255.255.0

but still I cannot register most of the time to the server. I have tried from multiple locations but it’s the same thing…

Can someone help me please?

Thanks

eZZ,

You can only specify one default gateway for the system.

Use the command ‘netstat -rn’ to see where things are assigned.


Per your post ..

eth0 is 192.168.180.5 Mask 255.255.255.0 No gateway.. 
eth1 is 192.168.31.130 Mask 255.255.255.0 gateway 192.168.31.254

 Traffic to Phones and Devices on 192.168.180.n will go out eth0. Traffic to Phones and devices on 192.168.31.n will leave via eth1.  Traffic to any other network device will leave via 192.168.31.130 then route to the internet or other local networks through your router gateway at 192.168.31.254..

Thanks…

well, I have two different gateway … each network card has its own gateway…

eth0 is 192.168.180.5 Mask 255.255.255.0 gateway: 192.168.180.254
eth1 is 192.168.31.130 Mask 255.255.255.0 gateway 192.168.31.254

however, netstat -rn returns this:

Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.180.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.181.0 192.168.180.254 255.255.255.0 UG 0 0 0 eth0
192.168.31.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
0.0.0.0 192.168.31.254 0.0.0.0 UG 0 0 0 eth1
0.0.0.0 192.168.180.254 0.0.0.0 UG 0 0 0 eth0

and this is my eth1 configuration:
allow-hotplug eth1
auto eth1
iface eth1 inet static
address 192.168.31.130
netmask 255.255.255.0
gateway 192.168.31.254

how about incoming traffic though… if I use my external IP which is routed to 192.168.31.130 it should work just fine… by the problem is that the server doesn’t response.

Do I need to add something to linux routing for this to work?

Thanks

No You can’t do that !!!

If you need to route some network through the 2nd Gateway you need to add exlicit routes.

Like

route add -net 172.16.200.0 netmask 255.255.255.0 192.168.180.254

Would explicitly routetraffic for the 172.16.200.n network through the eth0 adapter and then through the .254 gateway…

Read this about IP gateways & routers…


“it should work just fine… by the problem is that the server doesn’t response.” huh? i interpret that as it does not work fine.

to reiterate what phonebuff already said: you can only have 1 default gateway.

if you have multiple gateways, then you have a great chance that, for example, asterisk receives traffic on one NIC but responds via the other. With asterisk, this can even happen with multiple IP addresses on the same NIC with a single gateway.

what you need to do is have one default gateway and if you want some specific traffic to use a different route, create appropriate static routes.

additionally, in your asterisk configuration, you posted the following setting:

localnet=192.168.0.0/255.255.255.0

this is telling asterisk that addresses in the range 192.168.0.1 thru 192.168.0.254 are within your LAN [and conversely, neither of the LAN segments 192.168.31.0 and 192.168.180.0 are in that localnet] so I think its safe to say asterisk is totally confused.

Good Catch mudslide567 – Missed this one…

Should have been == localnet=192.168.0.0/255.255.0.0

thanks… I did change that but still having the same issue… I will add route and see if that’s gonna work…