View previous topic :: View next topic |
Author |
Message |
Barvinok n00b
Joined: 29 Sep 2013 Posts: 34 Location: Ukraine
|
Posted: Sun Sep 29, 2013 8:12 pm Post subject: Forcing MAC on boot |
|
|
Hi.
My laptop firmware has a bug -- default MAC of the NIC is FF:FF:FF:FF:FF:FF.
Quote: | Dolphin ~ # dmesg | grep -i eth
[ 1.595332] jme: JMicron JMC2XX ethernet driver version 1.0.8
[ 1.598134] netif_napi_add() called with weight 128 on device eth%d
[ 1.601635] jme 0000:03:00.5 eth0: JMC250 Gigabit Ethernet chiprev:23 pcirev:3 macaddr:ff:ff:ff:ff:ff:ff
|
Consequently, the interface is not getting up, not getting IP address assigned by the DHCP and so on.
A year ago, when net.lo and net.eth0 were still there and in effect, I solved this problem by adding mac_eth0="..correct mac here...", and everything worked well.
Then (a week ago) I had to replace hard drive on this laptop and reinstall Gentoo on it.
Before that I did the Gentoo install to two other laptops. Somehow they don't seem to have net.lo and all the stuff I got used to, they have empty /etc/conf.d/net but still their network interfaces were automagically up and running well.
But not this beast
I wrote mac_eth0 entry to /etc/conf.d/net as before but it didn't work -- the interface got invalid mac on reboot. I noticed the interface got renamed to enp3s0f5 and wrote mac_enp3s0f5 to the /etc/conf.d/net but to no avail. I even tried net.ifaces=0 for kernel to avoid renaming, thinking udev may be intervening. But no. I feel like /etc/conf.d/net isn't respected anymore
here's what ifconfig -a says
Quote: | enp3s0f5: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether ff:ff:ff:ff:ff:ff txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 48:5d:60:88:8b:ab txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 |
What is the proper MODERN way to force a MAC on a NIC ? By modern I mean having all that netifrc-whatever stuff taken into account.
Thanks in advance. _________________ Unlike reality, stupidity is inescapable
Last edited by Barvinok on Mon Sep 30, 2013 1:32 pm; edited 1 time in total |
|
Back to top |
|
|
chiefbag Guru
Joined: 01 Oct 2010 Posts: 542 Location: The Kingdom
|
Posted: Mon Sep 30, 2013 1:22 pm Post subject: |
|
|
To switch to the old naming convention do the following, it will probably make things easier to understand.
Code: | touch /etc/udev/rules.d/80-net-name-slot.rules |
|
|
Back to top |
|
|
Barvinok n00b
Joined: 29 Sep 2013 Posts: 34 Location: Ukraine
|
Posted: Mon Sep 30, 2013 1:30 pm Post subject: |
|
|
chiefbag wrote: | To switch to the old naming convention do the following, it will probably make things easier to understand.
Code: | touch /etc/udev/rules.d/80-net-name-slot.rules |
|
I'm sorry, I don't see how this can change MAC address from incorrect to the correct one
In general I don't care how my interfaces are named. I just need a working way to set a MAC. _________________ Unlike reality, stupidity is inescapable |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Mon Sep 30, 2013 1:52 pm Post subject: |
|
|
See the examples in "/usr/share/doc/openrc-0.11.8/net.example.bz2", specifically, "mac_eth0" and friends. These go in your /etc/conf.d/net file.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Barvinok n00b
Joined: 29 Sep 2013 Posts: 34 Location: Ukraine
|
Posted: Mon Sep 30, 2013 4:53 pm Post subject: |
|
|
John R. Graham wrote: | See the examples in "/usr/share/doc/openrc-0.11.8/net.example.bz2", specifically, "mac_eth0" and friends. These go in your /etc/conf.d/net file. |
As I said in my first post
Barvinok wrote: | I wrote mac_eth0 entry to /etc/conf.d/net as before but it didn't work -- the interface got invalid mac on reboot. I noticed the interface got renamed to enp3s0f5 and wrote mac_enp3s0f5 to the /etc/conf.d/net but to no avail. |
Besides, I don't have /usr/share/doc/openrc-0.11.8/ despite both openrc and baselayout installed.
This is my /etc/conf.d/net
Code: | #
mac_enp3s0f5="00:1A:7F:B0:CD:34"
mac_eth0="00:1A:7F:B0:CD:34"
# |
What do I do now to make sure the /etc/conf.d/net settings are respected? _________________ Unlike reality, stupidity is inescapable |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Mon Sep 30, 2013 8:44 pm Post subject: |
|
|
Well, first of all, you should have /usr/share/doc/openrc-0.11.8/net.example.bz2. Observe: Code: | ~ # equery list -i openrc
* Searching for openrc ...
[IP-] [ ] sys-apps/openrc-0.11.8:0
~ # equery files openrc | grep 'net\.example'
/usr/share/doc/openrc-0.11.8/net.example.bz2 | Perhaps you should re-emerge (--oneshot) openrc.
Second, could you post your /etc/conf.d/net file, please, and also report the version of openrc you're using?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters.
Last edited by John R. Graham on Mon Sep 30, 2013 8:48 pm; edited 1 time in total |
|
Back to top |
|
|
Barvinok n00b
Joined: 29 Sep 2013 Posts: 34 Location: Ukraine
|
Posted: Mon Sep 30, 2013 8:45 pm Post subject: |
|
|
Problem solved.
The cause for /etc/conf.d/net not working was that I set "newnet" flag for openrc, thereby invalidating "oldnet" ways of setting custom MAC.
But newnet approach through setting in /etc/conf.d/network is also not suitable since I use DHCP, because I was told that /etc/conf.d/network is for static addresses.
Finally, I had to write custom dhcpcd hook that reset interface mac before dhcpcd takes over. Here it is
Code: | Dolphin ~ # cat /etc/dhcpcd.enter-hook
# Custom hook to fix wrong MAC on an interface
if [ "$reason" = PREINIT ]; then
if [ "$interface" = "enp3s0f5" ]; then
ifconfig $interface hw ether 00:1B:8C:7A:F0:28
ifconfig $interface up
fi
fi
|
Also I made sure to not add /etc/init.d/network to rc-update and to add /etc/init.d/dhcp to it.
And everything finally worked as expected. _________________ Unlike reality, stupidity is inescapable |
|
Back to top |
|
|
Barvinok n00b
Joined: 29 Sep 2013 Posts: 34 Location: Ukraine
|
Posted: Mon Sep 30, 2013 8:59 pm Post subject: |
|
|
John R. Graham wrote: | Well, first of all, you should have /usr/share/doc/openrc-0.11.8/net.example.bz2. Observe: Code: | ~ # equery list -i openrc
* Searching for openrc ...
[IP-] [ ] sys-apps/openrc-0.11.8:0
~ # equery files openrc | grep 'net\.example'
/usr/share/doc/openrc-0.11.8/net.example.bz2 |
|
Code: | Dolphin ~ # equery list -i openrc
* Searching for openrc ...
[IP-] [ ] sys-apps/openrc-0.11.8:0
Dolphin ~ # equery files openrc | grep 'net\.example'
Dolphin ~ # |
I was told these files (examples and net.lo) were moved to net-misc/netifrc for migration to newnet.
John R. Graham wrote: | Perhaps you should re-emerge (--oneshot) openrc. |
That does not help. Still no examples.
Besides, I do not need examples, because I'm perfectly aware of the method to set custom mac in /etc/conf.d/net -- I've been using it many times before.
The original question was absolutely unrelated to your suggestion.
John R. Graham wrote: | Second, could you post your /etc/conf.d/net file, please, and also report the version of openrc you're using? |
0.11.8, and my /etc/conf.d/net was posted in the message above yours, exactly one line prior.
Forgive me for being rude, but, really, it helps a lot if you read question before answering.
Thanks anyway. _________________ Unlike reality, stupidity is inescapable |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Mon Sep 30, 2013 10:23 pm Post subject: |
|
|
Well your post didn't look like your entire /etc/conf.d/net file, which is what I meant to ask for; sorry if I wasn't clear. Also, just the plain net_interfacename="mac-address" Works for Me™, so I was assuming you had made a syntax error somewhere and would benefit from the examples.
Glad you got it working, but I continue to believe there's a simpler solution.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
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
|
|