Multiroute question
Julian Elischer
julian at freebsd.org
Fri Sep 21 05:54:56 UTC 2012
On 9/20/12 10:25 AM, Michael MacLeod wrote:
> Actually, multiple routing tables is the correct solution. I
> documented it here:
> http://www.mmacleod.ca/blog/2011/06/source-based-routing-with-freebsd-using-multiple-routing-table/
> >From the post: "... But route-to and reply-to do not trump the
> default routing table for traffic that originates or terminates on
> the router itself. They are useful only for traffic passing through
> the router. pf can only make routing decisions when a packet passes
> through an interface. It can try and set the reply-to interface to
> be the second WAN connection when an inbound SSH connection is made,
> but neither the SSH daemon nor the routing table on the host know or
> care about the routing preferences of pf." On Thu, Sep 20, 2012 at
> 11:01 AM, Michael Pounov <misho at elwix.org> wrote:
>
hi,
not a bad article..
a couple of things...
firstly, though it's not relevent to THIS case, you can assign
differnet fibs to different sockets on the same process, so
theoretically a single sshd instance could do both tasks.
The question is "how does it know which to use?" without extending
sshd to add more config options for that, we have just a few
possibilities..
Firstly, all sockets inherit their fib from that assigned to the
process, but what if we didn't assign one to the process, but let the
sockets take on the fib assigne to the packets of the incoming
request? The packets in turn can get a fib from two sources: policy,
via pf, or the ipfw setfib command, OR from the interface. as we can
now assign a fib to an interface and packets coming in on that
interface will take on the fib of the incoming interface. The only
missing part of this is the code that lets teh process's fib float in
the wind.
I was considering setting this like: setfib -N sshd blah....
where -N would be expressed within the kernel as fib -1.
In the socket code that would be inherited, and we would add code in
the listen/accept code of the sockets so that when it discovers the
socket is assigned fib -1, it switches it over to the fib of the
incoming SYN packet (or whatever protocol).
I've been meaning to a this ever since I added multifib support.
It may require a small amount of code in every protocol (a line or two
of C)
This would allow us to make unmodified arbitrary networking servers
work correctlty in multihomed systems.
from man ifconfig:
fib fib_number
Specify interface FIB. A FIB fib_number is assigned to all
frames or packets received on that interface. The FIB
is not
inherited, e.g. vlans or other sub-interfaces will use the
default FIB (0) irrespective of the parent interface's
FIB. The
kernel needs to be tuned to support more than the
default FIB
using the ROUTETABLES kernel configuration option, or the
net.fibs tunable.
from man ifpw:
setfib fibnum | tablearg
The packet is tagged so as to use the FIB (routing
table) fibnum
in any subsequent forwarding decisions. Initially this
is lim-
ited to the values 0 through 15, see setfib(1).
Processing con-
tinues at the next rule. It is possible to use the
tablearg key-
word with a setfib. If tablearg value is not within
compiled FIB
range packet fib is set to 0.
from man setsockopt
SO_SETFIB can be used to over-ride the default FIB (routing table) for
the given socket. The value must be from 0 to one less than the
number
returned from the sysctl net.fibs.
see also: setfib(1), setfib(2), setsockopt(2)
More information about the freebsd-net
mailing list