Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-19-2014, 01:49 PM
|
#1
|
Member
Registered: Nov 2004
Location: Virginia, US
Distribution: Slackware 14.1 multilib
Posts: 149
Rep:
|
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?
|
|
|
04-19-2014, 01:59 PM
|
#2
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,288
Rep:
|
ifconfig|grep ether
|
|
|
04-21-2014, 10:32 AM
|
#3
|
Member
Registered: Nov 2004
Location: Virginia, US
Distribution: Slackware 14.1 multilib
Posts: 149
Original Poster
Rep:
|
Quote:
Originally Posted by Didier Spaier
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?
|
|
|
04-21-2014, 11:32 AM
|
#4
|
Member
Registered: Jun 2010
Location: Ukraine, Vinnitsa
Distribution: Slackware
Posts: 351
Rep:
|
"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).
|
|
|
04-21-2014, 01:45 PM
|
#5
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
'ethwireck' does a fast job of that -but if the info can be hand through /sys that should be better.
|
|
|
04-21-2014, 03:43 PM
|
#6
|
Member
Registered: Aug 2012
Location: Ryomgård, Danmark
Distribution: Slackware64
Posts: 146
Rep:
|
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.
|
04-22-2014, 10:29 AM
|
#7
|
Member
Registered: Nov 2010
Location: Tucson, Arizona US
Distribution: Slackware Current
Posts: 376
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 05:40 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|