# Setfib on system boot. FreeBSD 8.2



## monkeyfoahead (Sep 7, 2011)

Greetings,

I have spent considerable time searching and trying to find a way to set the default route on my second routing table automatically at boot. I have yet to find a solution. Apparently rc.subr doesn't support setfib, I have tried an rc script. rc.local is depreciated and not on my system. 

How can I run: 
	
	



```
setfib 1 route add default 10.0.1.1
```
 automatically on boot and have it actually work?

Thanks


----------



## DutchDaemon (Sep 7, 2011)

You can simply create /etc/rc.local (it will still be run), or put the command in root user's crontab with the @reboot time. Use full path names in commands.


----------



## monkeyfoahead (Sep 8, 2011)

Excellent. Thank you. I have tried using roots cron tab but was unable to get it to run. I shall try again and post results. Thanks again.


----------



## monkeyfoahead (Sep 8, 2011)

Sorry I am still having issues. The route will not add, and I do not see the echo test at reboot. Here is my /etc/crontab


```
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD: src/etc/crontab,v 1.33.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute hour    mday    month   wday    who     command
#
*/5     *       *       *       *       root    /usr/libexec/atrun
*/5     *       *       *       *       root    /root/status.sh
@reboot                                 root    /usr/sbin/setfib 1 /sbin/route add default 10.0.1.1
@reboot                                 root    /bin/echo "THIS IS A TEST"
@reboot                                 root    /etc/rc.d/sshd restart
@reboot                                 root    /etc/rc.d/ftpd restart
```


----------



## DutchDaemon (Sep 8, 2011)

Don't edit /etc/crontab, because a system update may overwrite it. Use [cmd=]crontab -e[/cmd] as the root user, or, again, put it in /etc/rc.local. Also, make sure the command actually works when you run it from the command line and check /var/log/messages for failure/error messages.


----------



## monkeyfoahead (Sep 8, 2011)

Hmm, I did what you said an I am still unable to get setfib to work on boot. Is there another method for setting the default gateway on a second routing table?


----------



## DutchDaemon (Sep 8, 2011)

Any logging? Have you looked in e.g. [cmd=]dmesg -a[/cmd] for signs of problems? Any errors on the command line? Try piping the output and errors to a file in either the crontab or rc.local to have a record of what actually happens when that command is run. Both cron and rc.local should be late enough in the boot stage to succeed, but you can always prefix the command with something like 
	
	



```
/bin/sleep 60 &&
```
 to introduce a pause of 60 seconds.


----------



## monkeyfoahead (Sep 9, 2011)

Alright, I resolved it. The issue was that I was trying to set a default gateway for a wireless connection that had yet to be initialized. Adding the sleep to the front of the command gave it time to connect to the wireless network. Thank you sooo much for your help DutchDaemon!


----------

