How can I restart a network interface? I have a vm that doesn't update its IP address correctly when switching between home and work. The vm runs Ubuntu server and uses a bridged network adapter.

  • 5
    Under what OS/distribution? How is the network configured in the VM? – Gilles Jul 13 '12 at 23:56

Use ifdown to turn it off and ifup to turn it back on. To restart eth0:

> ifdown eth0
> ifup eth0

You will need root privileges.

More details about ifup and ifdown.


Sounds like you've got that interface configured using DHCP. If so, you want to kill the existing DHCP client, and restart it. For a lot of distros, you'd do this:

dhcpcd -k eth0
dhcpcd -d eth0

but not every distro used dhcpcd. I know some use dhclient, and doesn't Debian use pump?

Also, "eth0" may not constitute the correct interface name: do ifconfig -a to see what that VM has.

  • 1
    (Not about downvote:) I'm on Debian, dhcpcd and pump are in the repositories. Confusingly, dhclient is not, and that's the tool I got on installation and been using since. – Emanuel Berg Jul 14 '12 at 13:46

Under Debian, you can tell an interface to get another DHCP lease with

dhclient -v {interface_name}

The -v means "verbose" and will show you the process in action.

@JustinY's answer will work (ifup and ifdown commands) if the interfaces are configured to pull addresses from DHCP. If they are configured as static, they'll just revert to their static IPs. dhclient will attempt to contact a DHCP server no matter what.


the other answers look fine. Simply wanted to add, from the man page:

   -a, --all
          If  given  to  ifup,  affect  all  interfaces  marked auto.  Interfaces are
          brought up in the order in which they are  defined  in  /etc/network/inter‐
          faces.   Combined with --allow, acts on all interfaces of a specified class
          instead.  If given to ifdown, affect all  defined  interfaces.   Interfaces
          are  brought  down  in  the order in which they are currently listed in the
          state file. Only interfaces  defined  in  /etc/network/interfaces  will  be
          brought down.

generally, the --all flag might be extremely helpful to know about because it brings up the network as a whole (provided that the interfaces are marked auto).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy