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.
Shut the network interface down using
(replace
eth0
with the interface you want to change) and bring it up again usingIn Ubuntu Server 16.04 and above you must use the
ip
command (man page) to flush the address before restarting networking, otherwise any address changes in the interfaces file will not take effect:I got this answer from this helpful article
Stop all interfaces using
Configure (edit) your interfaces as you wish, then
Start them again
There is no need to reboot.
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.
/etc/network/interfaces
controls the ifupdown tools.So after making changes, you can just say eg
sudo ifup eth0
.Actually none of these work. Tested on Ubuntu 16.10. these had no effect.
Through all these the old dhcp ip came back and not the static. i wonder if this is intentional?
Try a flush between ifup and ifdown. This worked on Mendel (Google Coral), which is a Debian based.
Without the flush, the interface would restart without reading the config file.