JM (Jason Meridth)

JM (Jason Meridth)

Learn, Converse, Share

05 Feb 2013

Renew DHCP Lease on Ubuntu VM After Moving Between Wireless Networks

TL;DR

sudo dhclient -r [eth0] && sudo dhclient [eth0]

I add that command as an alias to my ~/.bashrc file

alias resetdhcp='sudo dhclient -r eth0 && sudo dhclient eth0'

then resourced it so I could use it in the bash session I was in

source ~/.bashrc

I constantly have my Ubuntu VM (VirtualBox) running on my Windows laptop and dock/undock it between work and home. Obviously those are two different wireless networks. Well, I was unable to find a dhcp renewal command that would work until today (look above).

This command releases and renews your DHCP IP Address.

I’m very happy about this.

dhclient man page

When run by itself, your instance will seek out a new ip lease.