ifconfig fails because usb ethernet adapter is not ready yet on FreeBSD
Solution 1:
The USB NIC seems to take a finite time to become available, which sometimes occurs after the "netif" service is started. This results in missing network interfaces and a broken server.
One solution is to insert a short time delay before the "netif" service is started which gives more time for the NIC to become available. This can be accomplished by adding a simple RC script.
For example, add a file called /usr/local/etc/rc.d/ourdelay
, which contains:
#!/bin/sh
# PROVIDE: ourdelay
# REQUIRE: FILESYSTEMS
# BEFORE: netif
# KEYWORD: nojail
. /etc/rc.subr
name="ourdelay"
rcvar="${name}_enable"
start_cmd="${name}_start"
stop_cmd=":"
: ${ourdelay_enable:="NO"}
: ${ourdelay_time:="5"}
ourdelay_start()
{
echo "Begin delay of ${ourdelay_time} seconds"
sleep ${ourdelay_time}
echo "Finish delay of ${ourdelay_time} seconds"
}
load_rc_config $name
run_rc_command "$1"
This file will need the execute bit set, use the command:
# chmod 555 /usr/local/etc/rc.d/ourdelay
Then enable it in your /etc/rc.conf
or /etc/rc.conf.local
file, using:
ourdelay_enable="YES"