Host server on Raspberry - c#

Ive made a simple chat Program in c#. It uses tcp. I can start the server and clients can connect and chat if everyone is in the same network.
I now want to put the server on my raspberry pi which has raspbian installed.
So far so good it works and i can connect again if everyone is in the same network, but now i want to access the server over the internet as a private person cant geht their hands on an public static ip adress, ive read that i could use ddns.
I have a host name on no-ip and installed noip2 on the raspberry and followed the instructions.
On their site they write you can test it with the command sudo noip2 -S. It shows that it connected with my account and will update my hostname.
In theory everything should be working, but i cannot connect to the server neither to the raspberry.
Anyone of you knows what i can do to make it work or is it the completely wrong way?
Thanks in advance!

You could use dyndns together with cname.
You would need to open port 80, 443 on your router.
This implies risk for the other devices in your network.
Instead of using rpi locally you could get a small virtual hosting server at AWS/Google for around 3$ per month.

Simply put, if you don't have a public IP, there's no way to connect to your RPi. If the IP address starts with 192.168, 172.16 through 32 or 10. then it's by convention (or definition depending on how you look at it) a non-routable address which means you can't get to it over the Internet.
DDNS is just a way of translating from a name to an IP address and doesn't imply anything about being accessible to the public. Noip is just a way of being able to associate a name with a dynamic IP address, which again does not imply anything about being accessible to the public. In other words, if www.yourdomain.com resolves to 192.168.1.2 (for example), it doesn't matter who can resolve the name, they still can't get to your server.
If your router has a public IP (which you said it doesn't) then you would be able to do a NAT translation, but based on what you said, that's not possible either.

Related

How to connect my .net application to SQL Server via internet

I have created a C# application with a login form (I use SQL Server database and SSMS). The database is on my PC, when I run the program on another PC which is in the same network as mine, everything works fine, but when I connect one of the laptops on another network, an error occurs: "The path wasn't found".
Is it possible to connect with the server remotely, via internet or something,
without having to be on the same network?
I already have:
Opened tcp and udp ports
Allowed SQL Server ports in Windows Firewall
Added an inbound rule for tcp (port 1433) and udp (port 1434)
Allowed remote connections
Here is my connection string:
Data Source=<server name>;Initial Catalog=Name;User ID=Minko;Password=Password1
This is not a programming question, but a Networking one.
To have a server reachable in the internet, is a costly mater. The static IP adress alone will cost a pretty penny, never mind actuall hardware.
On a small/no budget, VPN is perhaps the only way. Via VPN you can connect two local Networks (the home side of the Routers), allowing devices to talk as if they were physically in the same network.
No change to the programm is nessesary. If it works local, it works over VPN. The network classes do not care if the target is on the same computer, the same Switch or the Voyager probes.
The user will have to connect to teh VPN endpoint you have to provide - and usually can provide for cheap with any decent Router.
First off you should definitely change that PW.
Also - you make the comment that you are trying to use the same program to connect from a different network - implying that you haven't changed the IP address...
Are you sure you're using your public IP address? (Not your local network one that will start with 10. / 172. / 192.
Make sure you're using your public IP address... if you do this even if you're on the same network it will treat it as if you're not. It seems to me like you're still trying to use the local network's IP.
If it persists make sure you can reach the PC itself: ping ip-of-host in Powershell.
Connecting C# with SQL Server Database in a Local Area Network (LAN)
Try these steps one by one :
1- Find your public IP address using ( www.whatismyip.com ) for example.
2- Check that you can connect to the database using the public IP. To do that go to SSMS, and in the server name try to use IP-address only, or "IP-address\[instance-name]. If doesn't work, then you have to fix this first. Check this: https://dba.stackexchange.com/questions/62165/i-cant-connect-to-my-servers-sql-database-via-an-ip-address
3- When step 2 works, then you can use the "IP-Address\[instance-name]" in the connection string.

MSTSC.exe with STUN

Is it possible to connect mstsc.exe of one PC of one maching behing NAT to another machine behing NAT via STUN / hole punching.
If yes, could you please help how it can be done in c#.
As i understand there're lots of public stun servers over internet and the idea is to get some sorts of public address and then pass it as command line argument to mstsc ?
Thanks
Actually seems this problem - unability to access one PC behind NAT from other PC behind NAT is solved by Microsoft in 2009 (!).
It is possible to set a secure IPv6 name for a computer behind NAT and use it for remote desktop connection from outside PC because there's no need to come via nat for IPv6.
https://learn.microsoft.com/en-us/previous-versions//bb727045(v=technet.10)

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.

How do I make my ASP.Net website viewable in my private home network using IIS 6.0?

I want to know how I can make website available in my private home network? I know I am supposed to make my IP address static but I still do not know the complete steps to accomplish what I want to do. Is this even possible? If it is can someone please explain to me what I have to do?
A lot of ISP's won't allow you to receive requests on port 80. However, you can test this by trying...
-Install IIS - when you go to http://localhost, you should see an IIS start page.
-If you have a router/switch, you'll need to access the admin interface on it. This is usually default 192.168.1.1, but varies by manufacturer. You'll also need to get the local IP address of your IIS server. Go to run, hit CMD, and type IPCONFIG.
-Inside the admin interface, you'll have port forwarding. Forward port 80 to the IP address of your IIS server. Save.
-Now, get your actual IP address by going to a site like whatsmyip.com.
That should do it. Ask a friend or a family member to browse to your IP address. If they see your site, your ISP allows you to host. If they don't see it, your ISP has it blocked..
Having said that, you should check out serverfault.com - this question is more suited for that site.
This is pretty easy but you need to read up on some security before making anything live.
Static IP addresses cost more money than dynamic ones so I suggest signing up to http://www.no-ip.com/. It's requires installing a program which updates a domain which your ip address everytime it changes.
You will also need to use port forwarding on your router so it knows to send all http requests to your PC. HTTP data to passed normally through port 80 or 8080.
Hope this helps.
Check this out: http://msdn.microsoft.com/en-US/library/1y1404zt(v=VS.90).aspx

Testing a Remote Client-Server Application

Yesterday, I posted a question on some tips doing this Remote Client-Server Application in C#. So now, our group was able to create one. The problem is, we cannot think of ways on how we can test it since we are currently on different locations for our weekend break.
If anyone of you has any idea on how we can test it, please give us some hints.
Since you have both client and server programs, you can simply run them both on same PC and test them just like they would be on different machines. (use "localhost" or "127.0.0.1" as IP address of server)
It's enough to test program algorithm, and once it work on same PC, it should actually work on any two machines over internet/LAN.
Of course you should understand how networking actually works. Whoever you are connecting, must be visible to you. If you are going to connect via internet, server's IP address might not be enough. Something like http://www.showmyipaddress.com/ might show ISP's front, "white" address. And user, who run the server might have "grey" IP address, behind a NAT. So if you are going to use something like showmyipaddress.com , check your real IP address by typing "ipconfig -all" in windows command line. If ipconfig shows same IP, there are high chances it will work over internet (just check your firewall).
Have one of you setup the server, the other the client. Make sure your configurations match (use the server IP address, as you will probably not have a server name that can resolve via DNS).
Browse to http://www.showmyipaddress.com
Your ip address is listed there
Tell your ipaddress to the others (You need to open a port in your FW/router if you have one)
Tell them to change localhost to your ipaddress in the application and then connect.
you can use VMWare and run virtual machine (it's your choice), and run the server and the client in the same machine.
or you can run it on the same machine, just run : "ipconfig" on the command prompt ! get the IP and use it, or in some languages you can use the keyword "localhost", good luck

Categories