Setfib on system boot. FreeBSD 8.2

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:
Code:
setfib 1 route add default 10.0.1.1
automatically on boot and have it actually work?

Thanks
 
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.
 
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.
 
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

Code:
# /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
 
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.
 
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?
 
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
Code:
 /bin/sleep 60 &&
to introduce a pause of 60 seconds.
 
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! :)
 
Back
Top