# Two NICs with two gateways on FreeBSD



## pnanvuma (Apr 23, 2014)

Hello 

I have a FreeBSD server with two NICs i.e re0 with IP 21.9.8.7 and re1 with IP 41.2.4.30. I want each to have a gateway of its own so that all routes are active. I have the seetings below in /etc/rc.conf but they don*'*t work. I can reach the server on interface re0 but not on re1.


```
defaultrouter="192.168.100.10"
ifconfig_re0="inet 21.9.8.7 netmask x.x.x.x"
ifconfig_re0_alias0="inet 192.168.100.8  netmask x.x.x.x"

ifconfig_re1="inet 41.2.4.30  netmask x.x.x.x"
static_route="net1"
route_net1="-net 41.x.x.x/26 192.168.100.20"
```

Output of my `netstat` is 

```
# netstat -r
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.100.10    UGS         1       185    re0
41.x.x.x/26    	   link#4             U           0        0    re1
localhost          link#5             UH          0        0    lo0
192.168.100.0      link#1             U           0        0    re0
21.x.x.x/28        link#1             U           0        0    re0
```

I would like to know what I am doing wrong. I appreciate any help rendered

Thank you.


----------



## vermaden (Apr 23, 2014)

This will work:
http://daemonforums.org/showthread.php?t=4610

... but maybe there is more simple way today?


----------



## usdmatt (Apr 23, 2014)

This seems an incredibly awkward setup and it's fairly impossible to help diagnose if we don't have the full configuration or further information on the layout of your network. (The public & private address assigned to re0 is an especially strange configuration).

What do you mean by you want 'all routes active'?
A computer can only really have one active default gateway. The closest you'll get is the sort of set up as above where you have two routing tables and a firewall is used to choose a routing table on a per-packet basis.



> I can reach the server on interface re0 but not on re1.



What 'server' are you trying to reach and how are you testing it?
Also the rc.conf routes entry should be `static_routes="net1"` so i'm not sure that's being processed (at least on boot)
And you have a 41.x network on re1, but are routing a (hopefully different) 41.x network to a host on the private lan on re0??


----------

