Author Topic: how to set IP of Arduino over Ethernet?  (Read 1979 times)

0 Members and 1 Guest are viewing this topic.

Offline awallinTopic starter

  • Frequent Contributor
  • **
  • Posts: 694
how to set IP of Arduino over Ethernet?
« on: May 03, 2018, 07:57:32 am »
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
 

Offline dmills

  • Super Contributor
  • ***
  • Posts: 2093
  • Country: gb
Re: how to set IP of Arduino over Ethernet?
« Reply #1 on: May 03, 2018, 03:30:57 pm »
Whats wrong with DHCP?

Regards, Dan.
 

Offline awallinTopic starter

  • Frequent Contributor
  • **
  • Posts: 694
Re: how to set IP of Arduino over Ethernet?
« Reply #2 on: May 03, 2018, 04:07:10 pm »
Whats wrong with DHCP?

With 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.
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9810
  • Country: 00
  • Display aficionado
Re: how to set IP of Arduino over Ethernet?
« Reply #3 on: May 03, 2018, 04:16:01 pm »
With 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.
Normally 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.
 
The following users thanked this post: TomS_

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: how to set IP of Arduino over Ethernet?
« Reply #4 on: May 03, 2018, 04:27:42 pm »
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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline dmills

  • Super Contributor
  • ***
  • Posts: 2093
  • Country: gb
Re: how to set IP of Arduino over Ethernet?
« Reply #5 on: May 04, 2018, 03:26:03 pm »
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.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: how to set IP of Arduino over Ethernet?
« Reply #6 on: May 08, 2018, 11:20:53 pm »
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.
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 7992
  • Country: gb
Re: how to set IP of Arduino over Ethernet?
« Reply #7 on: May 09, 2018, 12:08:30 am »
Whats wrong with DHCP?

With 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.

Or 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.
« Last Edit: May 09, 2018, 12:11:47 am by Monkeh »
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
Re: how to set IP of Arduino over Ethernet?
« Reply #8 on: May 11, 2018, 12:59:43 am »
Give it a memorable MAC address and use arp to find the IP address.
 

Offline Mr.B

  • Supporter
  • ****
  • Posts: 1237
  • Country: nz
Re: how to set IP of Arduino over Ethernet?
« Reply #9 on: May 11, 2018, 01:09:45 am »
Normally 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.

What 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.
I approach the thinking of all of my posts using AI in the first instance. (Awkward Irregularity)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf