FreeBSD Force DHCP Client (dhclient) to Renew IP Address To Get A New Lease

I have a Linux DD-WRT router DHCP server running on my network. How can I force my FreeBSD based dhcp client to get a new lease from this Linux based router? What is the command in FreeBSD equivalent to Windows’ “ipconfig /renew” command?

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements FreeBSD
Time 1m
The dhclient command, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address. Let us see how to force DHCP client on FreeBSD system to renew IP address.

FreeBSD renew ip command to force DHCP client

The syntax is:
## FreeBSD older system syntax ##
dhclient {interface-name-here}
dhclient [options] {interface-name-here}
## Recommend FreeBSD version 11.x/12.x+ syntax / latest version ##
service dhclient restart {interface-name-here}
service dhclient restart em0

The name of the interface must be specified on the command line. You must run this command as the root user.

How can I see the current IP address settings?

Type the following command:

ifconfig
ifconfig interface
ifconfig em0
ifconfig em0 | grep inet

Sample outputs:

Fig.01: FreeBSD Display Current IP Address, Netmask and Ethernet Options

Here is a sample session from my FreeBSD 11.x jail:

How can I renew or release an IP in FreeBSD for em0 interface?

The syntax is:

$ sudo service dhclient restart em0
## older syntax ##
$ sudo dhclient em0
#######################################
## OR first use 'su -' and then type ##
#######################################
# dhclient em0 

Sample outputs:

Fig.02: Renew an IP address on FreeBSD using dhclient

Other options in FreeBSD to renew dhcp IP address

You can also use the following command to renew dhcp IP address for em0:

service dhclient restart em0
 
## OR ##
/etc/rc.d/dhclient restart em0

Sample outputs:

Stopping dhclient.
Starting dhclient.
DHCPREQUEST on em0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.254
bound to 192.168.1.142 -- renewal in 43200 seconds.

dhclient log file

In order to keep track of leases across system reboots and server restarts, dhclient keeps a list of leases it has been assigned in the /var/db/dhclient.leases.IFNAME file. The IFNAME represents the network interface of the DHCP client (e.g., em0), one for each interface. Try the tail command/more command/less command as follows:

tail -f /var/db/dhclient.leases.em0

OR

less /var/db/dhclient.leases.em0

Sample outputs:

lease {
  interface "em0";
  fixed-address 192.168.1.142;
  next-server 192.168.1.254;
  option subnet-mask 255.255.255.0;
  option routers 192.168.1.254;
  option domain-name-servers 192.168.1.254;
  option host-name "freebsd10";
  option broadcast-address 192.168.1.255;
  option dhcp-lease-time 86400;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.1.254;
  option dhcp-renewal-time 43200;
  option dhcp-rebinding-time 75600;
  renew 0 2015/2/1 21:38:04;
  rebind 1 2015/2/2 06:38:04;
  expire 1 2015/2/2 09:38:04;
}
lease {
  interface "em0";
  fixed-address 192.168.1.142;
  next-server 192.168.1.254;
  option subnet-mask 255.255.255.0;
  option routers 192.168.1.254;
  option domain-name-servers 192.168.1.254;
  option host-name "freebsd10";
  option broadcast-address 192.168.1.255;
  option dhcp-lease-time 86400;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.1.254;
  option dhcp-renewal-time 43200;
  option dhcp-rebinding-time 75600;
  renew 0 2015/2/1 21:44:47;
  rebind 1 2015/2/2 06:44:47;
  expire 1 2015/2/2 09:44:47;
}

Conclusion

You learned how to force DHCP client to renew an IP address on FreeBSD system. See dhclient man page/documenation for more info on a FreeBSD server. We can also type the following man command:
$ man dhclient

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Victor Coss Mar 13, 2016 @ 2:11

    I hope this post isn’t too old for your attention and hope you will reply. Can you explain why the dhclient.leases file file shows the same lease twice? Why does it do that, it does it on mine too and for ISC’s dhclient as well. Sometimes 3 or 4 times.

  • phillipsjk Oct 27, 2020 @ 16:26

    The instructions did not work for me. I specifically wanted to renew immediately to switch to a newly assigned static address. I got the following error message:

    The fix is easy, kill the conflicting dhclient process first (pid will vary):
    # kill 596
    # dhclient interface_name

    • 🐧 Vivek Gite Oct 28, 2020 @ 5:33

      Thanks for the tip. I updated this page and I appreciate your feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.