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:
1 | for i in $(ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d');do sudo ifconfig $i down && sudo ifconfig $i up;done |
To get fancier you can even make this into a script (place it in ~/bin):
1 2 | mkdir ~/bin vi ~/bin/restart_network.sh |
Then in vi (or your favorite editor) paste this:
1 2 3 | #!/bin/bash for i in $(ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d');do sudo ifconfig $i down && sudo ifconfig $i up;done |
Then:
1 | chmod 755 ~/bin/restart_network.sh |
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.
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.
Did you find a solution?
Nope. The issue still exist.
Try this:
sudo ifdown eth0 && sudo ifup eth0
Works like a charm
For all interfaces? 🙂