Why can't I access a local file from my public ip address if I can from my private ip address? - networking

I'm able to open the website being served on port 4568 on 127.0.0.1 (localhost) and my private ip address, but I can't seem to do so on my public ip address. I've tried to access the website by typing :4568 after my public ip like I did for my localhost and private ip.
Is it possible to open a site running locally on my computer through my public IP? If so, how? If not, why not?
NOTE: I'm not exactly clear what tags are appropriate. Feel free to add or remove any you deem inappropriate.

You are likly behind a NAT. What this means is that your public IP address and private IP address are not necessarily mapped to each other fully. To explicitly map your application to your public address, try the following:
Go to your modems management page
Look for a 'Port Forwarding' tab (might be under an advanced or
router menu)
There will probably be two or three field to enter:
The port on the public ip address to forward traffic from
The IP address to forward traffic to (your private IP)
(might be there) The port to send it to on the private IP
Assuming this works, all traffic going to your public IP address on that port will now go to your private IP address.
WARNING This is a simple rule and everyone on the internet can now access that port
Also make sure your web server is listening on 0.0.0.0 (all IP addresses) and your local firewall is allowing remote connections on the port in question.

Related

How we can access a localhost of a computer through its public IP if some other devices in the same network also have the same public IP?

I want to access localhost of a computer but other computers in the same network also has the same public IP. Can we access its localhost host by knowing both(public and private) IP address of that computer. I want to connect to it directly(not through any software like ngrok or VPN).
Thanks in advance.
You can only access localhost on the computer itself. Localhost refers to 'this node' by definition.
When communicating on an internal network you usually use the private IP addresses, not the public one(s). Connecting to a computer with a private IP behind a public IP requires reverse NAT aka destination NAT aka port mapping.
Connecting out from and right back into the same network through NAT may require a special firewall setup aka hairpinning. It's usually easier and faster to use split-brain DNS and resolve the public name to the private IP address of the device.

Failing to manage a Public Ip

Here is the scenario:
I have asked my ISP to give me public IP, which I can connect to my laptop and access from other outside network. They gave me following
IP : 103.51.2.198
subnet mask : 255.255.255.248
default Gateway : 103.51.2.193
preferred dns : 8.8.8.8
Alternate dns : 8.8.4.4
I have connected PPPoE connection in my laptop (not in router) and set these values at TCP/IP V4. My internet connection is fine.
But If I ping from other network by this IP (103.51.2.198), request is timed out.
Than I checked whatsmyrealip. and the IP is (103.51.2.102). this IP is a public IP of my ISP provider. And they are trying to give me an IP from that IP.
My ISP providers are not expert in networking nor am I. They are also not sure how they can give me a public IP.
I am not sure about what are they trying to do. and how will they give me another IP from a public IP. It will be very helpful, If anyone can explain the problem. and give a solution.
First of all, it's called public IP not "realIP".
Anyways, the answer for your question is:
You cannot access your home computer because it is behind NAT so it is unreachable from the outside of your network.
Quick example on how NAT works:
Scenario:
Private IP: 192.168.0.10
Public IP: 1.2.3.4
You are connecting to webserver on IP: 5.5.5.5
What happens:
You send data to your router, telling it that you want something from
5.5.5.5, your router assigns you a random port, let's say 11111,
sends the data with source IP 1.2.3.4 and port 11111. Stuff
happens on the webserver and the data comes back. Router reads it and
remembers that everything going to 1.2.3.4:11111 belongs to
192.168.0.10 so it sends you the data.
Here everything works because it's your computer the one starting the connection, otherwise, the webserver would never be able to connect to you.

Cannot access machine via DNS in the private network

I have a machine in my private network with IP 192.168.1.10
I have a DNS name, "toto.mydns.com", a DNS client is running on the machine.
I configured the router for Port forwarding.
I can access the machine when i am outside my home, when using a pulic IP address it works but when i am at home and i get a dynamic IP address trough DHCP from my router, i cannot use toto.mydns.com anymore, i must use 192.168.1.10 to access.
I would like to know if i need to configure something on the router for that ?
Thank you !
toto.mydns.com will resolve to your external public IP
There will almost certainly be nothing routing that IP through to your router, and thus through NAT to your internal address.
The easiest way to resolve this (Pun very much intended) is to have a hosts file entry on your computers running inside your network so that they resolve the same DNS address to the internal address.
A much harder, but more fun, way would be to set up your own DNS server inside your network, have the DHCP dish it out as the primary DNS server for your network and put in an entry for your internal address :D
Have fun...
Toto.mydns.com is accessible from outside,this DNS is assigned on a machine with a static IP address(sorry not dynamic),so the IP of this machine is 192.168.1.10.
Whrn i am at home in my private network i need to enter 192.168.1.10 and toto.mydns.com does not work.Any help???

HTTP request to web server from client using private ips

I'm curious why a client(android or c# based program, etc) behind a private router(or gateway, anyway with a private ip such as 192.168.xx.xx) can get a response from a request to a http server.
I know that this works, but just want to know how.
Is the client which is getting back the response need port forwarding unless it's not using a public ip?
He doesn't need port forwarding.
This can work by using NAT or PAT (Network Address Translation or Port Address Translation) configured in the Router mostly configured by the ISP's in the edge router.
-EDIT (more explanation added):
The edge router has some public IP (mostly pool of IP's) configured to communicate in internet (public network).
When the request that comes from internal network with private IP it takes that and changes the source IP (private IP) to one of the public IP's that has configured, thus the request would look like is made by the router itself.
Mostly will attach also a port number and save it in a database table (local db in router) with the private IP of the device who originally made the request and will forward the request to the internet.
Then, when the response is received by public server in that router, it will map it by the port with the private IP that had saved it in local db earlier, so it will know to whom it belonged originally, and will forward that to the IP

How to telnet to a computer which is sharing a single public ip?

Suppose that I am sharing a public ip 56.162.XXX.XXX with some other users. Now I have a local ip that I see if I type ipconfig in the command prompt. That is 192.168.2.3. Now I have a program running on port 3630 listening to any incoming connection. I can call myself with the help of loop back ip ie. telnet 127.0.0.1 3630, and i see that two programs are getting connected and can exchange data. I can also telnet and get connected with my laptop from another laptop which is sharing same public ip as mine by the command telnet 192.168.4.20 3630. But how should I do the same from a remote computer? I mean a computer which has a different public ip.
Actually I want something like "telnet public ip(local ip) port no". The other computer is also sharing a public ip with some other users.
You will need to setup some kind of NAT (Network Address Translation) or PAT (Port Address Translation) that will forward the requests for port 3630 to your local IP.
The actual configuration to use will depend on your firewall/router. If you have a standard ADSL router, there is likely to be a configuration page in there that will allow you to do this.
You will need to read up on port forwarding and NAT.
http://en.wikipedia.org/w/index.php?title=Port_forwarding

Resources