Go Down

Topic: Setting a static IP address for ethernet shield. (Read 2390 times) previous topic - next topic

catchlavaghana

Greetings all,
Quick little question I was hoping somebody may be able to answer. I'm currently using a sub domain to control my arduino via ethernet shield through the internet. All working perfectly until I reset or unplug my router. After this happens my router assigns a new DHCP ip to my arduino. I then cannot access it from the internet until I change my byte gateway in my code to the new assigned DHCP ip by my router. I was just wondering how if possible to assign a static ip to my arduino/ethernet shield so that I don't have to change my byte gateway each time my router resets.

Thanks in advance!
Code: [Select]
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 4 }; // ip in lan
byte gateway[] = { 192, 168, 1, 3 }; // address on DHCP (This is the one I have to change each time my router resets)
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask

PaulS

Quote
After this happens my router assigns a new DHCP ip to my arduino.

You should be able to configure the router to assign the same address to the Arduino each time.

You do not NEED to specify a gateway.
The art of getting good answers lies in asking good questions.

Go Up