Skip to contentSkip to conversation

Help with udev dev.d and net script

DISCUSSION Walt H 2 participants 3 messages Dec 30, 2004

lore
Share & tools
lore

Walt H

author
#0 lore raw

Hello,

I've been struggling to try to get a shell script executed when my system starts it network interfaces. I'm running kernel 2.6.10 with udev-050 and the 20040923 hotplug scripts on a Gentoo based system. I've got 2 Intel e100 network interfaces (using kernel modules), one of which connects to my DSL modem and gets its IP address dynamically via DHCP. My ISP can be very slow in giving an IP address (30-45 seconds), which causes a problem with my firewall script, which is automatically generated by fwbuilder. What I've been trying to do, is execute a script under /etc/dev.d/ for my eth1 interface, which sleeps until the interface gets an IP address, and then runs the firewall script. Unfortunately, the firewall script needs an IP address for the interface to operate correctly, and without one, no traffic in or out will pass through this box.

I've tried putting the script in /etc/dev.d/eth1/ /etc/dev.d/net/eth1 etc... but it never gets executed. I could brute force the issue by modifying a hotplug script or init script, but don't want to have to do this after each upgrade and the udev /etc/dev.d stuff seemed appropriate. What am I doing wrong?

My init scripts can be executed in parallel, which is what contributes to this problem I believe, as additional startup scripts may be executed before the interface is fully brought up. I could stop that I suppose, but I want to know why the dev.d stuff isn't working first I guess :) Thanks in advance,

-Walt

### /etc/dev.d/eth1/startfirewall.dev script follows:

#!/bin/bash
LOGFILE=/tmp/eth1-udev.log
echo date ": Starting fwbuilder firewall script...." >> $LOGFILE NETUP=0
while [ $NETUP -eq 0 ]; do
IP=/sbin/ip -4 addr show dev eth1 | tail -n1 &> /dev/null if ! test -z "$IP"; then
NETUP=1
echo date ": eth1 up with IP: $IP" >> $LOGFILE
else
echo date ": eth1 not up yet. Will retry in 10s..." >>
$LOGFILE
sleep 10
fi
done
echo date ": Activating firewall script now..." >> $LOGFILE /etc/fwbuilder/Holman\ Network.fw &> /dev/null

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 2 lines · Walt H

What I've been trying to do, is execute a script
under /etc/dev.d/ for my eth1 interface,

udev will not execute dev.d/ scripts for network interfaces if you don't use udev to rename the interface. You need to hook into the hotplug call not the udev notifier.

Kay

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#2 lore raw
In reply to Walt H
Quoted 8 lines · Kay Sievers
Quoted 4 lines · Walt H

What I've been trying to do, is execute a script
under /etc/dev.d/ for my eth1 interface,

Quoted 9 lines

udev will not execute dev.d/ scripts for network interfaces if you don't use udev to rename the interface. You need to hook into the hotplug call not the udev notifier.

Kay

Thanks for the quick reply Kay. I could've sworn I read at one point that I could do it with udev :) Oh well, I guess I'll look into the hotplug interface instead. Thanks,

-Walt

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel