Is there anyway to have Ethernet Gateway set to DHCP for IP address?
-
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.
-
Have a look here:
https://www.arduino.cc/en/Reference/EthernetClientand here:
https://www.arduino.cc/en/Reference/EthernetBegin
As you can see, skipping ip parameter activates DHCP.
-
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!
-
@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. :)
-
@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 :wink: ) 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.