Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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"
share|improve this question
    
Is it possible for you to switch NIC's so that em0 would be the one who use DHCP and em1 is the one with the static IP? That would probably solve this in a easy way. –  pauska Feb 1 '12 at 19:00
    
@pauska Really?! em0 is considered as default before em1? Sounds like a tempting, easy answer to this nuisance. Anyways, I'd like to know if there's a solution without switching roles of the two NICs. –  poplitea Feb 1 '12 at 19:04
2  
re "Doesn't 123.123.123.123/32 mean almost the same as default?" No. The default is 0.0.0.0/0. The /32 means narrowing to one host only. –  kubanczyk Feb 1 '12 at 22:28
    
Did you check, that your ISP sends a Defaultgw with DHCP? Do you use any custom dhclient configuration? try to run dhclient manually and see what happens. –  arved Feb 3 '12 at 10:18
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks for the defaultroute_delay-tip! I'll check that one out. –  poplitea Feb 14 '12 at 19:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.