Forums

Resolved
0 votes
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
Monday, June 24 2019, 05:35 PM
Share this post:

Accepted Answer

Tuesday, June 25 2019, 08:03 AM - #Permalink
Resolved
0 votes
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}
The reply is currently minimized Show
Responses (12)
  • Accepted Answer

    Tuesday, September 15 2020, 08:30 AM - #Permalink
    Resolved
    1 votes
    If you do the check, it stops the command from firing when any interface comes up and just fires for the specific interface.
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 14 2020, 10:47 PM - #Permalink
    Resolved
    0 votes
    Thanks again Nick,

    If what I have works, is there a danger in keeping it, or is it simply best to do the check? Not sure why we need to check to interface unless it checks whether it is up or down.

    Thanks

    John
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 14 2020, 08:10 PM - #Permalink
    Resolved
    0 votes
    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::
    if [ "${1#ifcfg-}" == 'enp1s0' ]; then
    ifconfig enp1s0 hw ether 0c:xx:63:xx:51:xx
    fi
    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.
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 14 2020, 07:25 PM - #Permalink
    Resolved
    0 votes
    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
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 14 2020, 07:08 PM - #Permalink
    Resolved
    0 votes
    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.
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 14 2020, 06:17 PM - #Permalink
    Resolved
    0 votes
    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.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, June 28 2019, 04:52 AM - #Permalink
    Resolved
    0 votes
    Nick, YOU are the man!! I Love it! I will give it a try and after reading everything and looking at the code it seems as htough it will work well. I will let you know in a few days!

    John

    PS.. THANK-YOU SIR! And the feature request.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 26 2019, 09:01 PM - #Permalink
    Resolved
    0 votes
    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:
    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
    Need to be run when networking is down. You only need one of them, so let's use the ifconfig one.

    If you don't have one, create a file /usr/sbin/ifup-pre-local and make it executable. In it put:
    if [ "$1" == 'eth0' ]; then
    ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
    fi
    Obviously change eth0 and the MAC address to suit.

    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
    Like
    1
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 26 2019, 04:31 PM - #Permalink
    Resolved
    0 votes
    Forum request and now a feature request
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 26 2019, 07:31 AM - #Permalink
    Resolved
    0 votes
    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:
            if ($this->iface == 'enp0s10')
    $info['MACADDR'] = '11:22:33:44:55:66';
    Obviously replace enp0s10 with the device you want to fix and the MACADDR with your desired MACADDR.

    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.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 26 2019, 02:17 AM - #Permalink
    Resolved
    0 votes
    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
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, June 25 2019, 03:50 PM - #Permalink
    Resolved
    0 votes
    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
    The reply is currently minimized Show
Your Reply