How to check network status on the Linux machine

Discussion in 'Linux Networking' started by Andrew, Dec 4, 2004.

  1. Andrew

    Andrew Guest


    Recently, I wrote a program on a Linux machine which is able to
    detect whether the machine is connected to the network. I used the
    Linux netstat program with the –i option to do the trick. netstat has
    a running flag (shown as a R when exercute netstat –i command), which
    will be turned on if the network cable is plugged into the machine and
    vice versa. However, it turns out that on some motherboards (I am
    using on broad network cards) the netstat will fail to detect the
    connection status. That is, no matter the network cable is plugged in
    or not, the running flag (R) is always on.

    The Linux system that works:
    ASUS P4PEX motherboard and unpatched Redhat 9.0 OS

    The Linux system that doesn't work:
    Gigabyte GA8IPE-1000G motherboard and updatched Redhat 9.0 OS

    The bad news for me is that I have to make the program work on the
    second Linux system (with Gigabyte motherboard) :'( Does
    anyone have any clue where the problem lies? I have been stuck on this
    problem for some time now. Can anybody please help? Thank you for your
    time :)
    Andrew, Dec 4, 2004
    1. Advertisements

  2. And mii-tool what does return on such machine?
    Davide Bianchi, Dec 4, 2004
    1. Advertisements

  3. Andrew

    Bit Twister Guest

    ping -c 1 -w 2 gateway_ip_addy_here > /dev/null
    if [ $? -ne 0 ] ; then
    echo network is not up
    Bit Twister, Dec 4, 2004
  4. Andrew

    Damjan Guest

    Recently, I wrote a program on a Linux machine which is able to
    mii-tool and ethtool will tell you if the ethernet cable is pluged, but only
    if your network card (and driver) support it.

    You can also use programs like netplugd to do things on plug/unplug events.
    Damjan, Dec 6, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.