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


Groups > comp.os.linux.networking > #1218 > unrolled thread

How to know if eth0 is up?

Started by<fab@slick.airforce-one.org>
First post2012-03-30 17:44 +0000
Last post2012-04-05 19:07 +0100
Articles 6 — 6 participants

Back to article view | Back to comp.os.linux.networking


Contents

  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

#1218 — How to know if eth0 is up?

From<fab@slick.airforce-one.org>
Date2012-03-30 17:44 +0000
SubjectHow to know if eth0 is up?
Message-ID<4f75f0eb$0$19106$426a34cc@news.free.fr>
Hello.

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.

Thanks.

-- 
F. Delente

[toc] | [next] | [standalone]


#1219

FromChris Davies <chris-usenet@roaima.co.uk>
Date2012-03-30 19:33 +0100
Message-ID<6sah49xkda.ln2@news.roaima.co.uk>
In reply to#1218
fab@slick.airforce-one.org wrote:
> 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

Either mii-tool or ethtool.
Chris

[toc] | [prev] | [next] | [standalone]


#1220

FromBit Twister <BitTwister@mouse-potato.com>
Date2012-03-30 19:57 +0000
Message-ID<slrnjnc41d.6pk.BitTwister@wb.home.test>
In reply to#1218
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

[toc] | [prev] | [next] | [standalone]


#1224

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2012-03-31 21:22 +0000
Message-ID<slrnjnetc5.1ls.grahn+nntp@frailea.sa.invalid>
In reply to#1220
On Fri, 2012-03-30, Bit Twister wrote:
> 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.
...

A general answer is more enlightening for the rest of us, though.

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

... like this one. I know kernel interfaces change now and then, but
I'd like to see one modern distribution which didn't enable that one.
(Thanks, by the way!)

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#1221

FromJ G Miller <miller@yoyo.ORG>
Date2012-03-30 21:12 +0000
Message-ID<jl57jn$7md$3@dont-email.me>
In reply to#1218
On Friday, March 30th, 2012, at 17:44:11 +0000, FAB wrote:

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

Which is quite a different thing to your "subject" which could be
answered perhaps with

     ifconfig eth0 | egrep 'UP' | egrep 'RUNNING'

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

As others have suggested perhaps

     ethtool eth0 | egrep "Link detected"

          Link detected: yes

-- 

  The Paul Ryan Budget -- Robs from the poor and gives to the rich.

[toc] | [prev] | [next] | [standalone]


#1232

FromMark Evans <mpe@anacon.freeserve.co.uk>
Date2012-04-05 19:07 +0100
Message-ID<jj3159-brb.ln1@server.anacon.no-ip.org>
In reply to#1218
fab@slick.airforce-one.org wrote:
> 
> 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).

Have you looked at ifplugd?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.linux.networking


csiph-web