Jason Meridth

I am a continuously learning senior full stack SDE/SRE trying to not let best be the enemy of better.

Buy me a coffeeBuy me a coffee

Renew DHCP Lease on Ubuntu VM After Moving Between Wireless Networks

05 Feb 2013 » » ubuntu, networking, wireless

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.