I actually wanted to post the below as an answer to this question titled: ifup eth0 timeout during boot. But am not sure if this is right approach or it's a way of screwing up things badly.
We can actually check if the network cable is connected to the machine, or not, by running the command,
grep "" /sys/class/net/eth0/carrier
When the network cable is plugged in, the output would be 1 for the above command and when it is not plugged in, the output would be 0 for the above command. I tested the above part in my system and it worked fine as expected.
Now the question lies in how to include this condition on startup. We can include this in the network startup file, which can check this condition before bringing up the interfaces. In RHEL box the file
/etc/sysconfig/network-scripts/ifcfg-eth0 is used to bring up the network interfaces.
So, If I change the file to look like,
cable=$(grep "" /sys/class/net/eth0/carrier) if $cable -eq 1 then #rest of the /etc/sysconfig/network-scripts/ifcfg-eth0 as it is. else break
However, before proposing this method, or even trying on my machine, my question is: When the services are being brought up will the
/sys/class/net/eth0/carrier be ready and available? Assuming this approach works, if I decide to use wireless network will there be a problem?