LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-19-2014, 12:49 PM   #1
l0rddarkf0rce
Member
 
Registered: Nov 2004
Location: Virginia, US
Distribution: Slackware 14.1 multilib
Posts: 149

Rep: Reputation: 33
Detecting ethernet connection


In /etc/rc.d/rc.inet1 is there a way to detect if there is a signal on the ethernet port before attempting to assign an IP either via dhcp or static IP?
 
Old 04-19-2014, 12:59 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
ifconfig|grep ether
 
Old 04-21-2014, 09:32 AM   #3
l0rddarkf0rce
Member
 
Registered: Nov 2004
Location: Virginia, US
Distribution: Slackware 14.1 multilib
Posts: 149

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by Didier Spaier View Post
ifconfig|grep ether
Not sure this will help... Getting the MAC address line doesn't really tell me if the cable is plugged or not.

I kept looking around and I thing that reading /sys/class/net/eth0/carrier and /sys/class/net/eth0/operstate might do the trick. All I want to do is change the rc.inet1 script so that it only tries to bring the interface up if the cable is plugged, otherwise what's the point.

I guess I can also use the old scripts that Alien Bob (http://www.slackware.com/~alien/rc_scripts/) wrote a long time ago. Does anyone know if those scripts still work with 14.1?
 
Old 04-21-2014, 10:32 AM   #4
FeyFre
Member
 
Registered: Jun 2010
Location: Ukraine, Vinnitsa
Distribution: Slackware
Posts: 351

Rep: Reputation: 30
"the old scripts that Alien Bob wrote a long time ago" are exactly network scripts present in Slackware now(exactly, well except one bugfix known to me happened on 134 line).
 
Old 04-21-2014, 12:45 PM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
'ethwireck' does a fast job of that -but if the info can be hand through /sys that should be better.
 
Old 04-21-2014, 02:43 PM   #6
ml4711
Member
 
Registered: Aug 2012
Location: Ryomgård, Danmark
Distribution: Slackware64
Posts: 146

Rep: Reputation: 103Reputation: 103
You can use ethtool or mii-tool:

Code:
ethtool  eth0
...
...
Link detected: yes / Link detected: no

mii-tool -v  eth0
eth0: negotiated 1000baseT-FD flow-control, link ok / eth0: no link
...
...
 
1 members found this post helpful.
Old 04-22-2014, 09:29 AM   #7
hpfeil
Member
 
Registered: Nov 2010
Location: Tucson, Arizona US
Distribution: Slackware Current
Posts: 354
Blog Entries: 1

Rep: Reputation: Disabled
Ifconfig is deprecated, AFAIK. Install iproute2. The you can check your links with `ip links show`. I have rc.inet1 commented out. In rc.local, I invoke rc.ip:
=-=-=-snip=-=-
#!/bin/sh
## Replace the deprecated ifconfig and route commands
#
## Start with tabula rasa (old gag from Kant)
echo back to parade rest...
# You don't need to reset loopback, it will just throw an "already exists" message.
ip addr flush dev lo
ip addr flush dev eth0
ip link set lo down
ip link set eth0 down

## Bring up the loopback device
echo bring up loopback device...
ip link set lo up
ip addr add 127.0.0.1/8 dev lo brd + scope host

## Bring up the link to the WAN
echo bring up link to the WAN with default gateway route
ip link set eth0 up
ip addr add 192.168.1.100/24 dev eth0 scope global
ip route add default via 192.168.1.1 dev eth0 metric 1 scope global [That's the default local address of the router.]

## Add default multicast route
ip route add 224.0.0.0/4 dev eth0 scope global

## Prohibit link local multicast addresses.
## Prohibit link local (alias, limited) broadcast.
ip route add unreachable 224.0.0.0/24
ip route add unreachable 255.255.255.255

echo out of rc.ip
=-=-=--snip=-==-=-
Then in rc.local, I invoke /etc/rc.d/rc.inet2 to launch bind, ssh, nis, nfs, and all.
Suffering from occasional bouts of congenital indolence, as I oftentimes do (born lazy), the iproute2 package does a lot more powerful stuff as well, ip-bridge, ip-tunnel, ip-maddress, etc.

PACKAGE LOCATION: n/iproute2-3.10.0-x86_64-2.txz
PACKAGE DESCRIPTION:
iproute2: iproute2 (IP routing utilities)
iproute2:
iproute2: These are tools used to administer many advanced IP routing features
iproute2: in the kernel. See Configure.help in the kernel documentation
iproute2: (search for iproute2) for more information on which kernel options
iproute2: these tools are used with.
iproute2:
iproute2: These utilities were written by Alexey Kuznetsov. The current
iproute2: maintainer of iproute2 is Stephen Hemminger.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Not detecting ethernet connection on Debian M4trixSh4d0w Linux - Newbie 22 04-18-2013 02:09 AM
linux box ethernet not detecting connection to router agatone Linux - Networking 5 12-25-2012 12:31 PM
Auto-detecting ethernet? ub3rj3phf Red Hat 1 11-03-2004 02:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration