Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to tell an eth port has link?

Reply
Thread Tools Display Modes

How to tell an eth port has link?

 
 
CptDondo
Guest
Posts: n/a

 
      04-02-2007, 04:01 PM
There has to be a way to tell if the ethernet port has a cable plugged in.

I see the kernel message go by telling me it has lost or established the
link when I plug the cable in... But I can't find anything that would
tell me the status from userspace.

I've been all through /proc and I don't see anything that would clue me
in....

So... How to tell if an ethX port has a valid hardware link? I need to
test this before networking comes up so I know if I should run DHCP or
not...

--Yan
 
Reply With Quote
 
 
 
 
Ian Northeast
Guest
Posts: n/a

 
      04-02-2007, 04:09 PM
On Mon, 02 Apr 2007 09:01:02 -0700, CptDondo wrote:

> There has to be a way to tell if the ethernet port has a cable plugged in.


Use ethtool and/or mii-tool. Depending on what type of card it is, one or
the other should work.

Regards, Ian
 
Reply With Quote
 
Tauno Voipio
Guest
Posts: n/a

 
      04-02-2007, 05:27 PM
CptDondo wrote:
> There has to be a way to tell if the ethernet port has a cable plugged in.
>
> I see the kernel message go by telling me it has lost or established the
> link when I plug the cable in... But I can't find anything that would
> tell me the status from userspace.
>
> I've been all through /proc and I don't see anything that would clue me
> in....
>
> So... How to tell if an ethX port has a valid hardware link? I need to
> test this before networking comes up so I know if I should run DHCP or
> not...
>
> --Yan



Maybe you like to have ifplugd?

--

Tauno Voipio
tauno voipio (at) iki fi
 
Reply With Quote
 
Mark Hobley
Guest
Posts: n/a

 
      04-02-2007, 11:03 PM
CptDondo <(E-Mail Removed)> wrote:

> I see the kernel message go by telling me it has lost or established the
> link when I plug the cable in


Is there a hook for this that can call a script, or trigger an initd event
that can be used to call a script?

I am curious, because on my network, if I have a power failure, the network
hubs lose their connections, but the computers continue to run from a UPS
supply. The loss of the network hubs is a sure signal to all computers that
the power is out.

I was hoping to hook a shutdown script to the loss of ethernet connection
event, that shuts the computers down, if the outage lasts more than a couple
of minutes.

Regards,

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Telephone: (0121) 247 1596
International: 0044 121 247 1596

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/

 
Reply With Quote
 
CptDondo
Guest
Posts: n/a

 
      04-02-2007, 11:56 PM
Mark Hobley wrote:
> CptDondo <(E-Mail Removed)> wrote:
>
>> I see the kernel message go by telling me it has lost or established the
>> link when I plug the cable in

>
> Is there a hook for this that can call a script, or trigger an initd event
> that can be used to call a script?
>
> I am curious, because on my network, if I have a power failure, the network
> hubs lose their connections, but the computers continue to run from a UPS
> supply. The loss of the network hubs is a sure signal to all computers that
> the power is out.
>
> I was hoping to hook a shutdown script to the loss of ethernet connection
> event, that shuts the computers down, if the outage lasts more than a couple
> of minutes.
>


If I understand ifplugd correctly from reading the manpage, it should
detect the other end losing power, as the link will drop.

I have not gotten into ifplugd yet - I'm still hoping to get dhclient to
do what I want - but it looks promising. For my purposes it's a bit of
overkill...

--Yan
 
Reply With Quote
 
Mark Hobley
Guest
Posts: n/a

 
      04-03-2007, 02:03 AM
CptDondo <(E-Mail Removed)> wrote:
> I have not gotten into ifplugd yet - I'm still hoping to get dhclient to
> do what I want - but it looks promising. For my purposes it's a bit of
> overkill...


Yeah for mine too really, I don't want to configure the network, that is
already done here, and my IP addresses are static, so I don't use dhclient. All
I want to do is hook the cable dead event, possibly through initd, if it
supports the incident.

Regards,

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Telephone: (0121) 247 1596
International: 0044 121 247 1596

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/

 
Reply With Quote
 
CptDondo
Guest
Posts: n/a

 
      04-03-2007, 02:28 PM
Mark Hobley wrote:
> CptDondo <(E-Mail Removed)> wrote:
>> I have not gotten into ifplugd yet - I'm still hoping to get dhclient to
>> do what I want - but it looks promising. For my purposes it's a bit of
>> overkill...

>
> Yeah for mine too really, I don't want to configure the network, that is
> already done here, and my IP addresses are static, so I don't use dhclient. All
> I want to do is hook the cable dead event, possibly through initd, if it
> supports the incident.


I think what I am going to do is:

on boot, run mii-tools to see if the cable is hooked up
if it is, run dhclient {
if dhclient gets an address {
set up for networked database
exit }
}

assume no network
set up for local database

I think you could run mii-tools/ethtools from a loop every so often
(minute?) and see if the link is dead.

--Yan
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
D-Link DUB-H7 - 7-Port USB 2.0 Hub gootoo Linux Networking 0 10-03-2006 11:53 AM
D-Link DGS-1005D with bad port Ook Network Routers 1 04-28-2005 09:53 AM
closing port 80 on D-link 604+ Bob J Home Networking 6 09-08-2004 02:05 AM
Port forward through a VPN link Vincent Mooney-Chopin Windows Networking 3 08-08-2004 04:53 AM
opening a port on a D-Link 604 Morgoth Broadband 0 05-04-2004 07:21 PM



1 2 3 4 5 6 7 8 9 10 11