restart network interface after editing /etc/network/interfaces [duplicate]
After editing /etc/network/interfaces, the usual way to get the system to re-read the file and use the changes is to do:
sudo ifdown wlan0 && sudo ifup wlan0
Of course, substitute the relevant interface if it's not wlan0.
I assume Network Manager is not present on this system. If it is, you are better off to make your changes there rather than /etc/network/interfaces.
Please be aware that starting with Ubuntu Server 16.04, you need to use the ip
command to flush the interface address before restarting networking, otherwise changes in the interfaces file will not take effect.
IMPORTANT: If you are doing this through an SSH connection, it's important that you chain the commands together as shown below, because you may lose the connection to the server immediately after you flush the network interface.
sudo ip addr flush interface-name && sudo systemctl restart networking
(Source)