Solved FIB and route

Hello,

I have two NICs one for LAN (172.16.2.0/24, igb0) and other for DMZ (192.168.20.0/24, igb1). I wanted to set up separate routes for these using FIB.

My config is

Code:
#cat /boot/loader.conf
net.fibs=2
net.add_addr_allfibs=0

rc.conf
Code:
#cat /etc/rc.conf
ifconfig_igb0="DHCP"
ifconfig_igb1="DHCP"

Routing tables on the first FIB looks like this
Code:
#setfib 0 netstat -rn
Routing tables

Internet:
Destination  Gateway  Flags  Netif Expire
default  192.168.20.1  UGS  igb1
127.0.0.1  link#3  UH  lo0
172.16.2.0/24  link#1  U  igb0
172.16.2.5  link#1  UHS  lo0
192.168.20.0/24  link#2  U  igb1
192.168.20.135  link#2  UHS  lo0

The second routing table is empty
Code:
#setfib 1 netstat -rn
Routing tables (fib: 1)

Now if i try to add a default route in the second routing table it fails
Code:
#setfib 1 route add -net 192.168.20.0/24
route: writing to routing socket: Invalid argument
add net 192.168.20.0 fib 1: Invalid argument
#setfib 1 route add default  192.168.20.1
route: writing to routing socket: Network is unreachable
add net default: gateway 192.168.20.1 fib 1: Network is unreachable

How can I populate the routing table for the second FIB?
 
Code:
setfib 1 route add -net 192.168.20.0/24
This doesn't seem correct as you're not telling it how or where to route that network
Code:
setfib 1 route add default 192.168.20.1
This then won't work as without a route for the 192.168.20.0/24 network, it doesn't know how to get to 192.168.20.1.

I think you should be able to change this line, so that both IP addresses are assigned in both fibs. I can't see any obvious reason why this should be a problem (although it's unclear what you're actually trying to do).
Code:
net.add_addr_allfibs=1
That should then mean the 192.168.20.X address from DHCP appears in the second fib's routing table, at which point you should be able to change the default gateway.

You may also be able to leave that setting as 0, but run dhclient manually in each fib. I've not tested this though.
Code:
# dhclient igb0
# setfib 1 dhclient igb1

Personally I'd prefer to just use static addresses for something like this.
 
Back
Top