I am getting the wrong client IP address - asp.net

I am running an ASP.NET application. The web server is located on the same system. In the code behind I just want to get the IP address of the requesting client. I am using this code:
Request.UserHostAddress
But I am getting a wrong address: 127.0.0.1. My system IP address is 198.162.0.27.

You are getting the right one. 127.0.0.1 is the loopback IP address, which is mapped in your hosts file to localhost.
If you connect from a remote computer, you will get the remote computers network address.

Related

How does WMI resolve hostname to IP

For a machine with multiple IP addresses and has a hostname, how does the WMI remote query choose which IP address to connect to? I know that if we set the IP address of a machine in "hosts" file, the ping command will resolve to that IP address.
The reason I have this question is because one of the proprietary app
that I used had WMI query to get remote info, but it used different IP
to connect to the target machine than the one supplied in "hosts"
file.

How is IP address 127.0.0.1 used in terms of servers?

I'm working on a project which enables a web-based server which is accessible through 127.0.0.1:8081.
But I am not really able to understand the concept of the ip address. Does it mean the address is only available from the device which opens up the server, or across the whole LAN on any computer connected to that same router?
127.0.0.1 is a special IP address that refers to your local machine. Localhost resolves to this address. If you want to make your server accessible from the web or a different machine you will have to use a routable IP address.

IP address is not reachable or is invalid

I am facing a strange issue these days. I have a list of IP addresses which I want to connect to during the deployment using Jenkins. Now what is happening is, if I am deploying at one IP address (remote machine but in same location) in my local location server, I can successfully do that. But If I am trying to deploy to an IP address (remote machine in other country/region) It is throwing the error, saying
Error : Ip address XYZ is not reachable or is invalid.
Please be notified that I am able to get the response from the machine when I ping it using:
ping XYZ
But while trying to deploy on it using Jenkins, I am not.
Please let me know if there's any solution for this problem.
There isn't enough data points but you can look for these things
1. IP address, Check if all three machines are in same n/w (Jenkins Server, target and your machine)
You can check it with IP address of each machine
2. check Gateway set for Jenkins server
3. Best way if feasible is to ssh / rdp to your Jenkins server and try running your command manually that will give you
Local machine get loopback address(127.0.0.1), so it will be reachable or any local machine having IP address with same subnet mask thats called LAN.
When you are reaching out to remote machine, either it should be public IP address(visible to everyone in the world) or you must have connect to that Area-Network via VPN, this is called tunnelling to remote over the WAN (wide area network). Their(remote location) again, you will notice that all the IP address have same subnet mask as you have on the local machine.
So their could be be IP address duplication case in VPN scenario, where you are bale to ping but not able to reach. This is because, IP address is assigned to other machine but not you yours and ping responses are coming from that other machine. That means your machine is in failed to resolve ARP and in dormant state.

Access server in local network through domain

i have problem with access to server with domains.
Test url: testpage.example.com.
Server is in local network with port fowarding (80, 443), configured as web server using caddy server as reverse proxy.
Case 1 (using Asus router):
Connected on local network behind router. Server is in the same network as my computer. Everything works like a charm in and out of my network.
Case 2 (using internet provider router):
Connected on local network behind router. Can't access server with domain. Works with direct IP. Outside network, works as in case 1.
I used same server.
Does anyone know why this problem occured? How can i solve it?
Thanks,
David
Two options I can think of:
You could add a record to whatever DNS server you're using in Case 2.
You could write a short script that runs whenever you change network connections to modify your hosts file accordingly.
This happens when the server you are trying to reach "testpage.example.com" resolves to your router's external IP address. Because your public IP address is the same as server's IP address (even though inside your home network you have different private IP addresses) your requests are lost in the ether.
As a workaround you can resolve the testpage.example.com manually on your local machine.
For Windows c:\windows\system32\etc\hosts
For Linux /etc/hosts
testpage.example.com 192.168.1.102 -> private IP of the machine serving the site.

access local server from other networks

I created a localhost server using servlets.
I want to know how to access from other networks(other ip addresses).
what to do for that?
any answers will be helpful for me
you should use public ip address,instead of local ip address to access over the networks.
You can access it by giving IP address of your machine in your application url in place of localhost while accessing it from another machine in the same network.
you can use your ip address instead of localhost.and also need to configure firewall.The firewall can be configured by: choosing the Windows Firewall from the Control Panel, then click on Exceptions -> Add Port and enter name and number: your server, port and leave transport protocol as TCP.
e.g,
http://10.4.0.198:8080/project

Resources