View previous topic :: View next topic |
Author |
Message |
Jarjar Apprentice
Joined: 21 Jul 2002 Posts: 265 Location: Sweden
|
Posted: Sat Jan 02, 2010 9:15 pm Post subject: /etc/conf.d/net: Changing interface name *and* MAC - paradox |
|
|
Is this possible? I want to change the MAC of one of my NICs, to, say 11:22:33:44:55:66, and at the same time rename the interface from eth*, which of course is done based on the MAC address. Chicken and the egg.
Is this possible?
In which order are mac_ethX=665544332211 and rename_112233445566=newname "executed"?
I currently have this:
Quote: |
rename_001D7DC7D923="lan"
rename_00105A01EB3C="net"
config_net=( "dhcp" )
config_lan=( "192.168.1.1/24" )
|
... and would like to change the MAC of the net interface, and have it persistent across reboots. (Without actually rebooting now, though.)
Any advice? _________________ [Server etc. | C2D 2.2 @ 3.0 GHz / 4 GB RAM / 3x1 TB + 1x2 TB SATA disks + 1.5 TB ext. | Gentoo]
[Laptop | Macbook Pro 15" / Core i7 (Sandy) Quad 2.2 GHz / 16 GB RAM / Samsung 840 250 GB SSD + 1 TB + 2 TB HDD / 6750M 1 GB / OS X, Win 7] |
|
Back to top |
|
|
Mad Merlin Veteran
Joined: 09 May 2005 Posts: 1155
|
Posted: Sat Jan 02, 2010 9:40 pm Post subject: |
|
|
You should be able to rename your NIC with udev (based on the MAC at boot time), see /etc/udev/rules.d/70-persistent-net.rules. Your network scripts would run after, and then you can change the MAC address. _________________ Game! - Where the stick is mightier than the sword! |
|
Back to top |
|
|
Inodoro_Pereyra Advocate
Joined: 03 Nov 2006 Posts: 2631 Location: En la otra punta del cable
|
Posted: Sat Jan 02, 2010 10:11 pm Post subject: |
|
|
/etc/conf.d/net.example wrote: | # MAC changer
# To set a specific MAC address
#mac_eth0="00:11:22:33:44:55" |
Add that to your /etc/conf.d/net file, remove or rename the file/content of /etc/conf.d/rules.d/70-persistent-net-rules and have udev restart the network subsystem:
Code: | udevadm --trigger net |
Again, rename the network interface in 70-persistent-net-rules to net.whatever and create a proper symlink: /etc/init.d/net.wathever -> /etc/init.d/net.lo.
Stop net.eth0, start net.whatever.
Theoretically, that will change your net.X to net.Y without rebooting (never tryed myself).
Also:
Code: | ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF |
Changes the mac address in real time in case you didn't know that.
Cheers! _________________ Mi Blog.
Si no fuera por C, estaríamos escribiendo programas en BASI, PASAL y OBOL. |
|
Back to top |
|
|
Jarjar Apprentice
Joined: 21 Jul 2002 Posts: 265 Location: Sweden
|
Posted: Sun Jan 03, 2010 8:58 am Post subject: |
|
|
Thanks guys, it works great! Well, not so great as I'd hoped, as my end goal didn't work out... Everything I asked for here did, though.
/etc/udev/rules.d/70-persistent-net.rules
Code: |
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:5a:aa:bb:cc", ATTR{type}=="1", KERNEL=="?*", NAME="net"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1d:7d:xx:yy:zz", ATTR{type}=="1", KERNEL=="?*", NAME="lan"
|
Then run
Code: |
$ udevadm trigger net # no --trigger
|
That should take care of device naming. Next up, MAC changing, as easy as in my initial post (see net.example for details).
/etc/conf.d/net
Code: |
mac_net="00:10:5a:cc:dd:ee"
|
_________________ [Server etc. | C2D 2.2 @ 3.0 GHz / 4 GB RAM / 3x1 TB + 1x2 TB SATA disks + 1.5 TB ext. | Gentoo]
[Laptop | Macbook Pro 15" / Core i7 (Sandy) Quad 2.2 GHz / 16 GB RAM / Samsung 840 250 GB SSD + 1 TB + 2 TB HDD / 6750M 1 GB / OS X, Win 7] |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|