How to build Opera unite like functionality using .NET?
When we run opera browser and enable the opera unite then it shares our desktop on web and we can access it over internet without having a static IP, how does this works?
You need to map your dynamic IP to some static DNS name. One easy to use solution would be a DynDNS service. For these you get a small client program (or good routers already have a dyn dns client already implemented), that simply maps your current ip address to a specfic dns name.
After getting this done it depends on how variable you like it:
- Do you have one master that should be able to look on various client PCs for help?
- Do you like to connect two clients which are both have dynamic ips?
In the first case your master is the one how always ensure to map his current ip address to the dns name. On the router maybe some port forwarding is needed and your clients get a vnc client with reverse mode enabled. This allows everyone to built up a connection to your master and sharing the desktop without any changes on the client site. Only on the master site has something to be done (dynDns and port forwarding).
In the second case it is a little bit more complicated. Now you got two dynamic IPs that like to connect to each other. This is normally be done through some kind of mediator. Means both machine connect to some master (reachable through some DNS name). Now both machines have a bi-directional connection to the master and the master will simply take the data from the first client and forwards it to the second and vice versa. To take all the burden from the master it would be possible that the master in a first step sends the ip address of client A to B and vice versa. Then in a first step both trying to connect to each other directly. This method is known as UDP hole punching and does not always work, which then leads to a fallback to use the master instead.
Two examples that are using the second approach are Skype and join.me.
All these techniques don't have to do anything with .Net. It is pure knowledge about ethernet, TCP/IP, internet, etc. And due to the fact that you have to do a lot of work in this low-level area i would think that C# is not the ideal framework to accomplish this task. Maybe to put the GUI as last step over it all, but for the real work behind the scenes you need some decent network know-how which is mostly independent from the programming language you are using.
You should run your own DNS server. And whenever an user opens the browser and logs in, you should send the current IP address of the user to your server and update in your local DNS. Since you will have only a subdomain (desktop.operaunitecom), whenever someone hit your url it first goes to operaunite DNS server from where it will fetch your IP address. When the user's session closes you should remove the DNS entry. This could be a possible solution.
Related
There's a similar question ( Can I temporarily override DNS resolution within a .NET application? ) but I just can't figure it out with the meager response there.
Background info
I have a server set up in my home network, an old computer. Our router has the right ports forwarded, the server runs server software for things like http, svn, games, etc. I've got a domain name registered that always points to our external IP address. For all intents and purposes, I've got a typical webserver set up. My friends can game on my server by connecting via the domain name, I can push and pull svn projects, etc.
The only problem is that I also need to use my server when I'm connected to my home network (the same network as the server). Using the domain name results in Windows resolving it to our own IP address, and my router is too retarded to realize it just needs to forward it back into our network to the server as per the usual. I've done some looking around, configuring, telnetting and DNS overriding, but I have it on good authority that our ISP apparently crippled the DNS override feature of their routers to prevent this exact scenario. Apparently they don't like internal loopbacks.
I now basically have to keep 2 configs for each of my server's services: one config that specifies the domain name for when I'm abroad, and a second that specifies the server's internal IP for when I'm at home. It's frustrating because it just isn't always possible.
I want to instantiate a global DNS resolution request/response listener that will do the following: if the requested domain name matches a given string, override the IP in the response with one of my choice.
I've looked things up like easyhook, dllimport, msdn pages, etc, but I still can't figure out where to actually start, which classes I need to get access to, and so on. I basically have no pre-existing code for this particular problem.
I have Visual Studio, years of relatively simple programming experience and a good understanding of unfamiliar code and everything else, just no idea how to start or what to look for.
Many thanks for anything that can get me going.
Couple of pointers, DNS is as you mentioned some server somewhere that knows how to resolve a Domain name to an IP ADDRESS. There are two types of responses 1) Definitive for the domain and 2) Not Definitive for the Domain. Obviously any Definitive response will win.
DNS does not run at TCP/IP layer it runs one layer below using UDP (port 53). As a result DNS is tied into the TCP/IP stack whereby the stack first looks locally to a local host table and sees is the name is there, if it cannot find it the stack will send out the DNS request prior to the session start or SYN packet flying. In order for this to happen, the DNS servers must resolve the address.
I do not fully understand your issue because most Windows servers only have 1 IP Address and one associated Domain name. Unless of course they are using DHCP which just means the server uses multiple address on boot up and DNS server receive updates to what those new address are.
Public vs. Private IP addresses are the responsibility of a router. The router is configured to do NAT (Network Address Translation). This allows a private server to have unroutable addresses like 10.10.1.100 etc. But the router will answer ARPs for the public address making the public network think the router is the public address. So one of your solutions could be to convert your server to a private address and use a "real" router that can perform NAT. Port forwarding is not really routing rather it's a way to "trick" packets destined for one port number to be forwarded to another port dedicated for that application.
My suggestion is to either follow the suggestions above or add the Domain names you want to the local Host table on the server. This will get you what you want. A better solution is to configure your own server to be a DNS server definitive for your domain, that way you get to control everything.
I ended up solving this with (as a few have suggested) the hosts file after all.
I first used ManagedWifi to set a network connection monitor. It detects changes to my connection status and reports the network name.
Then I wrote a console app that stays open (using Hidden Start allows me to hide the window) and safely modifies the hosts file, then flushes the DNS cache. This seems to work in pretty much realtime. :)
Using some code from codeproject, I converted a LAN scanner into an ASP.NET web application. The app attempts to ping all ips in a given user inputted range. The app works fine locally. However, I wanted to make the app online. Using the free AZURE subscription, I put the site online. However, it does not scan the user's LAN. This might be because it is trying to scan the LAN of the server computer my app is deployed on. I would like to know if using ASP.NET, it is possible to scan the CLIENT'S LAN instead of the SERVER'S LAN. Please comment if you require the code for the webpage. The website should be online at http://nkdscan.azurewebsites.net/index . Please comment if any other info is required.
No, this is not possible using a server-based scanner, because that server has no way to access the private IP addresses used by the local network. You can only do this from the inside of a network, which means client-side code of some sort.
The problem is that your local network addresses (192.168.., 10...*, etc) are not accessible from the other side of your router. When you connect to a remote server your router does some address translations to make it look like it's sending the request. If you have lots of computers in the same LAN connecting to the same server it's going to look very much like lots of connections from the same place.
If you want build internet server applications then you need to know the basics of how the internet works, and this is one of the important ones. You don't have to know how things happen at the packet level (although that's interesting too), but some understanding of things like network address translation is essential.
I want to get the IP address I am being NATed behind (e.g. the one presented to the outside world, rather than my local IP).
Something like the result you get from www.ipchicken.com.
How can I get this? The local IP info is easy to find, but I have no idea how to go about getting the IP assigned from the ISP.
The reason I need it is that my network infrastructure is such that I have two gateways out of the network. If one fails, it trips over transparently to the other. All well and good, but there is no alerting mechanism to tell me that I have failed over.
I believe it's quite hard to get this information. I guess another approach I could take is by putting a webservice on an externally hosted webserver - the idea being that it returns the IP of the querying host. (However, I have no idea how to do this either!) I suspect this might be the easiest way to go.
Your computer does not have access to this information locally; you need to get it from one of the many network services which do this.
There are lot's of ip services
This one, for example. Just make a GET request and parce a simple html : http://checkip.dyndns.org/
Some more details about this service (Policies and rules):
http://dyn.com/support/developers/checkip-tool/
upd
If you need to check your IP frequently you'd better to add your own web-service. .dyndns.org allows to check the ip once for 10 minutes.
You can run some .net code on web-service:
((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString();
But I think a script language (python?) will be more suitable.
Is it possible to write C# code as below and send email using mnetwork in different country?
MSExchangeWebServiceURL = mail.something.com/ews/exchange.asmx
It's a web service URL. This works great when I run the same code from home network, my friends home network anywhere around, but when I run it from my client's location in Columbia it fails.
I have a valid user name and password on that Exchange Server. Is there any configuration that I can set to achieve this?
BTW this code below works when I run it within office network and any network within any home network. I have tried it at least with five friends network in Plano, Texas. I want this code to work running from any network in another country.
My client in Columbia can connect to the web service using a browser using the same user name and password, but when I run the code above it is not able to connect to our web service.
EDIT: Based on the comments and updated post, I would wager that the client location has a proxy server or firewall that is blocking the traffic. The client probably needs to add the relevant domain to whatever "whitelist" they have.
If it works from an internal network, then the problem is most likely not the code. You need to debug it and see what error turns up when running it outside of the network. Then check the logs on the firewall and the target exchange server to see what is happening.
One possible culprit is that the DNS name is not setup outside the office network, or that the office firewall is not setup to pass traffic (or only to pass SMTP traffic) from the internet to the server in question. Another is that Exchange Web Services is not setup properly to accept requests from the outside world. That can be tested from http://www.testexchangeconnectivity.com/.
If this isn't enough for you to get there, post more info about what errors you are seeing. "It isn't working, I want it to work" kind of reminds me of the Star Trek TNG episode about the species who kept telling Geordi to "make it go".
If you are asking if the code works (which it doesn't look like you are but it's in your post) you should ask on stackoverflow. If you are wondering why it won't work from home Its likely because the edge server is not set up to relay, and if you are at home and not vpn'd into the network that's all you have access to.
You need to break this down a bit:
What's the MSExchangeWebServiceURL? I don't need to know your real URL, but is this resolvable from your home network? i.e. is it an internal DNS host (server.mycompany.local) or is it an externally-resolvable DNS host (mail.yourcompany.com)?
If it's internal, like another poster said, you'll at least need to VPN in (or replace that with the external URL).
I'm not a big C# guy, but I'm guessing it's looking for your Exchange Server hostname or FQDN, and since the type is "SMTP" it wants to establish a TCP session with your mail server. You can likely test this out by opening up your command prompt and trying to telnet <MSExchangeWebServiceURL> 25. When that works, my guess is your code will work too.
I want to know how I can send or recieve data over internet to/from a computer in subnet
(this is specially in context to PPP users bcoz getting static IP is not so much in practice).
I actually want to create an application which can transfer file between 2 specific computer in WAN.
so what are things I need to know about to do the same..(ex. PRESENT IP or MAC ADDRESS etc..)
PROGRAMATICAL EXPLANATION ALTHOUGH PREFFERED,BUT IS NOT NECCESARY...
FTP?
There is a vast torrent of useful results in google, I seriously suggest to google before you ask here.
For instance, have a look at the top result: http://www.devarticles.com/c/a/C-Sharp/Network-Programming-in-C-sharp/
Apart from that, FTP, as suggested by Colin, may be what you're looking for. If you're new to using FTP in C# have a look at http://www.google.com/search?q=c%23+ftp
Put the information on a public IP server, so both computers keep polling if there is new data and send / download that data as needed. A single text file can hold necessary flags such as paths and other info you need.
server just need to be a web server, which means IIS or similar should be installed.
I'm thinking part of your question has to do with one of the computers not having a static IP address. If the two computers, A & B, don't know each others IP address, then an alternative is to use a server. Either A can store the information on the server to be picked up by B, or A can register his current IP address on the server for B to lookup and then connect to A, assuming firewalls don't interfere. Another scheme is that A and B can simultaneously connect to the server, and the server can relay data between the two.
Of course, all of this communication would be done using techniques such as those suggested by mafutrct and Colin.
This question sounds to me like the difficulties of NAT Traversal and trying to establish peer-to-peer connectivity over the Internet. I stumbled on this question researching the best way to set up Internet connectivity to a device that is sitting behind a firewall. I am assuming that the device behind the firewall has to initiate the connection, that a Internet server application (on a Public IP address) to at least manage the initiation of the connection is required, and the Internet server application may also have to act as a relay if the difficulties of NAT is not able to be traversed.
http://en.wikipedia.org/wiki/NAT_traversal
http://en.wikipedia.org/wiki/Peer-to-peer
A good example of this is LogMeIn. Where the application is installed on the computer that needs to be accessible over the Internet, that application communicates with the LogMeIn Internet servers, you can establish a connection to that computer either by initiating through the LogMeIn servers and connecting peer-to-peer over port 80/443 using NAT Traversal (this would be establishing a peer-to-peer connection) or by initiating through the LogMeIn server and the LogMeIn server acting as a relay if peer-to-peer is unable to be established.
Please note; you must have an application (something running) on both ends of the connection on the Internet, there is no other way. Just like FTP that was mentioned earlier (FTP Client, FTP Server)... but in this case it is peer-to-peer (basically you are writing your own Client and Server... or if you have to use a relay... Client--Relay--Server
http://en.wikipedia.org/wiki/LogMeIn
"The service connects the remote desktop and the local computer using SSL over TCP or UDP and utilizing NAT traversal techniques to achieve peer-to-peer connectivity when available."
The part I don't know is can the relay go in both directions; and I am figuring the device behind the firewall must have to constantly manage the open connection to the Internet Server that is the relay. Those are the questions I am wrestling with now.
Also, you may want to check out this post.
C# byte streams through TCP
From that time, till this date I have encounter so many problems with these four kinds of NAT that basically without an external server you cant do anything.
This is because, one computer can never find where the other one is located as suggested in the pic.
Here PC 'A' will never come to know about the port that corresponds to PC 'B' on R2B without an external server.Even more, if somehow u come to know about the ports you are still in a situation that the router wont allow you to access it if the request hasn't been made for your IP.