How to check network status on the Linux machine

How to check network status on the Linux machine

Post by nightperso » Sun, 05 Dec 2004 15:13:43


Hi:

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 option to do the trick. netstat has
a running flag (shown as a R when exercute netstat 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 :)
 
 
 

How to check network status on the Linux machine

Post by Bit Twiste » Sun, 05 Dec 2004 15:57:32


ping -c 1 -w 2 gateway_ip_addy_here > /dev/null
if [ $? -ne 0 ] ; then
echo network is not up
fi

 
 
 

How to check network status on the Linux machine

Post by Damja » Wed, 08 Dec 2004 03:54:14

> 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
 
 
 

How to check network status on the Linux machine

Post by Bob Smit » Wed, 08 Dec 2004 18:00:35


Take a look at "mii-tool". You may need an updated
Ethernet driver for the hardware on the target
motherboard.

Hope this helps
Bob