I need to change my MACADDR and in the past one would just add MACADDR=NewMac to the ifcfg-eth0 file. In ClearOS7.6, that file name has changed a bit.
I did change my MAC using MACADDR in this file, it did in fact change the MAC when I did an an interface Down and Up command and it was there when I did an ifconfig to check it. But when I look at my ifcfg-enp2s0, "MACADDR=" is not there and it, the MACADDR change did not 'stick' after a reboot.
How do we make this stick for multiple reboots? Where did my setting go?
John
I did change my MAC using MACADDR in this file, it did in fact change the MAC when I did an an interface Down and Up command and it was there when I did an ifconfig to check it. But when I look at my ifcfg-enp2s0, "MACADDR=" is not there and it, the MACADDR change did not 'stick' after a reboot.
How do we make this stick for multiple reboots? Where did my setting go?
John
Share this post:
Accepted Answer
Unfortunately, ClearOS regularly overwrites the file and you will lose your changes, which you have found out There is an outstanding feature request for this but I don't know when it will be implemented. In the meanwhile, you can block the file from being overwritten by setting the immutable bit on it with the command:
chattr +i {filename}
If you ever need to make changes, you must remember to unset the immutable bit with a:chattr -i {filename}
Responses (12)
-
Accepted Answer
-
Accepted Answer
Thanks again Nick!
If I heard nothing on this issue, I was going to try to just make the file read-only for all... Not certain if that is what is called the immutable bit, but doing so would server the same purpose I suppose.
Still have a few things to go in ClearOS! Weird change and it should only be rewritten, IMHO, when you set/change the parameters/settings of the NIC/Interface.
Thanks!
John -
Accepted Answer
WOW! and BUMMER!
Locking eth0 down really disables quite a few modules with "oops. Invalid interface!" Including DMZ and 1 to 1 NAT, AND IP Settings, (obviously), and more! A lot of cable companies may not be relying on MACs behind their modems that much anymore, but I know, or believe, my ISP DHCP assigned static address is linked to my router/gateway's MAC.
I am really disappointed, (not that one user being disappointed will really matter), having used Clear since way back when good ol' ClarkConnect. I am a bit chicken to remove my MAC setting and see what happens.... but probably will.
I truly hope that one can someday easily configure a MAC address and have things work. Clear... PLEASE?!
On the bright side, absolutely no issues in moving a couple ClearOS 6.9 boxes to 7.6.
John -
Accepted Answer
If you want a real kludge, edit /usr/clearos/apps/network/libraries/Iface.php and in the save_dhcp_config function at around line 1737 add:
Obviously replace enp0s10 with the device you want to fix and the MACADDR with your desired MACADDR.if ($this->iface == 'enp0s10')
$info['MACADDR'] = '11:22:33:44:55:66';
Although this works you are at risk of an update to app-network. I know there is one coming but it is waiting a code merge and testing and after that I'll be updating it again for PPPoE. In yum.conf you could try blocking updates to app-network* if this is critical or you'd need to monitor for changes.
It may be easier to ask your ISP. -
Accepted Answer
There may be another way round this which is safe and repeatable and won't ever get stomped on. I bumped into this post and it gave me an idea. The commands:
Need to be run when networking is down. You only need one of them, so let's use the ifconfig one.ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
macchanger-ng --mac xx:xx:xx:xx:xx:xx eth0
ip link set eth0 address xx:xx:xx:xx:xx:xx
If you don't have one, create a file /usr/sbin/ifup-pre-local and make it executable. In it put:
Obviously change eth0 and the MAC address to suit.if [ "$1" == 'eth0' ]; then
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
fi
Once you have created the file, to test do:ifdown eth0 && ifup eth0
The /usr/sbin/ifup script is already set to call /usr/sbin/ifup-pre-local, if it exists, before it does the business of bring up the interface -
Accepted Answer
-
Accepted Answer
Nick,
One problem solved now one other regarding MAC address. The ClearOS box I am building for my brother is for a satellite ISP and he has paid for a persistent IP, Not quite static but as long as his MAC on his router does not change, his IP will not change. Change the MAC and he gets a new IP address.
____________________________________________
EDIT: What finally worked was making the ifup-pre-local having only
ifconfig enp1s0 hw ether 0c:xx:63:xx:e1:xx:e3
No variable checking. After a reboot, the MAC is just fine!
____________________________________________
I have done the following:
Created (owner root) and made executable for all users (0755) /usr/sbin/ifup-pre-local. In that I have:
if [ "$1" == 'enp1s0' ]; then
ifconfig enp1s0 hw ether 0c:xx:63:xx:51:xx (X's are just my attempt at privacy)
fi
I have done the enp1s0 down and up and a reboot. No MAC address change.
I ran at the CLI, (putty):
ifconfig enp1s0 hw ether 0c:80:xx:e1:xx:e3
and the MAC address stuck.
I also did a MACADDR= in the ifconfig-enp1s0 and that worked. But it needs to stick and last time it did the immutable bit quite a few modules stated there was an issue.
Thanks again so very much!!
John
PS. Not wanting to make another post, but it took a long time to login and upload an edit today. Just an FYI. -
Accepted Answer
Does the command need "sudo"? You can also change the address with the "ip" command and, perhaps, ethtool. Ethtool also supports permanent changes. References - https://blog.kanbach.org/post/how-to-permanently-change-a-mac-address-using-ethtool/ and https://programming.vip/docs/modifying-mac-address-of-network-card-under-linux.html.
Otherwise I don't know.
It would be easier if you brother could take a one-off hit and change his IP address. -
Accepted Answer
Hi Nick!
We may have cross posted as I did an update/edit of my last post.
I have it working well, it seems, by simply modifying the /usr/sbin/ifup-pre-local and and entering only:
ifconfig enp1s0 hw ether 0c:xx:63:xx:e1:xx:e3
No variable checking and after a reboot(s), the MAC I want is there and just fine!
John -
Accepted Answer
Interesting. It looks like the $1 check is not working. Odd. I t works in /usr/sbin/ifup-local. I may have to check some more.
..... it looks like $1 is ifcfg-eth0 (or whatever your interface is) which makes it harder to check for the interface. You should be able to do::
From https://tldp.org/LDP/abs/html/string-manipulation.html, ${1#ifcfg-} returns $1 less the leading "ifcfg-". I have tested it and it seems to work.if [ "${1#ifcfg-}" == 'enp1s0' ]; then
ifconfig enp1s0 hw ether 0c:xx:63:xx:51:xx
fi -
Accepted Answer
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »