Google Answers Logo
View Question
 
Q: IP address of a Computer, Router ( Answered 5 out of 5 stars,   4 Comments )
Question  
Subject: IP address of a Computer, Router
Category: Computers
Asked by: asdf123-ga
List Price: $25.00
Posted: 21 Nov 2005 18:56 PST
Expires: 21 Dec 2005 18:56 PST
Question ID: 596044
I am experimenting with some simple java code for creating a simple
server on a pc (for example on port 80 - the internet).

If i run the code and put my IP (the one provided by my router apparently)
in a web browser i can access my server. However other computers outside
my network cant.

With java a client can open a socket connection with:

String name = ....
InetAddress.getByName("" + name); 

or

InetAddress.getByAddress("xxx.xx.x.xxx"); 

So the question is:
How does someone gain access to such a server on my PC?
my router given IP doesnt work (outside of my computer)
and the IP of the router doesnt
specifically identify my machine - so how do i do this!!!

i am as IP literate as going to command window and typing ipconfig /all.
i connect using cable internet.

i dont know how things like the "connection spec dns suffix", "physical add",
and all that play a part in this. 
I always thought there would be a single identifying IP for a PC.

In summation im looking for a way for someone to make a socket connection
to my computer. Im assuming with a unique ip address. How do i find that 
address?

Please Help!
Answer  
Subject: Re: IP address of a Computer, Router
Answered By: sublime1-ga on 21 Nov 2005 19:44 PST
Rated:5 out of 5 stars
 
Hi again, asdf123...

You're quite right that your router address does not identify
your machine. In fact many routers of the same brand name will
have the same router IP address given by ipconfig /all.

the easiest way to determine your web IP address is to go to:
http://www.whatismyip.com/

That will show you the IP address that others need to use to
access your server. Assuming your router has been set up to
allow traffic through port 80, you should be good to go.

This would be the numerical IP address you'd use in conjunction
with the InetAddress.getByAddress command.

Your router configuration page should also specify the URL
that whatismyisp.com shows you. You can usually find it by
entering the Default Gateway address, which you get when you
run ipconfig /all, into your browser's address bar. This would
be a number very similar to your router's IP address, but with
the last 3 digits being different, and quite possibly 254.


Let me know if that satisfies what you were seeking when you
posed your question, or if I missed anything.

Please do not rate this answer until you are satisfied that  
the answer cannot be improved upon by way of a dialog  
established through the "Request for Clarification" process. 

sublime1-ga

Request for Answer Clarification by asdf123-ga on 21 Nov 2005 20:23 PST
That didnt work.

I have four PCs on the router and they ALL get the same IP
with that site (ive been there before).

When i enter the IP a username/password box appears (and then the 
routers page opens NOT the server).

I went to the routers page and found a page with the following:

Port Range  
Application  Start    End   Protocol      IP Address       Enable 
  ________      0   to  0  TCP/UDP/Both   192...  


Is this where i should be setting this stuff?
If so how?
What does every field control?
Application?
Do i put the IP of my PC only?

The question persists... if there was a server on each of the 
4 PCs how would the client distinctly pick the PC (i thought
there would be a unique IP)?
Do they all have to use different ports then?
They cant all use 80 then?

Thanks!

Request for Answer Clarification by asdf123-ga on 21 Nov 2005 20:33 PST
Update:
I entered 

Application: Blank
Start: 80
End: 80
Protocol: Both
IP Address: -- mine (as given by router)  
Enable: checked on 

And the server worked on my computer and another one on the router.
And im assuming it will outside of the router.

My final clarification is:
Is this the only way to do this behind a router?
There is no direct unique ID outside of playing with 
router settings?

I want to make an online game for me and a few friends by
making socket connections with java but as posted before you need
a name or IP address.

With everyone behind routers it seems like this is a difficult way
to connect to a given computer.

Clarification of Answer by sublime1-ga on 21 Nov 2005 22:46 PST
Hi asdf123...

