How can I configure the network interface on Linux to automatically reconnect if the cable was disconnected.?

I have my Red Hat Enterprise 5 workstation set up to use Active Directory authentication.  I also have it configured to lock the screen after 30 minutes of inactivity.  The problem is - if someone disconnects my network cable even momentarily while the screen is locked, I can't authenticate and unlock the screen because the network interface is inactive (so it can't communicate with AD).  Is there a way to configure the system to automatically activate the network interface once the cable is reconnected?
Who is Participating?
esbfernConnect With a Mentor Author Commented:
The solution to this issue was to enable the NetworkManager service and to modify the startup so this service would run by default.  The service checks the connection to the network and attempts to activate the network interface if it is inactive.  It is only needed when you're running DHCP.  

To start the service: sudo service NetworkManager start
To make it persistent (survive reboots): sudo chkconfig NetworkManager on

This doesn't mean that the suggestions offered earlier aren't valid, but this is the method suggested by Red Hat.  My thanks to all of you.

Bob Reed
Are you talking about reconnecting to the network or re-authenticating with AD?

If you are using a static IP it will reconnect instantly  when the cable is plugged back in.

I am not sure about how AD handles lost connections.
esbfernAuthor Commented:
I am talking about reconnecting to the network.  I am set up to use DHCP and if I disconnect the cable then reconnect it, I have to manually activate the connection again.  I am wondering if there is a way to have the OS auto reconnect to the network.  The AD part is only related in the sense that I can't log back in and manually activate the network interface because my AD credentials can't be authenticated since AD is unreachable.   I hope this explanation is clear.
you might want to taking a look @ dhclient.conf

here is some information on users having issues switching between connections -

You may want to try running a script to check network connectivity every minute:

if ! `ping -c5 >/dev/null 2>&1` ; then
/etc/rc.d/init.d/network restart
exit 0

This would perform 5 ping test and if it fails, it will restart the network.

You can save it in /usr/bin/pingtest then chmod 775 /usr/bin/pingtest to make it executable

Using crontab -e, input:

* * * * *  /usr/bin/pingtest

Verify that the script is working, once verified, stay logged in first then unplug your network cable then plug it again...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.