This is a discussion on How to tell an eth port has link? within the Linux Networking forums, part of the Linux Forums category; There has to be a way to tell if the ethernet port has a cable plugged in. I see the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
CptDondo <yan@nsoesipnaemr.com> 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/ |
|
|||
|
Mark Hobley wrote:
> CptDondo <yan@nsoesipnaemr.com> 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 |
|
|||
|
CptDondo <yan@nsoesipnaemr.com> 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/ |
|
|||
|
Mark Hobley wrote:
> CptDondo <yan@nsoesipnaemr.com> 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 |