how to set IP of Arduino over Ethernet? - Page 1
Forum section: electronics / general

author: awallin
author_rank: Frequent Contributor
timestamp: May 03, 2018, 07:57:32 am
content: Hi all, does anyone have a neat solution for setting the IP of an Arduino (Due) with Ethernet-shield - preferably over Ethernet?I would like to avoid re-programming over the USB-prog port with a hard-coded IP every time I want to change networks.Some kind of UDP(?) packet or similar that sends a magic-packet to the right MAC as long as the sending machine is on the same physical Ethernet as the Arduino?thanks for ideas!AW

author: dmills
author_rank: Super Contributor
timestamp: May 03, 2018, 03:30:57 pm
content: Whats wrong with DHCP?Regards, Dan.

author: awallin
author_rank: Frequent Contributor
timestamp: May 03, 2018, 04:07:10 pm
content: Quote from: dmills on May 03, 2018, 03:30:57 pmWith DHCP you then need to find out what IP the Arduino got.- either the arduino has a display, prints it out on the USB-serial, or maybe beeps out the IP-numbers, or something similar- OR you need to log into your router/firewall and look at the list of dhcp-leases.so not ideal, unless you also have a display on the arduino.

author: Mr. Scram
author_rank: Super Contributor
timestamp: May 03, 2018, 04:16:01 pm
content: Quote from: awallin on May 03, 2018, 04:07:10 pmNormally you'd set DHCP reservations for specific MAC addresses if you want a device to have a specific IP address. That's how you set the IP address of any device on your network.It sounds like you want to send out fixed IP addresses to your devices, to then have DHCP retrieve and honour those. That leaves a lot of room for error. You simply need better integration with your DHCP service and set things up properly.

author: nctnico
author_rank: Super Contributor
timestamp: May 03, 2018, 04:27:42 pm
content: If you need to know the IP address of a gadget you can implement a simple protocol over UDP. If the gadget responds to a broadcast UDP packet you don't need to know it's IP address.

author: dmills
author_rank: Super Contributor
timestamp: May 04, 2018, 03:26:03 pm
content: DHCP for IP address then respond to a broadcast to tell whatever is on the other end what IP you have?mDNS is also possible to make your device known, but each one then needs a unique name which can be almost as much of a problem.The real pain is when the other end is a web browser because they need an address to connect to and typically cannot be told "Send this broadcast packet and give me a list of who responds".For assigning an IP address DHCP is favorite followed by something like zeroconf but that is a pain in almost all other ways.Regards, Dan.

author: westfw
author_rank: Super Contributor
timestamp: May 08, 2018, 11:20:53 pm
content: Note that for most Arduinos with most arduino ethernet shields, you also need to come up with a "unique" MAC address.The SAM3X used on Due has a "unique identifier" for each chip, but of course it is an inconvenient length (128bits) for using as mac or ip address.It also looks like a pain in the neck to read.

author: Monkeh
author_rank: Super Contributor
timestamp: May 09, 2018, 12:08:30 am
content: Quote from: awallin on May 03, 2018, 04:07:10 pmOr set the broadcast flag and you can then just watch the traffic.E: Looks like they already do this. Sniff away, and any non-compliant servers you find should simply be shot out an airlock.

author: oPossum
author_rank: Super Contributor
timestamp: May 11, 2018, 12:59:43 am
content: Give it a memorable MAC address and use arp to find the IP address.

author: Mr.B
author_rank: Unknown
timestamp: May 11, 2018, 01:09:45 am
content: Quote from: Mr. Scram on May 03, 2018, 04:16:01 pmWhat he said.IMHO, This is the least error prone method when you want to be able to change the IP address semi-often or change networks often.