Restarting Network Interfaces In Ubuntu 14.04

In Linux Tutorials

Restarting Network in Ubuntu 14.04

Restarting network interfaces in Ubuntu 14.04 is not as easy as it should be. Due to a “feature” in Ubuntu 14.04, service network restart  no longer works to restart network interfaces. To restart network interfaces one by one you can use sudo ifconfig interfacename down && sudo ifconfig interfacename up . But what if you wanted to restart all interfaces at once without banging off multiple commands?

Look no further:

To get fancier you can even make this into a script (place it in ~/bin):

Then in vi (or your favorite editor) paste this:

Then:

Or, if you want to alleviate this “feature” entirely, check out my buddy Matt Ahrenstein‘s Chef Recipe for this. It’s a bit more involved, but restored network scripts to expected functionality in an elegant way.

5 Comments

  1. I have a concern. I had modified the \home\etc\interfaces script as given below:
    Also I had created 2 routing tables T1 & T2 within /etc/iproute2/rt_tables
    auto eth3
    iface eth3 inet static
    address xx.xx.xx.xx
    netmask 255. 255.255.0
    gateway yy.yy.yy.yy
    up sudo ip route add zz.zz.zz.zz/29 dev eth3 src xx.xx.xx.xx table T1
    up sudo ip route add default via yy.yy.yy.yy dev eth3 src xx.xx.xx.xx table T2
    up sudo ip rule add from xx.xx.xx.xx table T1

    When I execute the command you gave … it does restart the task but if fails to assign IP address or gateway for eth3.

  2. Try this:
    sudo ifdown eth0 && sudo ifup eth0

    Works like a charm

Submit a comment