"route add default -iface em1" in rc.conf on FreeBSD

I have two NICs on my FreeBSD server, which are set up like this in rc.conf:

ifconfig_em0="10.0.0.1    netmask 255.255.255.0"        # LAN NIC
ifconfig_em1="DHCP"                                     # WAN NIC

This setup doesn't give any default route, only (assuming 123.123.123.123 is the WAN IP of em1):

10.0.0.0/24         ---> em0
123.123.123.123/32  ---> em1

When I try to ping WAN IPs like 8.8.8.8, I get No route to host. (Why? Doesn't 123.123.123.123/32 mean almost the same as default?) Anyway, I can run add route default -iface em1, and then WAN IPs are directed through em1, as they should.


How do I make interface em1 the default, reboot-persistent route for my system? I.e., how can I say add route default -iface em1 in rc.conf? (I have to make the route interface-specific and not specific to the interface's IP, because the IP of em1 is dynamically given by my ISP.)


I've tried the following without success:

static_routes="mydefault"
route_mydefault="default -iface em1"

and

defaultrouter="-iface em1"

Gah - totally rewritten because I misread the question!

It sounds like your route may not be coming up because em1 isn't up and ready when the rc scripts go to set the default router. You can use the defaultroute_delay option in rc.conf to make the system wait a while before bringing up the default routes.

Also like @arved said you may want to make sure your ISP is sending the router information in their DHCP leases -- If you want to use their gateway they should be specifying one, otherwise you will only be able to reach devices on the subnet they specify.