Red Hat Disable a NIC permanently..

Hi,

I have a task here where I need to write a script to disable one of my NIC when it checks certain event. Till now I am not able to find a way to do this, because, it should be persistent though restart of services as well as reboots.
I have tested putting it in rc.local, but it doesn't work.

Any help!

Maybe if you told us your operating system that'd help narrow down the possible solutions a bit.

Exactly what UNIX or Linux are you using?

I am guessing you want to take the NIC offline, nothing more.

This seems to be a rather "overkill" approach. What are you trying to accomplish?

In other words this seems a really odd approach. There may be something much simpler and probably safer to implement.

If the device uses a unique driver, you can blacklist the driver.

If not, then you can likely modify udev to (perhaps) get what you want.

See: Blacklisting a single USB device from Linux – Project Gus

(that example isn't for a NIC but you might be able to adapt it, you just have to be able to identify the device)

Sorry for the delay, this is for RHEL 6.6, we want to suppress card for non DB machines, but can do it after building only. I don't want to do misconfiguration in ifcfg-eth* files. Any alternative approach would be better.

What do you mean by "misconfiguration"?

When does this need to take effect?

If boot time is good enough, udev may be a way to go, it can rename the device into something which does not match the entries in your network configuration. Make sure the network config is set to not automatically do DHCP on unknown devices.

Misconfiguration here, can look like: if I want to disable eth1 card, then I can empty ifcfg-eth1 file, and just keep DEVICE=eth1 , and then restart Network services.