2

How to force FreeBSD to assign default router when acquiring IP in DHCP mode?

My machines are FreeBSD 8.2-PRERELEASE or RELEASE

The NIC (respectively em0 or re0) is set to get a dynamic IP address. Usually I do get everything straight without having to tweak the config i.e rc.conf. The default router is automatically set in the routing table.

In /etc/rc.conf

ifconfig_re0="DHCP"

On my current config, the default router doesn't set. I had to add it manually (??)

$ route add default 10.0.0.1

or add a line in my rc.conf

defaultrouter="10.0.0.1"

But hardcoding the default router is not an option, since it will depend on the network the machine will join.

My machine does get the DHCP lease and acquire a proper IP, only it is not able to find its route to the internet, until the default router is set manually. So I am wondering if there is parameter to set, that will force to recognize and add the default router to the routing table automatically as expected.

Note that this issue is only happening with the ethernet network adapter. wlan0 does get its default gateway set in the routing table properly.

any ideas? or command I could try to trouble shoot why the default gateway is not set automatically?

  • Are wlan0 and em0 on the same DHCP server? My thoughts are that if they are different servers, the one serving em0 isn't sending the default gateway IP. – garethTheRed Nov 27 '14 at 10:41
  • Different range of addresses, so I will have to ask our network admin. How could I catch the response from the DHCP see if it contains both the IP lease and gateway? – zabumba Nov 27 '14 at 11:39
  • This is where it gets tricky as I don't have FreeBSD. However, I'm certain tcpdump is available. Maybe dhcpdump is too. – garethTheRed Nov 27 '14 at 11:43
  • dhcpdump is available in ports in the net/ category. – D_Bye Nov 27 '14 at 12:33
1

If you are using the default dhclient, you can try altering the config for the Ethernet interfaces to request or require that the DHCP server sends a value for the routers option. Try something like this in /etc/dhclient.conf:

interface "re0" {
    request routers;
}

Of course, this will work only if the segment's DHCP servers are configured to respond to request or require directives from their clients with the desired options... The dhclient.conf(5) man page is quite informative.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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