In your latest clarification, you said:

"Update:
 I entered 

 Application: Blank
 Start: 80
 End: 80
 Protocol: Both
 IP Address: -- mine (as given by router)  
 Enable: checked on 

 And the server worked on my computer and another one on the router.
 And im assuming it will outside of the router."

Right. This is what I meant by enabling port 80 from the 
router configuration page.

"My final clarification is:
 Is this the only way to do this behind a router?
 There is no direct unique ID outside of playing with 
 router settings?

 I want to make an online game for me and a few friends by
 making socket connections with java but as posted before you need
 a name or IP address.

 With everyone behind routers it seems like this is a difficult way
 to connect to a given computer."

Your IP address is assigned by your ISP (Internet Service
Provider) and will be the same for all the PCs attached to
your router and comprising your LAN (Local Area Network).

Speaking to that, if you don't have a fixed IP address, you
may need to notify your friends of a change of address from
time to time. Most cable and DSL connections have an IP
address which is "leased", and the lease is renewed every
4 to 24 hours. While a cable provider may, in fact, give
you the same IP address for months at a time, it isn't
a requirement on their part, and can change at any time.

One way in which you can be a bit more specific is to give
your friends the IP address with the port number included
in the address, as in, for example:
http://68.154.122.173:80/

You could, of course, use a different port number, but you
would still have to set it up in the router to allow traffic.

Using your web IP address, as in the example above, would
allow 2-way traffic between your friends and all the PCs
in your local network. If you want to limit them to only
connecting with one of the PCs, you could configure the
settings, as you did above, with the IP address given to
the specific machine you want to use. It's unique IP 
address will be found by using ipconfig /all on that 
machine, and will be a subset of the 198.168.123.xxx
series which your router uses to identify each specific
machine in the network. So you would still give your 
friends the web IP address, but the router would limit
the connection to the one local machine you have named.

If your java application resides on your server, and
has an executable file (.exe), you can specify this
in the Application area. Leaving the field blank will,
I believe, allow any and all applications to use that
port.

It may seem tedious to have to go through this configuration
process, but given the safety which a router provides as a 
hardware firewall, in addition to allowing the creation of
a local network, it's really a small price to pay.

Let me know if that clarifies what you need to know.

sublime1-ga
asdf123-ga rated this answer:5 out of 5 stars
Sublime's answer solved the problem immediately and i appreciated the quick
and pleasant responses. Ive learned more so i have more questions -
but they are outside the scope of my original question and i think it
would be unfair to ask them here.
Great work!

Comments  
Subject: Re: IP address of a Computer, Router
From: happymac-ga on 21 Nov 2005 22:20 PST
 
What is happening here is your router is not set for Network Address
Translation. The IP address you see at whatismyip.com is the WAN IP of
your cable modem/router. You need to complete the following steps for
your server to work:

1) Ensure that you are assigning a static IP address to the machine
running the server; you may continue to use DHCP for the other
machines on your network, but be sure the DHCP range is not inclusive
of the IP assigned to the server.

2) Set up NAT (Network Address Translation) to forward all port 80
incoming traffic to the static LAN IP of the server.

Hope this helps.
Subject: Re: IP address of a Computer, Router
From: feldersoft-ga on 21 Nov 2005 23:40 PST
 
No the problem is the router IS setup for network address translation.
 This is fine (and most likely desirable), but in order for this to
work he needs to setup port forwarding on the router.
Subject: Re: IP address of a Computer, Router
From: sublime1-ga on 22 Nov 2005 19:29 PST
 
asdf123...

Thanks very much for the 5 stars!

Best regards...

sublime1-ga
Subject: Re: IP address of a Computer, Router
From: lowenbrau_meister-ga on 25 Nov 2005 18:09 PST
 
sublime1's  answer is not entirely accurate:
  "Your IP address is assigned by your ISP (Internet Service
    Provider) and will be the same for all the PCs attached to
    your router and comprising your LAN (Local Area Network)."

