[20090105] The Release Notes for 7.1-RELEASE should have mentioned that FreeBSD now supports multiple routing tables. To enable this, the following steps are needed:
Add the following kernel configuration option and rebuild the kernel. The 2 is the number of FIB (Forward Information Base, synonym for a routing table here). The maximum value is 16.
options ROUTETABLES=2
The procedure for rebuilding the FreeBSD kernel is described in the FreeBSD Handbook.
This number can be modified on boot time. To do so, add the following to /boot/loader.conf and reboot the system:
net.fibs=6
Set a loader tunable net.my_fibnum if needed. This means the default number of routing tables. If not specified, 0 will be used.
Set a loader tunable net.add_addr_allfibs if needed. This enables to add routes to all FIBs for new interfaces by default. When this is set to 0, it will only allocate routes on interface changes for the FIB of the caller when adding a new set of addresses to an interface. Note that this tunable is set to 1 by default.
To select one of the FIBs, the new setfib(1) utility can be used. This set an associated FIB with the process. For example:
# setfib -3 ping target.example.com
The FIB #3 will be used for the ping(8) command.
The FIB which the packet will be associated with will be determined in the following rules:
All packets which have a FIB associated with them will use the FIB. If not, FIB #0 will be used.
A packet received on an interface for forwarding uses FIB #0.
A TCP listen socket associated with an FIB will generate accept sockets which are associated with the same FIB.
A packet generated in response to other packet uses the FIB associated with the packet being responded to.
A packet generated on tunnel interfaces such as gif(4) and tun(4) will be encapsulated using the FIB of the process which set up the tunnel.
Routing messages will be associated with the process's FIB.
Also, the ipfw(8) now supports an action rule setfib. The following action:
setfib fibnum
will make the matched packet use the FIB specified in fibnum. The rule processing continues at the next rule.
阅读(7478) | 评论(0) | 转发(0) |