1

At home, I have a modem, router, desktop, and laptop.

My modem is connected to my router. The desktop is connected through a wire to my router. The laptop is connected wirelessly to the home network/router.

When I go to this website: http://whatismyipaddress.com/ , the IP address is the same for my desktop and my laptop. How can I determine the unique IP?

The reason I ask is because I am interested in developing a simple C++ server-client chat application intended to work over the internet. When writing this, I believe the client's code will need to have information about the server (IP Address and Port #). I would like to run the server on the Desktop machine and have any machine running the client code to be able to connect to it.

Thanks for your help. Also, in case you are interested, I am following this c++ chat application tutorial to do this: http://www.youtube.com/watch?v=-Rk8LPtVpY0

code
  • 5,294
  • 16
  • 62
  • 113
  • Thank you for this information. So it seems like the only thing that I need to specify is my unique home IP address and the Port # in the Client's code so that the client executable will know where to connect to. Lets say the client.exe is run on a machine outside of my network. How will it know the server.exe is running on my desktop versus laptop? Also, is there any other step that I will need to do ? When specifying a port number in my router settings page, should I select TCP or UDP? – code Sep 29 '12 at 22:09

4 Answers4

6

It's because whatismyipaddress.com is just getting your external address. Your router is hiding your internal addresses. If you want to get your internal ip addresses you have to lookup the ip address on your computer (if it's windows go to network and sharing center and click on the "Local Area Connection", then details).

If you want to make your desktop available to the web (as the "server" as you put it) you're going to have to forward ports on your router to the desktop.

CrazyCasta
  • 26,917
  • 4
  • 45
  • 72
  • Thank you for this information. So it seems like the only thing that I need to specify is my unique home IP address and the Port # in the Client's code so that the client executable will know where to connect to. Lets say the client.exe is run on a machine outside of my network. How will it know the server.exe is run on my desktop versus laptop? Also, is there any other step that I will need to do ? When specifying a port number in my router settings page, should I select TCP or UDP? – code Sep 29 '12 at 21:53
2

The website is reporting the IP address of the modem. This is the address the rest of the Internet sees you as. As opposed to the 192.168.x.x address you obtained from your router, which is only useful for your internal network (any device connected to the router).

To determine your unique IP address you can do two things:

Log in to the router and look for a status tab, this tab usually reports all the connected devices.

Or more easily, if your on Windows run "cmd" and type in "ipconfig /all".

Frison Alexander
  • 3,228
  • 2
  • 29
  • 32
2

As we don't have enough IP4 IPs to get every device on the net a unique IP, there is something called masquerading. This allows a router to mask the outgoing traffic for your local network under one "real" IP address. This address is given to you when your router connect to the internet.

Typically your local net is somewhere in the address ranges reserved for local nets like 192.168.*.*

This of course makes direct networking between 2 machines where one is masked a bit tricky. Your router basically know which of the local machines are the origin of the connection, so it can direct responses back to the right machine.

If you need a connection that is totally transparent for both sides you would have to create port forwardings to your local machine - so that it becomes visible to the internet.

Some website can show you your outward ip, but easiest would be to log into the router and have a look there.

Kai Mattern
  • 3,090
  • 2
  • 34
  • 37
1

The ip address of every device seen from outside your home network will be the same. That's one of the jobs of the router (abstracting away which particular device is responsible for which packet) and this concept helps make the internet scalable.

Read more about subnetworks on wikipedia.

It's also a good idea to learn networking basics before writing your application. Check out

Community
  • 1
  • 1
Pramod
  • 5,150
  • 3
  • 45
  • 46