Have you ever worked on a virtual machine which was running Linux? Ever switched between different network types on your laptop (WLAN to Ethernet)? I am. And a lot of times the virtual machine just coulnd't figure out how to switch with it. So I landed in a state where I coulnd't use a connection to the internet from within the virtual machine.

I ended up with simply restarting the responsible interface.

$ sudo ifdown eth0
$ sudo ifup eth0

If you want to get a step further, you can add an alias into your ~/.bashrc

This would look somethink like:

alias ifdu='sudo ifdown eth0 && sudo ifup eth0'