LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-13-2009, 03:36 AM   #1
barth84
LQ Newbie
 
Registered: Nov 2009
Posts: 3

Rep: Reputation: 0
udev ignores network rules on Fedora 11


Hi to all,
I am new to this forum and Linux sorry if I make some errors.

I want to read the data written in the /etc/udev/rules.d/70-persistent-net.rules file and use them in my script lunched after that rule.
So, I wrote this rule:
SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/usr/bin/myscript"
and I added it on /etc/udev/rules.d/99-myrule.rules
my script is never executed.

I tried to change the conditions of my rule and I set it in this way:
KERNEL=="eth*", RUN+="/usr/bin/myscript"
and also this time the script is never executed.

Then I tried this rule:
SUBSYSTEM=="net", RUN+="/usr/bin/myscript"
and the script is executed when the system shutdowns or reboots, and not at boot time.

Why the conditions are not true during the boot time?

Thank you very much
 
Old 11-13-2009, 09:25 AM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
hi

on my system it has this warning inside file....# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

2) there are 2 ways around this both not using that file

a) put your script into /etc/rcS with a number starting with S and higher than networking using root powers.

b) a lot easier...add the script to rc.local with root powers as rc.local is always the Last script to execute so you can't muck it up
 
Old 11-13-2009, 09:36 AM   #3
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Quote:
Originally Posted by barth84 View Post
Hi to all,

I want to read the data written in the /etc/udev/rules.d/70-persistent-net.rules file and use them in my script lunched after that rule
...
Thank you very much
Can you explain us, what is the purpose of use /etc/udev/rules.d/70-persistent-net.rules?

There are lots of other ways how to start your script.
 
Old 11-13-2009, 10:36 AM   #4
barth84
LQ Newbie
 
Registered: Nov 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by aus9 View Post
hi

on my system it has this warning inside file....# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

2) there are 2 ways around this both not using that file

a) put your script into /etc/rcS with a number starting with S and higher than networking using root powers.

b) a lot easier...add the script to rc.local with root powers as rc.local is always the Last script to execute so you can't muck it up
In my 70-persistent-net.rules file there is written that it has been generated by... but not the part of only change the NAME value.

I tried the b solution and it works fine, but I would use the udev system. I could use the a solution if it is not possible to use udev.

This is the motivation about what I can do that:
I have 3 PCs with the same Hardware, so I would umount the primary disk on a machine and put it on another one.
The problem is that the network does not working because the MAC address changes.
The easiest solution is to delete the HWADDR field in /etc/sysconfig/network-script/ifcfg-eth* and then it works, but evry time the eth* increases.
So my idea is to create 2 udev rules:
1) 69-remove-persistent-net.rules: it deletes the 70-persistent-net.rules
2) 99-config-eth.rules: it reads the 70-persistent-net.rules and then modifies the /etc/sysconfig/network-script/ifcfg-eth* with the correct MAC address

I prefer to use udev, it it works

Last edited by barth84; 11-13-2009 at 10:41 AM.
 
Old 11-13-2009, 11:12 AM   #5
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Strange network, how can't it works if MAC changes. MAC filtering? Avoid to use that kind of networks.

Second

Quote:
Originally Posted by barth84 View Post
This is the motivation about what I can do that:
I have 3 PCs with the same Hardware, so I would umount the primary disk on a machine and put it on another one.
The problem is that the network does not working because the MAC address changes.
You want to change computer in the network? But you can change NIC as well.

There is file "local.boot" or thesame in /etc/init.d where you can place any script, it executed at boot time before first run level.
 
Old 11-16-2009, 02:10 AM   #6
barth84
LQ Newbie
 
Registered: Nov 2009
Posts: 3

Original Poster
Rep: Reputation: 0
The 3 PCs are in three different places, they are not in the same network.
The network does not work if there is enabled the persistent naming rule and if the ifcfg-eth* file contains the MAC Address.
If I delete them it works fine.
So my idea is to delete the 70-persistent-net.rules on the shutdown and update the ifcfg-eth* file on boot up after that udev generates the new 70-persistent-net.rules
 
  


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
Why UDEV ignores multiple rules for the same device? arctgx Linux - Hardware 5 01-16-2013 05:47 AM
cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or directory rcg1984 Linux From Scratch 2 09-17-2008 07:02 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 03:43 AM
iptables ignores rules bCookie Linux - Networking 1 01-27-2005 02:49 AM
Shorewall ignores the rules? N3K0KUN Linux - Security 3 09-06-2004 02:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:21 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