« Back to all recent discussions

NAS542, Link Aggregation and MAC address

BoyanskiBoyanski Posts: 23  Junior Member
edited August 7 in Questions
Hello,
I have a NAS542 and I've setup the Link Aggregation feature. I have also setup iSCI volume, which needs an IP address on the PC part of the setup.
I've setup the DHCP server on the router to give a specific IP to the NAS, but because the two LANs on the NAS have two MACs - numbers:B8 for the one and numbers:B9 for the other, I found out that when restarting the NAS, sometimes it shows to the router as ...B8 and other times as B9 and in one case the router assigns the IP I want, but in the other case it assigns a different/random IP. The router doesn't allow me to give one IP to two different MACs, so when the "wrong" LAN card shows first, I can't access the iSCSI.
Can this be resolved?

#NAS_Aug
Tagged:

Best Answers

  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    edited September 19 Accepted Answer
    Yes, it's enabled. WebDAV is the only service I enabled successfully through MyCloud:
    And HTTP didn't work. Are you sure port 80 is available? Can you manually forward it?

    Also after each restart the gateway is lost, so can I add the line in the script?
    In that case you are pretty close to using a fixed IP anyway, eh? Anyway, I can imagine that doesn't work.  The DHCP client is started, but it is possible that it returns before the IP is known. Don't know what happens then with the already set gateway. Better filter the -G away:
    cat >/sbin/dhcpcd <<__EOF__
    #!/bin/sh
    date >>/tmp/dhcpcd.log
    echo "\$0 \[email protected]" >>/tmp/dhcpcd.log
    ARGS="\$( echo "\[email protected]" | sed 's/-G//' )"
    # have a look:
    echo \$ARGS >>/tmp/dhcpcd.log
    ifconfig bond0 hw ether 00:11:22:33:44:55
    exec /sbin/dhcpcd.old \$ARGS
    __EOF__

  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    Accepted Answer
    Isn't that my case?
    Semi-fixed IP? Yes.
    Would there be a conflict?

    No. The DHCP server won't hand it over to any other device, as it's reserved for the NAS. The NAS will never ask for it, but just use it. That's fine.

    A downside of this approach can be that the nas is not accessible by hostname. Many routers will automatically add the hostnames of the DHCP clients to the DNS system. So in your case that entry might not be there. (Or maybe it does, if fixed IP assignments are also added).



«13

