I am posting an answer which is worked for me. I think I will not be able to achieve this using NetworkManager as per redhat documentation:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_with_ip_commands
Note
The ip link set ifname command sets a network interface in IFF_UP state and enables it from the kernel's scope. This is different from the ifup ifname command for initscripts or NetworkManager's activation state of a device. In fact, NetworkManager always sets an interface up even if it is currently disconnected. Disconnecting the device through the nmcli tool, does not remove the IFF_UP flag. In this way, NetworkManager gets notifications about the carrier state.
As per this, NetworkManager always set the IFF_UP flag even if you are disconnected, so the ethtool
see it as link detected.
To resolve this issue in my scenario, I can add this particular interface to the unmanaged devices list of NetworkManager and by doing this, when I reboot the interface, it is correctly showing that the link is not detected by ethtool
.
cat /etc/NetworkManager/conf.d/99-unmanaged-devices.conf
[keyfile]
unmanaged-devices=interface-name:ens224
Once the interface is added to the file, I can run systemctl reload NetworkManager
and the interface will be removed from the Network Manager controlled interfaces lists.
To make the device controlled by NetworkManager again, remove the file /etc/NetworkManager/conf.d/99-unmanaged-devices.conf
and reload the network manager.
Once it is removed from NetworkManager I will no longer be able to run the tcpdump
or any other command to listen on that interface as it is not showing as UP.