Command to get the default IPv4 address in FreeBSD

This will print your system's default IPv4 address, determined by the default route. This should work in 98% of the cases unless for some reason no IP4 address is set or there is no default route.
ifconfig $(netstat -4rn | grep ^default | sed "s/.* //") inet | awk '$1 == "inet" {print $2}'