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

Posted on 2008-11-05
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
    LVL 11

    Expert Comment

    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

    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

    you might want to taking a look @ dhclient.conf

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

    Expert Comment


    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

    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

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
    It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now