# Multi-homed FreeBSD system default gateway question



## Christopher (Feb 6, 2014)

Hi Forum,

I've got a FreeBSD 9.1 system that is attached to two separate /29's connected to different ISPs.  Lets call them NET1/29 and NET2/29.

The system does NAT (via pf) for my private IP space behind this system.  What I would love to happen is have the system select the default gateway based on the source IP address.  Effectively something like this:

If the source IP address is in the range of NET1/29, use the default gateway on NET1 attached to interface em0.
If the source IP address is in the range of NET2/29, use the default gateway on NET2, attached to interface em1.

Right now the system has one default gateway, the gateway on NET1, so if you reach it via its IP address on NET2, the traffic returns to you via the network on NET1, not the network on NET2.  If NET1 goes down, I'd love to be able to reach the system via ssh so I can fail over the internet connection.

Is this possible?  Thanks!


----------



## kpa (Feb 6, 2014)

Look at the route-to directive in pf.conf(5). That will route traffic to the selected gateway for matching traffic. Note that you can only re-route incoming (as seen from the point of a network interface) traffic, the directive has no effect on outgoing traffic.


----------



## ondra_knezour (Feb 6, 2014)

Multiple routing tables may be useful for you. See http://blog.ijun.org/2011/10/multiple-d ... -with.html


----------

