Editing network interfaces without system rebooting
I'd like to make some changes to my networking configuration by editing my /etc/network/interfaces
file. What's the cleanest way to make changes to this file and have them take effect, without having to reboot? Typically, I've been doing:
- Edit the file
service networking restart
But I have the impression that this isn't the "right" way to make these kinds of changes.
Solution 1:
Shut the network interface down using
sudo ifdown eth0
(replace eth0
with the interface you want to change) and bring it up again using
sudo ifup eth0
Solution 2:
In Ubuntu Server 16.04 you must use the ip command to flush the address before restarting networking, otherwise any address changes in the interfaces file will not take effect:
$ sudo ip addr flush interface-name
$ sudo systemctl restart networking
I got this answer from this helpful article
Solution 3:
Stop all interfaces using
sudo /etc/init.d/networking stop
Configure (edit) your interfaces as you wish, then
Start them again
sudo /etc/init.d/networking start
There is no need to reboot.
Solution 4:
Why don't you think it is the right way. Think, what can ubuntu do extra during booting? Ubuntu has a list of services that need to run during booting, each service has a list of consecutive command to start itself. Ubuntu just run networking service through /etc/init.d/networking script which contains some command that need to run network service. So if any change need to apply to your network then you have to restart your service and the way is recall your service's consecutive commands.
Solution 5:
/etc/network/interfaces
controls the ifupdown tools.
So after making changes, you can just say eg sudo ifup eth0
.