LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   udev ignores network rules on Fedora 11 (https://www.linuxquestions.org/questions/linux-networking-3/udev-ignores-network-rules-on-fedora-11-a-768859/)

barth84 11-13-2009 03:36 AM

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

aus9 11-13-2009 09:25 AM

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

nimnull22 11-13-2009 09:36 AM

Quote:

Originally Posted by barth84 (Post 3755274)
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.

barth84 11-13-2009 10:36 AM

Quote:

Originally Posted by aus9 (Post 3755684)
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 :)

nimnull22 11-13-2009 11:12 AM

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 (Post 3755780)
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.

barth84 11-16-2009 02:10 AM

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


All times are GMT -5. The time now is 07:19 AM.