I have been trying to get the IP of a person on my network, so I tried pinging them and finding their ip on my network site, but it didn't give me their WAN ip. Please help.
if the client is in your network you will probably stay in your LAN - therefore you will get the response from the private IP of course.
the WAN IP is only used when the client tries to access some IP on a public range.
one option is to ask the client to visit something like http://www.whatismyip.com/ and tell you the output or host a service yourself that is doing something similar.
Related
I am very much new to network programming and maybe I am asking a very basic question.
I am working on a legacy C++ codebase where the windows 'getnameinfo' API is used to obtain the hostname from the given IP address. The obtained hostname is wrong and it belongs to a different VM in the domain.
Let us say, there is VM with hostname 'VM1' with IP 10.44.176.57 and
another VM with hostname 'VM2' and IP 10.44.176.24.
When IP 10.44.176.57 is passed to the getnameinfo() API, it resolves it to the hostname VM2.
The ping command also returns the same results.
When I ping hostname VM1 and VM2 both resolves to their correct respective IP addresses.
I checked in DNS manager, the IPs of VMs are assigned correctly.
My question is,
1) Why getnameinfo API is returning the wrong hostname?
2) Is there any way to verify the resolved hostname is the correct one ?
My computer is using Wi-Fi provided by a tplink router.
I am using a website to get my IP, https://www.whatismyip.com.
My code is fine, because I can connect to the socket in my own computer by using 127.0.0.1.
Here is my code from https://www.geeksforgeeks.org/socket-programming-cc/amp/
But I don't know why my friend can't connect to my socket using the IP I get from the website.
I wonder, do I need to set up something in my router, or am I using the wrong code?
What you get from whatismyip.com is your public IP address. Your computer is probably behind a NAT/PAT (Network Address Translation / Port Address Translation), meaning your machine has a private IP address that gets translated by your router/firewall into the public one displayed by whatismyip.com
You have two solutions:
Get a public IP address from your Internet provider, and disable NAT on your router (probably you'll need help for this).
Configure port forwarding on your router so that it forwards traffic on your public IP address to a given port on your machine.
I coded a TCP/IP Chat Server/Client in C/C++ that works perfectly in my local network and with several clients connected to it. It does not work when the Server is in a different network to the client. I coded time ago the same tool in Python and the same happened.
Is there any way of solving this? Without port forwarding, that is the most common solution.
I could only find this: Android server concept confusion. How to connect TCP chat app on different networks but I could not understand it.
NOTE: I have just find a sample program (server) that works when it is on a different network; http://www.codeproject.com/Articles/1891/Beginning-Winsock-Programming-Simple-TCP-server
You have three choices:
1) NAT penetration. Both devices simultaneously attempt to exchange data with each other, tricking each person's router into thinking that it's replying. For this to work, you each need each other's public IP address and if you need any features from TCP, you need to implement them yourself.
2) Public rendezvous server. Both devices automatically connect to a server on an unNATed network. The server knows the public IP address of every client that connects to it, so it can route your data to the client with the correct public IP.
3) Some combination of 1 and 2. Here, a public server is used to facilitate NAT penetration and eliminate the need for manual coordination. Your friend registers with the public server and the public server tells him your public IP address and facilitates NAT penetration.
In local network addresses of devices doesn't change offently. Yo can reach the computer by only defining the local address. On the other hand, if you want to communicate with a device in different network yoou should know its public IP and should define a routing to the port.
If you have a server with static IP or known IP you can reach it. You can store the IP addresses of clients dynamically in this server. Write a program that inform the IP of host computer to the server. In that way, you can store the IP addresses even they change oftenly.
Let I've an URL, for instance http://www.google.com/. I want to know all of gateway's IP addresses for package's path. Is it possible to do? If yes, please give me a pointing.
When you are outside of a local network (for example you are outside of google local network) then there is no such a thing like gateway IP of an IP. If you mean a default gateway, then read this for more info.
As an outside host which needs to connect to google.com you just can convert that domain to an corresponding IP address. To do this, you can use gethostbyname.
So I have a system using ZeroMQ as the message controller and because it doesn't allow you to find information about a clients address that is connecting or sending messages I need to pass in self identifying information containing port and ip address of the node. However I'm not sure the best way of doing this.
I'm stuck because if they connect using an internal ip address for the network I would obviously need to use that ip address but if its going over WAN then I need the public ip address. What is the best way of communicating the ip address of the machine without knowing whether or not you are connecting to a local machine or a machine over WAN