Full Ethernet network information. - SOLVED

Hello, I'm using te standard Ethernet2 library and the Example web server sketch. I would love to see the full network information such as the ipaddress, subnetmask, gateway and dns. I can not figure out a way how to do that and Wondering If it is possible to see the full information in serial monitor?

Joseph

Exactly which Ethernet library are you using ?

The GitHub page for the Ethernet2 library says

This library is no longer going to be used, since the official Arduino library has been updated and works great GitHub - arduino-libraries/Ethernet: Ethernet Library for Arduino

1 Like

that's now your 4th thread in the context of "Networking" in the last days. Can you pls explain in ONE thread what you really have and what you really want to achieve?

Regarding your question: if you have a DHCP server in your network, you just gather an IP by DHCP and afterwards you know the ip, subnet, gateway and DNS.

Please move your post by editing the tile to a better sub forum like "Using Arduino / Networking"

adopted from my WiFiEspAT library PrintPersistentSettings example.
not tested

void printEthStatus() {
  uint8_t mac[6];
  Ethernet.MACAddress(mac);
  Serial.print("Station MAC: ");
  printMacAddress(mac);

  IPAddress ip = Ethernet.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  IPAddress gw = Ethernet.gatewayIP();
  Serial.print("gateway IP Address: ");
  Serial.println(gw);

  IPAddress mask = Ethernet.subnetMask();
  Serial.print("subnet IP mask: ");
  Serial.println(mask);

  Serial.print("DNS server: ");
  IPAddress dns1 = Ethernet.dnsServerIP();
  if (dns1 == INADDR_NONE) {
    Serial.println("not set");
  } else {
    dns1.printTo(Serial);
    Serial.println();
  }
}

void printMacAddress(byte mac[]) {
  for (int i = 5; i >= 0; i--) {
    if (mac[i] < 16) {
      Serial.print("0");
    }
    Serial.print(mac[i], HEX);
    if (i > 0) {
      Serial.print(":");
    }
  }
  Serial.println();
}
1 Like

There is 2 projects I'm working on different things, Hardware and software.

My different post are for hardware and software both Not the same thing. Yes for networking but not the same questions.

Thank you looking at it now.

Thank you juraj, I figure out the subnetmask from the library I was going through but not the gateway or dns part.

use the Ethernet library, not Ethernet2. Ethernet2 is obsolete since Ethernet supports W5500

I have the IDE of 1.8.16. Does that suport the 5500?

IDE 1.8.16 has Ethernet library bundled. just use
#include <Ethernet.h>

Thank you I will do that.

Hello juraj I have a updated question. Is it possible to see If and what Vlan my arduino is on? Sometimes I can't remember what port is on what lan or Vlan and it is a pain to login and go through all my network settings just to find what port is on what? I never tag my ports with some type of know for personal reasons I guess.

Joseph

I don't understand what you ask. If there are multiple local networks they should have different network part of the IP address. like 192.168.0.x and 192.168.1.x

Iā€™m sorry you are right. My mistake there. Disregard that last question please.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.