Is there anyway to have Ethernet Gateway set to DHCP for IP address?



  • Hi,

    This post may sound a bit obscure at first, but read it out 🙂

    I HAD a fully functional working MySensors network with Ethernet Gateway using a WDR-4300 router set with IP address reservation. To make a long story short, the router couldn't handle all the network traffic in my house and would occasionally drop its pants and shit the bed with my internet speed and wifi devices losing connection all the time.

    I decided to take a risk and an investment and purchased the Google OnHub router. It is supposed to be a smart router, diagnosing the internet connection and constantly adjusting for it to keep it going. I have it set up and working with most of the devices on my network, minus MySensors and my FreeNAS drive (both for the same reason I think, now it gets interesting).

    I set up everything the same on new OnHub router, minus a few things I haven't been able to change (or can't find out how, but I really just don't think it's possible). and that was the subnet chain of my IP address range (used to be192.168.1.x now it's 192.168.86.x) so therefore, anything with a hardwired IP address has to be changed, including MySensors.

    The only downside is, the OnHub software doesn't allow a person to manually input a MAC address and assign it an IP address, that can only be done once a client is connected. Problem, OnHub won't recognize any device unless it leases it the IP address (hence, MySensors ethernet gateway won't work and neither will any pre-set IP address in a server).

    Is there anyway to set up the Ethernet Gateway sketch to ask for an IP address via DHCP, so I can then set my OnHub router to give the gateway a specific IP address on boot?

    I know it's a long shot, but I thought I would ask. I read in the code that it wasn't possible for the ENC28J60 Ethernet module, but nothing was said about the w5100 which I am using, and was hoping would be possible.

    Thanks!


  • Admin

    You should be able to write a simple sketch using the Ethernet library to fake a DHCP request. Set the same MAC address as you do in the Ethernet-gateway.

    We're currently doing major refactoring of the ethernet parts.. using DHCP will be an option soon.

    https://github.com/mysensors/Arduino/blob/gateway-refactoring/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino



  • Hi,

    How would I do that? I'm a complete noob when it comes to programming (just learning).


  • Admin

    Have a look here:
    https://www.arduino.cc/en/Reference/EthernetClient

    and here:

    https://www.arduino.cc/en/Reference/EthernetBegin

    As you can see, skipping ip parameter activates DHCP.


  • Hero Member

    Yeah cant you just use https://www.arduino.cc/en/Tutorial/DhcpAddressPrinter and then recycle the mac address used?



  • Well, I tried to add the DHCP, but it does go over the memory size of the Nano by 150 bytes, so it won't go there.

    Next thing would be the Uno, but again, still new and just figuring this out. Would I have to remove the SPI callout in the Gateway code, and therefore have to re-set which pins go where?

    Thanks for the help so far!



  • How about cloning the Ethernet Gateway MAC address on your PC, once it's 'known' to the router you can change your PC MAC address back and plug in your Ethernet Gateway.

    Here's some info on how to do it:
    http://www.howtogeek.com/192173/how-and-why-to-change-your-mac-address-on-windows-linux-and-mac/

    Edit: Added link to more info



  • Hi mvdarend,

    that was a good idea, but unfortunately that didn't work either. I plugged in my ethernet cable to my PC (i'm usually on wireless) and set up a static IP. That worked fine for the router. So I then cloned the MAC address over to the Arduino sketch and went back to wireless. Rebooted the Gateway and it didn't want to work. Can't even ping the IP address along the way.

    So, i'm stumped for now. I tried the code you linked to in the first reply hek, but i'm getting compile errors. It's something on my end, i'm sure.

    Anyways, i'm going to try and build a serial gateway (again) and see what happens for the short term until the library gets updated for DHCP then try again.

    Thanks!


  • Hero Member

    @drock1985 - Sorry if I missed it, by WHY do you need to use DHCP on the mySensors Gateway? Why not just pick a free IP address, outside of the DHCP pool?



  • Hi Greg,

    Its something with this new router I am using, the Google OnHub. It works differently than most routers, being advertised as a "smart router".

    It doesn't allow you to manually specify information like address reservation to MAC addresses like all other routers do (Trendnet, TP-Link, D-Link, etc). The only way it does is after a device successfully connects once via DHCP, you can then in the app (for iOS and Android, there is no web interface) you can select that device and then set a reserved IP, but never before.

    From what I can tell in the current EthernetGateway sketch (v 1.5) the code does not actually perform a full DHCP request communicating back and forth with the router (which is what OnHub wants) and instead relies on the router setting up the communication after the gateway advertises the MAC address and IP. Without the full DHCP request, I can't set a static IP at all.

    I even contacted Google multiple times, but they said it's beyond the software and how it's programmed. So now i'm forced into getting DHCP implemented into the EthernetGateway sketch.

    I know the easy solution would be to go out and get a different router, but so far this is the only one I have had in the last 3 years that I haven't had to reboot because of dropping Wi-Fi connections or slow-downs, so it's a keeper. 🙂


  • Plugin Developer

    @drock1985 if you have any of your old router or old smartphone(not using now) or your friends smart phone(change your rouer authentication detail temporerly if you use your firends phone 😉 ) connect it with you OnHub and use that MAC on your Gateway



  • That's what mvdarend suggested but that still doesn't work. I set the EthernetGateway to an unused ethernet port MAC address on my PC (since I used wireless to connect). I connected the cable to OnHub and my PC, it seen the PC and I set the DHCP reservation. Unplugged it and rebooted over back to wifi. I then programmed the MAC address of the wired MAC address I used earlier, but it still doesn't register.

    I don't know what else to try.



  • Back up and running temporarily when Arduino uno and serial gateway. Looking forward to the update for DHCP.


Log in to reply
 

Suggested Topics

14
Online

11.4k
Users

11.1k
Topics

112.7k
Posts