I am new to Linux server administration and I am try out some network commands.
I wish to change the network settings by modifying the /etc/network/interfaces file and want the changes to take effect immediately as possible. But I do not wish to restart the networking service, as it will cause disaster. We also want to avoid rebooting the system as much possible.
How to do it? I have used the ip commands and the ifup/ifdown commands, but for some strange reason, they sometimes fail. Where is any documentation or books to study this?
Sorry for English.
Debian Linux reload changes to interfaces file without a network restart
debianlinux-networking
Related Topic
- Debian multiple network interface multiple networks
- Ifup default route missing
- Bond active backup Linux
- Debian – Can’t set a second network interface on a second ethernet port Debian 3.16
- Ubuntu – Alternative to /etc/network/interfaces on Ubuntu 18.04
- Realtek – Fix RTL8111/8168/8411 Ethernet Card Randomly Disconnecting
Best Answer
The problem with
ifup/ifdown
is that it reads the current config to bring the interface up and down. So if you had, e.g.:and you
ifup eno1
, what really happens is someip addr
andip route
commands executed. Among them you'll haveip addr add 1.1.1.1/24 dev eno1
. If now you modify the file:and you
ifdown eno1
, it will not executeip addr del 1.1.1.1/24 dev eno1
butip addr del 2.2.2.2/24 dev eno1
, hence the errors when you modify the config while an interface is up.To work around this, backup the old configuration file before modifying it:
and after you modified the configuration, use the backup for the
ifdown
command:If you are connecting to the machine remotely, a good idea would be to reverse the operation after a timeout:
If you lose connectivity, it should be restored after 180 seconds, otherwise you can just kill the job.