Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.networking > #1220

Re: How to know if eth0 is up?

From Bit Twister <BitTwister@mouse-potato.com>
Newsgroups comp.os.linux.networking
Subject Re: How to know if eth0 is up?
Date 2012-03-30 19:57 +0000
Organization A noiseless patient Spider
Message-ID <slrnjnc41d.6pk.BitTwister@wb.home.test> (permalink)
References <4f75f0eb$0$19106$426a34cc@news.free.fr>

Show all headers | View raw


On 30 Mar 2012 17:44:11 GMT, <fab@slick.airforce-one.org> wrote:
> Hello.

Hi. You know if you were to read 
   http://www.catb.org/~esr/faqs/smart-questions.html
it suggest giving meaningful information pertinent to your setup.

At a minimum I would suggest which linux distribution, release, and
Ethernet card. That kind of information might get you some exact answers.

NIC may dictate which tool (ethtool, or mii-tool).

Distribution might get you what net function can be used to make you code
much more maintainable as time goes by.


> I'd like to know if there is a command line instruction or a /proc/
> entry that tells reliably if a cable is hooked in an ethernet port
> (typically, to know at boot if I must use my dhcp client on eth0, or
> look for a WIFI cell).
>
> I have found /proc/net/dev but it shows eth0 even though no cable is
> plugged in.

On my distribution, carrier status is found over in /sys/class/net and
the network-functions script has a check_link_down function to do
all the dirty work.

Based on the lack of any detailed information, I can only suggest
trying something like parsing the output from something like

LC_ALL=C ip link show dev eth0

Back to comp.os.linux.networking | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to know if eth0 is up? <fab@slick.airforce-one.org> - 2012-03-30 17:44 +0000
  Re: How to know if eth0 is up? Chris Davies <chris-usenet@roaima.co.uk> - 2012-03-30 19:33 +0100
  Re: How to know if eth0 is up? Bit Twister <BitTwister@mouse-potato.com> - 2012-03-30 19:57 +0000
    Re: How to know if eth0 is up? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-03-31 21:22 +0000
  Re: How to know if eth0 is up? J G Miller <miller@yoyo.ORG> - 2012-03-30 21:12 +0000
  Re: How to know if eth0 is up? Mark Evans <mpe@anacon.freeserve.co.uk> - 2012-04-05 19:07 +0100

csiph-web