Created attachment 1506330 [details]
Route lost after restart interface
Description of problem:
We added some iscsi cards to the server and configured network on the interface, we use "ifconfig down" and "ifconfig up" command to restart the interface,and the route on the interface lost
Version-Release number of selected component (if applicable):
Redhat 7.6 Native
Steps to Reproduce:
1.add iscsi card to the server
2.configure network on the interface
3.restart the interface
The route lost
The network configuration won't lost after restarting
See the attachment for details
- NetworkManager is a daemon to configure the network based on connection profiles (type `nmcli `, for an overview of the NetworkManager configuration -- in case you are actually using NetworkManager).
- ifup/ifdown are scripts provided by initscripts package. initscripts provide an alternative way for configuring network based on ifcfg files in /etc/sysconfig/network-scripts. As such, it is also profile based (if you understand the ifcfg files as a profile).
Note, that if NetworkManager is enabled, then initscripts' ifup/ifdown command may (depending on configuration) call to NetworkManager to perform the action, instead of doing it themselves.
- ifconfig/route are deprecated tools which directly talk to kernel to configure networking devices, addresses and routes. Nowadays, it would be advisable to use iproute2 (ip link, ip addr, ip route) instead.
Anyway. So, your initial state is that your network is configured (be it via NetworkManager, initscripts, or even something else). Then you issue
# ifconfig enp3s0f0 down
As said, this is not the same as
# ifdown enp3s0f0
# nmcli device disconnect enp3s0f0
Instead it is the same as:
# ip link set enp3s0f0 down
which instructs kernel to set the interface down (as far as kernel is concerned, not as far as NetworkManager/iniscripts are concerned). When an interface goes down, kernel will delete all IPv4 routes on that interface. When you bring the interface up again (ifconfig enp3s0f0 up), somebody needs to re-add the lost route.
The first point: just don't do that! `ifconfig ... down` is the wrong thing. Issue either
# ifdown enp3s0f0
# ifup enp3s0f0
or (if you use NetworkManager) use `nmcli device connect enp3s0f0`. Or if you really want to manually configure the interface in kernel (with iproute2, ifconfig), then you should be prepared to manually re-add the route as well.
If your system is configured via initscripts (without NetworkManager), then what you are doing is not fixable. initscripts have no understanding what is happening and they don't know that you bring the interface up again and that they should do something about that.
If your system is configured via NetworkManager, then indeed NM will noticed that the link goes down, it will notices that it comes up again, and it should restore the route. That is similar to https://bugzilla.redhat.com/show_bug.cgi?id=1548237#c2 and should be improved.
Are you using NetworkManager or plain initscripts? What gives `nmcli device`?
TL;DR: don't call `ifconfig enp3s0f0 down`. It's probably not what you want.
Thanks a lot for you help,it solved my problem.
This upstream commit should improve NM behavior to note remove routes when the interface is brought down manually:
I think we should include it in RHEL 7.7.
Also: let's not needlessly take the interface down: bug 1639274 and https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/54
This was fixed along the way in NetworkManager-1.12.0-10.el7_6. The functionality is preserved in 1.18 and ifconfig down/up doesn't break any routing.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.