September 30, 2004

Renewing a DHCP lease using FreeBSD

FreeBSD is not Windows in that the system won't try to renegotiate a DHCP lease after having reconnected a network link that had been disconnected. Users who frequently swap networks under Windows are intimately familar with the ipconfig /renew command. While this obviously won't work under FreeBSD, there is an equivalent command to renew a DHCP lease on an interface, without having to wait for the lease to expire.

First, double check what interface you want to renew. The interface is merely the driver type plus an interface number. There are lots of drivers out there (eth, fxp, sis, tx, etc), but the procedure is still the same.

alexm@gouge [2] ~ > ifconfig
sis0: flags=8843 mtu 1500
        inet 66.166.138.141 netmask 0xfffffff8 broadcast 66.166.138.143
        ether 00:0a:e6:34:f9:4f
        media: Ethernet autoselect (100baseTX )
        status: active

In this case the active interface is sis0, so here is the command to run.

# /sbin/dhclient -r sis0

Now occasionally that may not work as quickly as you might like. If you want to force it, you can restart the networking components by hand.

# /etc/netstart

Technically /etc/netstart has been obseleted by /etc/rc.network, although both seem to work just fine.

Nothing complicated. Just another small command to remember.

Posted by alexm at September 30, 2004 09:31 AM.
Send comments/suggestions to contact@moundalexis.com.
Add to del.icio.us | Digg this | Subscribe to this feed
Comments