Issues: Static IP + MAC address changing

  • Ok, so my goal here is to set a static IP address to my NAS running on a NanoPi M4 with OMV + Debian Stretch (latest updates installed), but I have encountered two issues:


    The cleanest way to achieve this (IMO) is to set the static IP via the router, which is perfectly possible except for the fact that my M4 changes its mac address every time it is rebooted. I searched in this forum and I found this old post from Jan 2018, but apparently the error was not reproducible so there is not much info there. Then, I searched in Armbian's forum and found 2 similar threads (one from February 2018 regarding a NanoPi Neo and one from May 2017 regarding and Opi Zero) and the suggested solution is to edit the /etc/interfaces file to hardcode the MAC address, but this thread of September-December 2018 says that editing the interfaces file is not a good idea as it may clash with whatever the Network Manager is doing.


    So, the not cleanest way (but still functional) is to set the static IP via the OMV web GUI. I encountered a loooot of issues about how changing the interfaces may break the web GUI's network section (which I think have been described a lot in this forum. See the May 2017 post mentioned above, for example), but still I managed to do it.


    The issue now is that I found that if I reboot my router (there are weeks I have to do it every day) while the M4 is on, when the router gets back and re-assigns IP addresses, apparently it ignores the static IP configuration and the N4 ends up with a completely different IP address, which is not the behavior I want.


    So, as I still prefer to set the static IP directly in the router via de MAC address, my main question is:


    How can I prevent the MAC address from changing on every reboot?


    If that is not possible (for whatever reason, which would be odd), then my question would be:


    How can I prevent the IP address from changing on every router reboot? Is it an issue with the router or with the N4?

    • Offizieller Beitrag

    The cleanest way to achieve this (IMO) is to set the static IP via the router, which is perfectly possible except for the fact that my M4 changes its mac address every time it is rebooted.

    That's very true, but someone like myself for instance my router does allow me to do that nor does have the ability for mac address filtering. So for me I have to do it the old fashioned way and use a static ip address outside of the DHCP scope (this prevents ip conflicts).
    As you are experiencing issues in allowing the router to do the work the old fashioned way might be the way to go.


    If I am right your system is using Network Manager, which again is the right way :) for whatever reason I bookmarked this which should help you resolve what you are experiencing.

  • If I am right your system is using Network Manager, which again is the right way :) for whatever reason I bookmarked this which should help you resolve what you are experiencing.

    Thanks! So I checked on my N4 and apparently the OMV web GUI configures the static IP the same way it is explained in your link, except that I found the /etc/network/interfaces file was edited directly instead of creating a new instance under /etc/network/interfaces.d/, so maybe the Network Manager is not being used (?).


    Anyway, my issue is that despite I can setup the static IP directly in the N4 successfully, the configuration doesn't survive router reboots as the N4 ends up with a different IP address given by the DHCP. That's really the issue I want to overcome (or to find a way to set the MAC address).

    • Offizieller Beitrag

    Anyway, my issue is that despite I can setup the static IP directly in the N4 successfully, the configuration doesn't survive router reboots as the N4 ends up with a different IP address given by the DHCP.

    If you set the static ip in the GUI that will add it directly to /etc/network/interfaces, if that does not survive a reboot then the N4 is using Network Manager so you would have to edit both files to set the static ip which the link explains.

  • Still not working. I've just set the interfaces file to:

    Code
    # The loopback network interface
    auto lo
    iface lo inet loopback
    iface lo inet6 loopback
    # eth0 network interface
    allow-hotplug eth0
    # Include additional interface stanzas.
    source-directory interfaces.d

    And created the new file with the static IP address:


    Code: /etc/network/interfaces/interfaces.d/eth0
    iface eth0 inet static
        address MY IP ADDRESS
        gateway MY GATEWAY
        netmask THE NETMASK
    iface eth0 inet6 auto
        privext 2
        pre-up echo 1 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
        pre-up echo 1 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
        pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/disable_ipv6

    Rebooted the N4 and got the static IP address that I set (which was already the result I had), but still the IP address is changing whenever the router reboots.

    • Offizieller Beitrag

    but still the IP address is changing whenever the router reboots.

    What's the router?


    My OMV uses a static IP, if I reboot OMV nothing changes, if I restart my router (which I very rarely do) it doesn't issue an IP address to OMV because the static IP is in the routers IP table.


    EDIT: If you used the solution from the Nano Pi Neo and added a Mac address to the /etc/network/interfaces, then create the static IP in the router with that MAC address that should resolve it? But you would have to remove the static IP from the GUI and/or at least from the two config files.

  • EDIT: If you used the solution from the Nano Pi Neo and added a Mac address to the /etc/network/interfaces, then create the static IP in the router with that MAC address that should resolve it? But you would have to remove the static IP from the GUI and/or at least from the two config files.

    So, I removed the static IP from both config files I had edited and from the web GUI and was preparing to set the MAC address with the NanoPi Neo's solution when I found in the OMV docs / Advanced Configuration sitehttps://openmediavault.readthe…html?highlight=interfacesthat editing the interfaces file directly is a bad idea as "The file /etc/network/interfaces will be (re-)generated by openmediavault on demand. Thus custom changes that are done by the user will get lost." and they suggest to add any custom configuration to an executable script located at "usr/share/openmediavault/mkconf/interfaces.d/", so I put the NanoPi Neo's code snippet into that script and followed the instructions on the doc, but it didn't work.
    Apparently, it was just being ignored and the MAC address was still randomly generated, but I found out that just by adding the configuration to the custom file in the /etc/network/interfaces.d/ folder does the trick, so that's how I have it now. The MAC address doesn't change anymore and I can set the static IP directly in my router's table.


    Thanks for your support!

  • I have no files inside .../interfaces.d/. Could you provide what this custom file should look like?

    It's supposed to have no files by default. As the link @geaves bookmarked says "During the networking daemon initiation the /etc/network/interfaces.d/ directory is searched for network interface configurations. Any found network configuration is included as part of the /etc/network/interfaces. " so you are supposed to place in there your custom configuration you want to apply. This is mine I use to define the MAC address:

    Code: /etc/network/interfaces.d/mac_eth0
    # Setup MAC address
    allow-hotplug eth0
    iface eth0 inet dhcp
      hwaddress ether MY_MAC_ADDRESS


    Just replace "MY_MAC_ADDRESS" with the address you want. Also the filename doesn't have to be "mac_eth0". You can name it as you want as long as it is inside /etc/network/interfaces.d/

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!