How to get IP address of remote computer ?
Bean
Posts: 8,129
I'm working with the "Brilldea W5100 TCP Server Echo Demo indirect Ver. 00.1" and I just want to print the IP address of the remote computer.
I wait until ETHERNET.SocketTCPestablished(0) is true, then I print the values in DestIP[], but they are always zeros ???
Any ideas how to get the IP address of the remote computer that connected ? I want to keep of log of them.
Bean
I wait until ETHERNET.SocketTCPestablished(0) is true, then I print the values in DestIP[], but they are always zeros ???
Any ideas how to get the IP address of the remote computer that connected ? I want to keep of log of them.
Bean
Comments
Hmmm seems like I've seen that information being passed as part of the header hash... I ended up stripping it off. If you don't get a reply by this weekend, I'll look into it, but I think the information your looking for is already in front of you.
id is the socket ID.
Problem is that it always returns my domain IP address. I guess the router handles the transmission to the actual dest IP address.
Do you know if there is anyway to get the actual dest IP address ? Or is that only known by the router ?
Bean
-Phil
http://www.agaverobotics.com/spinneret/tcptest.aspx
Edit: just to make sure I'm no the same page. You should see my WAN address not my PC IP address If I hit your Spinneret.
But I tried one of the proxy websites and it worked (it did NOT give me my local router address). So I'm good.
Bean
Dest IP Address=65.98.8.130
Dest MAC address=00:26:62:33:B1:90
So I got 130 for the last value not 151 that you posted ???
Bean
This will be great for providing access to a spinneret ONLY to certain IP addresses or certain MAC addresses... Cool...
Bean
I'm not sure. I can't get the MAC info from my hosting control panel.
The way it works is like this:
1: Computer A wants to talk to computer B.
2: Computer A calls DNS to ask 'what is the IP address of B?'
3: The name server replies that the IP address of B is '111.222.111.150'
4: Computer A checks its own routing table to see if 111.222.111.150 can be served from the local subnet
5: If no, then it'll go by a router, or gateway, say '192.168.1.1'
6: Computer A does an ARP broadcast and asks 'What is the MAC of 192.168.1.1?'
7: It receives the MAC address
8: It sends the data (now we're on Ethernet level) to that MAC address
9: The 192.168.1.1 router continues the same way, and asks for the MAC of the next gateway, and so on. But from then on that's invisible to computer A, it's all between the routers/gateways along the route.
So the MAC address will always be of the nearest router.
Even if your setup is such that there doesn't seem to be any routers in between (you can only manage this on your local network) then there could still be some computer in between (with a totally different IP address) which will respond to an ARP broadcast with 'Hey, I can serve that IP, here's my MAC'. It will then get that data, and forward it (maybe through another interface) to another computer.
It's all because the IP address is an identifier on the IP (as in TCP/IP or UDP/IP) level, and identifies the end-to-end points, while MAC is an identifier on the underlying protocol (Ethernet), which identifies the point-to-point physical nodes.
-Tor