# How to use setfib?



## artik (Jul 7, 2011)

Hi all! My firewall is ipfw. I have two uplinks. So, kernel option 
	
	



```
option routetables=4
```
 ok

What do I do next? Please tell me more about using this command. Thanks.


----------



## vermaden (Jul 7, 2011)

Like that mate: http://daemonforums.org/showthread.php?t=4610


----------



## artik (Jul 7, 2011)

Yeah, thanks!


----------



## artik (Jul 8, 2011)

Sorry, doesn't work. I do next:

```
uname -a
FreeBSD router 7.3-RELEASE FreeBSD 7.3-RELEASE #0: Fri Mar  4 23:23:28 EET 2011     artik@router:/usr/obj/usr/src/sys/RVM  i386
```

rc.conf

```
cat /etc/rc.conf | grep ifconfig
ifconfig_em2="inet 172.16.0.2/22"
ifconfig_em1="inet A.28.204.18/30"
ifconfig_em1_alias0="inet B.28.205.220/30"
cat /etc/rc.conf | grep defa
##defaultrouter="A.28.204.17"
##defaultrouter="B.200.33.241"
```
/etc/rc.local

```
cat /etc/rc.local 
# define default routes
setfib 0 route delete default
setfib 0 route add    default B.200.33.241
setfib 1 route delete default
setfib 1 route add    default A.28.204.17
```
*ipfw show*

```
#cat fw.sh 
ipfw add  allow ip from any to any via lo0
ipfw add setfib 1 ip from any to any via em1
ipfw add setfib 0 ip from any to any via em0
ipfw add 10000 divert 8668 ip4 from any to any via em1
ipfw add 11000 divert 8669 ip4 from any to any via em0
ipfw allow ip from any to any
```
Routing tables

```
#netstat -nr
Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            B.200.33.241     UGS         0     8480    em0
A.28.204.16/30    link#3             UC          0        0    em1
A.28.204.17       00:30:48:df:42:f7  UHLW        1        0    em1    466
A.28.205.220/30   link#3             UC          0        0    em1
127.0.0.1          127.0.0.1          UH          0      232    lo0
172.16.0.0/22      link#4             UC          0        0    em2
172.16.0.2         00:02:a5:4e:db:bb  UHLW        1        6    lo0
172.16.0.4         00:0a:5e:78:80:33  UHLW        1       35    em2    717
172.16.0.5         00:26:18:41:41:9d  UHLW        1        0    em2   1177
172.16.0.6         00:04:76:a2:7a:9a  UHLW        1        5    em2    675
172.16.0.7         00:30:48:91:5c:27  UHLW        1      200    em2    637
172.16.0.13        00:16:3e:27:95:a7  UHLW        1      119    em2   1175
172.16.0.124       00:26:18:41:41:9d  UHLW        1    12344    em2    320
172.16.1.0         48:5b:39:96:b6:50  UHLW        1     1113    em2   1156
172.16.1.2         00:1d:7d:9c:ad:33  UHLW        1     2689    em2   1087
172.16.2.11        48:5b:39:96:b5:1c  UHLW        1     1163    em2   1175
172.16.2.12        20:cf:30:8c:e7:0d  UHLW        1        4    em2   1114
172.16.2.32        00:1d:7d:9c:ad:55  UHLW        1      780    em2    715
192.168.2.0/24     link#2             UC          0        0    xl0
192.168.2.255      ff:ff:ff:ff:ff:ff  UHLWb       1       10    xl0
A.200.33.240/28  link#1             UC          0        0    em0
A.200.33.241     00:1e:13:f6:89:1b  UHLW        2        0    em0   1179
```
So, I see the default router, should it be? If I do the command *ifconfig em0 down*, the default router is not changed, the internet is off.

Please help me understand


----------