Answers

  • WiasoudaWiasouda Posts: 41  Junior Member
    Hi,
    Did you configure your link aggregation as port trunk in NAS itself?
    If no, then you can refer the user manual on charpter 8.4.2, ftp://ftp2.zyxel.com/NAS326/user_guide/NAS326_V5.21 ed2.pdf 
    And after configured, you will see the below screen:


    After bind, it would have only 1 MAC address, and you don't need to configure link aggregation on router or switch.

  • BoyanskiBoyanski Posts: 23  Junior Member
    edited August 8
    Hi,
    That's exactly how I've configured it. But after restart, sometimes it sends LAN1 MAC, sometimes LAN2.



    But I've also configured the router's Link Aggregation:


    If I disable the router's Link Aggregation would it work properly?
  • WiasoudaWiasouda Posts: 41  Junior Member
    NAS has bind its 2 ethernet ports as used one MAC address, so I think you may be able to disable link aggregation on your router, and you can try it.

  • BoyanskiBoyanski Posts: 23  Junior Member
    edited August 10
    OK, I tried that, disabled router's LA, restarted NAS and it changed the MAC.  :open_mouth:

    Each restart switches the MAC!
  • BoyanskiBoyanski Posts: 23  Junior Member
    Anyone?
  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    The most straight forward solution is using a fixed IP.

    If that is no option, how are your command line skills? You problem is a very common problem. A quick google proves that. Unfortunately the solutions on internet (like this one) don't fit your box.

    Yet it is possible to change the mac address manually.

    Using some black magic it is possible to inject code at boot time. So you can rename /sbin/dhcpcd to /sbin/dhcpcd.old, and put a script in place which does:
    #!/bin/sh
    ifconfig bond0 hw ether 00:11:22:33:44:55
    exec /sbin/dhcpcd.old "[email protected]"
    Unfortunately this has to be done @each boot, because /sbin/ is on a ramdrive. Fortunately the black magic covers that.



  • BoyanskiBoyanski Posts: 23  Junior Member
    Thank you very much for your answer. This appears to be a little advanced for me, so I'll do some reading first, then I'll try it. I may still need some help.
  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    I may still need some help.

    I'm here.

  • BoyanskiBoyanski Posts: 23  Junior Member
    Hello again. A little late here, but I'd like to do what you suggested. I didn't know how to do the command line, so I read a little and I can do it now through Putty. So I can see now the directories with 'ls' command, I can go super user to rename the dhcpcd file.
    What I don't understand is: 
    After renaming it, you said to put a script there. What is this, a text file with the same name and with your code inside?
  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    What I don't understand is: 

    After renaming it, you said to put a script there. What is this, a text file with the same name and with your code inside?

    Yes, basically. In Linux (and Unix) a file is executable when it has the executable flag set. When an executable file is a textfile, Linux reads the first line to see (after the #!) which script interpreter to use. In this case /bin/sh, which happens to be the same binary which supports the shell you are working in, and for that reason it's called a shell-script, and it can execute the same commands you can type in the shell.

    So you can put that code in a file, set the executable flag (chmod a+x filename), and it should run fine.

    The most occurring error on this is when the file doesn't have Linux line endings. A file created with Notepad won't work, because it has Windows line endings. In Windows for instance PsPad can create linux line endings. (Somewhere in the menu you have choice between Windows, Linux/Unix and Mac)


  • BoyanskiBoyanski Posts: 23  Junior Member
    Maybe I'm missing something else too. Here is what I tried:

    As super user 
    mv /sbin/dhcpcd /sbin/dhcpcd.old
    cd /sbin
    cat > dhcpcd
    Then I entered the code you gave me with the desired MAC in the console
    Ctrl + Z to save and exit
    chmod a+x dhcpcd
    I restarted the NAS and it changed the MAC again. As I checked the /sbin directory - dhcpcd.old was gone and dhcpcd file exist, but it's not the one I created, I guess the original what it should be.

    You said it's on a ram drive. Is it the "black magic" that I didn't understand?
  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    edited September 12
    Apparently. As many embedded linux devices, this box has it's root filesystem embedded in the kernel, which is extracted to a ramdrive on boot. A big advantage of this is that in the early boot stage Linux doesn't need access to any storage system, as all needed binaries and scripts are already available. Consequence is that any change made to the rootfs will be reset on reboot. That can be a disadvantage, but also an advantage, as it's harder to brick the device.

    The black magic is that it's possible to have a script on an USB stick, which is called rather early in the boot process. Before the nic bonding is made, and so before the dhcp client is started.

    That script could be:
    #!/bin/sh

    mv /sbin/dhcpcd /sbin/dhcpcd.old

    cat >/sbin/dhcpcd <<__EOF__
    #!/bin/sh
    ifconfig bond0 hw ether 00:11:22:33:44:55
    exec /sbin/dhcpcd.old "\[email protected]"
    __EOF__

    chmod a+x /sbin/dhcpcd

    exit 1
    nas-central.org is down, at the moment, but fortunately archive.org has archived the needed zipfile:

    I'd test first if it's possible to change the bond0 mac address this way. Maybe you'll have to bring it down first, or something like that.

  • BoyanskiBoyanski Posts: 23  Junior Member
    OK, I did it, the script works now. But...

    Now something else happened. As it injects the given MAC, now my router assigns a random IP address, not the one I set in the DHCP. At first I couldn't understand why this is happening, but as I thought it later I think I realized what's going on, since I triple checked the entries there.

    The iSCSI is not the only problem I had with the changing MACs. Zyxel Drive is the other thing that works only on the MAC of LAN2 (let's call it M2 for short).

    When I first configured the NAS, it was connected to LAN2, maybe that matters. When I log in to Zyxel Drive from my phone's mobile network, if the NAS uses M2, I have access. When it has M1, it just says "Connecting..." forever. Now I set the script to inject M2, but I can no longer access it through ZDrive.

    So back to the router. I think what's happening is that when I restart the NAS, first it alternates the MAC. Since it's on M2, it changes to M1, the router detects it on the network and assigns a random IP (M1 is not in the DHCP list). After that (maybe milliseconds later) the script changes M1 to M2 and maybe this causes some kind of a mess.

    I don't know if my assumptions are correct, it's the only possible thing that came to my mind.

    When I log in to MyCloud there it shows M1. When I click the down arrow, where it shows the status (disk usage, temperature, etc..), it cannot now, just closes it after a few seconds of trying.

    Why is it so complicated? Did I make a big mess?
  • MijzelfMijzelf Posts: 271  Advanced Warrior Member
    I can imagine the box first brings up both nic's, before bonding them. You can expand the script to do some logging, to see if that is the case:
    cat >/sbin/dhcpcd <<__EOF__
    #!/bin/sh
    date >>/tmp/dhcpcd.log
    echo "\$0 \[email protected]" >>/tmp/dhcpcd.log
    ifconfig bond0 hw ether 00:11:22:33:44:55
    exec /sbin/dhcpcd.old "\[email protected]"
    __EOF__
    This will log all starts of dhcpcd.log, with it's command line arguments. (If invoked after usb_key_func.sh is invoked). If indeed the single nic is brought up first, you can filter it, and simply not start dhcpcd.




  • BoyanskiBoyanski Posts: 23  Junior Member
    If I have understood correctly, this is the log file:

    ~ $ cat /tmp/dhcpcd.log
    Sun Sep 16 17:22:16 UTC 2018
    /sbin/dhcpcd -k egiga1
    Sun Sep 16 17:22:19 UTC 2018
    /sbin/dhcpcd -k egiga0
    Sun Sep 16 17:22:21 UTC 2018
    /sbin/dhcpcd -k bond0
    Sun Sep 16 17:22:22 UTC 2018
    /sbin/dhcpcd -k egiga1
    Sun Sep 16 17:22:22 UTC 2018
    /sbin/dhcpcd -R -G -N -h NAS542 -m 6 bond0
    Sun Sep 16 17:22:24 UTC 2018
    /sbin/dhcpcd -k egiga0

Sign In or Register to comment.