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

Posted on 2008-11-05
Medium Priority
Last Modified: 2013-12-15
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?
Question by:esbfern
  • 2
  • 2
LVL 11

Expert Comment

ID: 22886816
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.

Author Comment

ID: 22886975
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.
LVL 11

Expert Comment

ID: 22887155
you might want to taking a look @ dhclient.conf

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


Expert Comment

ID: 23011935

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...

Accepted Solution

esbfern earned 0 total points
ID: 23042197
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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question