This is not correct.  If you have a router that sits between your
cable modem and the other PC's in your house, the router will be
assigned the unique IP Address by your ISP.  The router uses something
called "Network Address Translation", NAT for short, to allow multiple
PC's in your house to access the internet hiding behind that one
unique IP address that your router uses.

The PC's inside your house, sitting behind your router, get a
"non-routable" IP address, either 192.168.x.x or 10.x.x.x., most of
the times its the 192.168 one.  This is NAT, allowing multiple PC's on
a LAN to connect to the internet using one internet connection and one
IP address.  These non-routable IP addresses cant go over the
internet, they are rejected by internet routers as unkown.  So your
buddies cant connect to your server on your PC by typing in the
non-routable IP 192.168.0.5..   What they need is the unique IP
address on your router WAN plug, lets say 110.30.46.37.  But you have
4 PC's  on your LAN, so how do they get that one specific server? 
They have to know the port to connect to.  Its also why when you want
to www.whatismyip.com, you got the unique IP address sitting on your
WAN plug and not the non-routable ip address of 192.168.0.5 on the
specific PC you were using.  Your router assigns these non-routable
addresses to your PC's when they are initially connected to the
router, and your router maintains a table of which PC is using wich
internal, non-routable IP address.  When you went to whatismyip.com, 
the router actually went to the web page, you PC kinda said something
like:  "Hey router, go to this web page and give me whatever its
says", your router says " You got it,  here is what I found"

When you go get a web page, like Googles home page, your computer
figures out Googles unique IP address, Googles is 72.14.207.99. When
your PC wants to get Googles web page it puts the port number for web
pages at the end of the ip address, example: 72.14.207.99:80 .  AND it
gives Google a return address of 110.30.46.37:2235.  Now thats your
unique IP address with a weird port number on it.  All ports from
0-1024 are already assigned to specific purposes. 1024 - 65535 are
open for random use.  When you wanted to make that initail contact
with Google and gets there web page, your PC had to go through port 80
to get to Google.  Your PC is also telling Google to continue the
electronic conversation on port  2235,  from that point on, until you
and Google are done communicating or time out, you will use port 2235
to exchange data.  You dont see this because its hidden from the user
to make life simple, which is a good thing.

Now when you set up the server on your PC, how do your buddies access
it???  You go to your routers set up page.  Like you said before, 
when you entered your own unique IP address into a browser  you got a
username password box, thats because your browser has a small web
server sitting on it so you can configure your router through a
browser. But you dont want anyone configuring your router, so you have
to log in and thats what the username password box is.  Once you log
into your router go to the Port Forwarding page, this is where you can
set a specific port to send all traffic to a specific PC!!!!!  That
page you were talking about before

"I went to the routers page and found a page with the following:
Port Range   
Application     Start        End    Protocol             IP Address       Enable 
  ________      0      to    0       TCP/UDP/Both   192...  
"


Now, you  should use a port number outside the assigned port range,
aka 0-1024. So when your buddies want to connect to you to play that
game, the ip address will have that port number at the end, example:
110.30.46.37:73489 .  When your router gets those packets from your
buddies, it will check the port number at the end of the IP address,
the router will see port 73489,  and it will know to send that packet
to you server PC.
NOW  you can only assign one port number to one PC, that is the
limitation of your router.  If you wanted to set up the same server on
all 4 PC's and have people connect to wichever PC has the least amount
of load on it,  you would need a "Load Balancer", but thats a whole
different conversation.

Example of Port Forwarding Page 

Port Range      
Application     Start             End           Protocol          IP
Address        Enable
Java Server     73489    to     73489       TCP/UDP        192.168.0.5
     (checked on)


SO, when your router gets people connecting to it with port 73489,
your router will automatically forward those data packets to your PC
with the internal "non-routable" address of 192.168.0.5, on which your
server is running.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy