arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
259 stars 264 forks source link

Library returns router IP address instead of remote IP for NAT'd host #71

Closed SapientHetero closed 5 years ago

SapientHetero commented 6 years ago

I used my ASUSwrt-Merlin router's port-forwarding feature to test my server on the internet and noticed client.remoteIP() returns the router's local address (192.168.1.1) for every connection instead of the client's actual IP. Is there any way to obtain the real client IP?

Rotzbua commented 6 years ago

Ensure that you only use ipv4 otherwise a nat64 will change the source ip.

SapientHetero commented 6 years ago

Ensure that you only use ipv4 otherwise a nat64 will change the source ip.

Ipv6 is already disabled in the router. Or am I misunderstanding your suggestion?

Rotzbua commented 6 years ago

Ipv6 is already disabled in the router. Or am I misunderstanding your suggestion?

That's what I thought.

I guess your router does translate both ip addresses (source and destination). My router from avm doesn't do this. Works as expected.