Getting ip address of local computer connected to proxy server - c#

I am currently implementing a HTTP proxy server and i need to get the local computers' ip addresses connected to it. Note that I am not referring to the remote server's ip address and it's not an ASP.NET app but rather a desktop app. The user on a different computer will input the ip address and port number of the proxy server through a browser, say Mozilla Firefox for instance, and i really need to get the user's ip address.
I am looking everywhere over the internet and i can't find a decent solution. Any idea please?

Related

Connecting Tcp Client from one device to Tcp Server in another device

The Tcp client/server code I'm working with is here: client and server.
As the title goes, I'm running the server code on my computer and I want to connect to it from another device using the client code. My question is, to what ip address does my client code have to connect? I know there are many related posts, but I'm only getting information on what's wrong rather than the solution.
This is a common problem when developing client/server applications. In a typical home network, there are multiple local IP addresses and a single external IP address. All devices communicating with your network from the outside must use the external IP address. However, when writing client/server applications, if you simply input the external IP address as the address to connect to, you'll quickly discover this won't work.
You need to use Port Forwarding. The client and server will be communicating over a specific port, and Port Forwarding is how your router knows which local IP address to send data to when the client is connecting to the external IP address. You want to login to your router settings, navigate to the section regarding Port Forwarding, and specify that communication over the port you're using in your server should be redirected to the local IP address that your server is running on. Exactly how to change these settings on your router depends on which router you're using.
Run the ipconfig command in a Windows Command Prompt on the machine running your server. Obtain the local IPv4 address from the results. This is the address to use when Port Forwarding the port used by your client/server applications. Adjust your router settings accordingly, and then your client should be able to use your external IP address just fine.
To find your external IP address, any website such as http://www.whatsmyip.org/ should work fine.
If you want to avoid all of these problems for now and simply test your application on your home network, then use the local IPv4 address found when running the ipconfig command on the machine your server is running on. Note that this will only work if both the client and server are running on the same network.

How to handle any request coming to my virtual wifi hotspot in Windows 7

I want to take control over all the requests which arrive to the virtual wifi hotspot.
I opened up a wifi hotspot via Microsoft Virtual WiFi Mini Adaptor through command prompt. I used netsh wlan start hostednetwork. I also put it into static ip mode to overcome with the android stuck at obtaining ip address issue. Everything is working fine.
Some time ago I built a server software with C# which binds to internal ip address of the wifi hotspot. I use it as a file server, remote computer controlling purposes.
Here is core section: If you connect to the hotspot from a device like android phone or pc, open the browser and type http://192.168.137.1:8080/ (hotspot pc ip address) on address bar, you simply connect to it and a home page appears and so on. But I want every client to be redirected to my server.
So regardless of what they put into address bar like google.com, facebook, yahoo, they will be redirected to my server and visit its homepage. This is something like controlling DNS, I guess. Is it possible to take control over every request that way?
I finally figured it out. First of all I need a DHCP server.
Here is one: http://tftpd32.jounin.net/
This also may help: http://www.wikihow.com/Set-up-DHCP-on-a-Local-Area-Network
With this program I can run and configure its DHCP server. I need to set the DNS server address to my own servers address (like 192.168.0.1 which is default gateway). So when clients connect to my virtual hotspot, they will receive this as a DNS server address. Clients will request every domain name from that address (instead of 8.8.8.8 which is Google Public DNS for example). So I also need a DNS server of my own. It must be bound to port 53 (192.168.0.1:53 with UDP protocol, not TCP!!) which is default DNS port number. Main server must be bound to 192.168.0.1:80 with TCP. Notice that it is bound to HTTP port.
If everything goes fine after doing these, my DNS server will give main servers IP address to clients regardless of the domain name IP they requested. Hence they will connect to my server instead of real ones (facebook,youtube etc).
By the way the DHCP server program which I given the url of is working very well for me. It is very simple and efficient. It will eliminate issues like "Android stuck at obtaining IP address". It also provides other servers such as TFTP, SNTP, SysLog and DNS. It also works so fine even without any advanced virtual hotspot program (such as Connectify). You may only call "netsh wlan start hostednetwork" command. I don't intent any promotion here. I'm just trying to help.
If you want redirecting all domain search queries to your ip address you have to control the DNS.
The best way is to operate as a proxy service between your client and the destination, so you can manipulate the query of the client.

need to store IP address, is Request.UserHostAddress ok to use?

In a website I need to store visitor's IP address for security logging. I m not sure about IP address and its details just have an idea there are different types of IP addresses like user, internet provider, LAN IP, WAN IP etc.
I am even not sure which IP address I should store in database for security I have searched and came to know about Request.UserHostAddress that it returns The IP address of the remote client.
Can you please guide and confirm if I am sotring correct IP and using correct code to retrive IP ?
Edit
I am not certain why IP address is stored but know just as a good practice to do it. My guess is IP need to be stored to identify user, just in case if something wrong happens, with stored IP address it can be traced out who did it or from what area this request came.
Is there some other use of IP, please direct me as well.
Cheers
IP stands for Internet Protocol, which is the protocol underlying HTTP, which is what clients use to connect to web servers. Every machine on an IP network has a unique IP address.
UserHostAddress is the correct property for identifying the client's IP address. It does not matter whether the client is coming from the LAN or WAN, nor does it matter who their internet provider is. Internet providers (and I'm simplifying here) help route traffic to your website, but don't actually participate as an endpoint; the ISP's servers will not show up in the UserHostAddress, only the actual client who initiates the connection, which is typically the user.
Note that I say typically. IP addresses can be spoofed, or they can be hidden behind a proxy (like TunnelBear) or other obfuscation system (like Tor). There's no way to guarantee that you have the "real" IP address of the "real" user, but the aforementioned property is the closest you're going to be able to get.

User IP in a Remote Desktop Connection

I am building an ASP.NET application
If I run a website in a remote connection, what is the Ip that i get from System.Web.HttpContext.Current.Request.UserHostAddress? Is it the ip of my local network or the ip of the network that the remote computer is connected?
I need to detect the ip of the network that the user is actually using, not the one of the remote computer.
Any ideas?
Is it the ip of my local network or the ip of the network that the
remote computer is connected?
It will be the local IP.
I need to detect the ip of the network that the user is actually using, not the one of the remote compute
Forget about this requirement. This information is not part of the HTTP protocol specification and is never sent to the server. You will need to either provide an input field on your site where you could ask the user to enter this information or have some desktop application running on the server that will be used to detect the IP of the remotely connected user and then launch the default web browser by navigating to your web application and passing it as a query string parameter for example.
Yet another possibility you may consider is to use some sort of ActiveX control that will retrieve this information. But we all know the constraints that come with ActiveX.

Is this an issue with my firewall or chrome? Xmlhttprequest to C# listener error

I have a Httplistener set up in C# that reads the Get parameters and performs an action, just a small personal project. Now, when I send the requests from an HTML page in chrome with 127.0.0.1:port it works fine. But if I use my full IP (the one i get from googling my IP), the xmlhttp request fails. Same when I host the file on my site. Is this an issue with Chrome or my firewall settings? I opened the port to all connections and excused Visual Studio from my firewall as well
The IP address that you get from Google (or wherever) is your IP address to the internet. On your network, you will most likely have an IP address for your network that is different than your internet address.
I did a google search and found this page to help you follow the steps required by various operating systems to determine what your computer's IP address is.
As an alternative to using an IP address, you can use your computer's name.
If you want to use your internet IP address so that you can access your site from the internet and not just your network, you'll need to set up port forwarding.
You need to set up port forwarding on your router.

Categories