0

I´d like to connect my Ethernet2 with WIZ550 using DHCP but instead of Local IP, I want to use Hostname.

This is my code, it works. I get a Local IP Address and I can connect to Arduino using this IP, but I don't know how to setup hostname.

void setup() {

  // Monitor Serial begin
  Serial.begin(9600);
  Serial.println("Welcome to Itronic");

  // start the Ethernet connection:
#if defined(WIZ550io_WITH_MACADDRESS)
  if (Ethernet.begin() == 0) {
#else
  if (Ethernet.begin(mac) == 0) {
#endif
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
      ;
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.print("My MacAddress: ");
  for (byte thisByte = 0; thisByte < 6; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(mac[thisByte], HEX);
    Serial.print(",");
  }
  Serial.println();
  server.begin();
  // Hardware Serial (2,3) begin
  mySerial.begin(19200);
Serial.print("hostName: ");
  Serial.print(Ethernet.hostName());
      Serial.print("dnsDomainName: ");
  Serial.print(Ethernet.dnsDomainName());
  IRreceiver.enableIRIn();  // Start the receiver
}
10
  • You need a DNS server and your own domain name, or an entry in your hosts file (dependent on OS). Your router may provide the facilities if it's good enough. – Majenko Apr 24 '17 at 22:22
  • @Majenko, do you know any tutorial out there? – Marckaraujo Apr 24 '17 at 22:29
  • First off you really need to learn how the internet works. – Majenko Apr 24 '17 at 22:32
  • I am not a noob with code, I know how to put a apache server btw, however I dont know how to setup this for arduino, another thing is that I am trying to setup a local server, so I really think that your sugestion is wrong as I dont need a "real domain name" for local setup. – Marckaraujo Apr 24 '17 at 22:40
  • 1
    Got it, thanks. However I dont want to use a computer, my webserver is running inside arduino, like: arduino.cc/en/Tutorial/WebServer – Marckaraujo Apr 24 '17 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.