How do I make my game connect to a server without real IP address? - networking

I'm making an XNA game. When I started, I had a broadband connection with real IP, so I could host servers of any kind without any problem, but now I don't have that connection any more and I want to be able to let players from outside my local network connect to my server again. How do I do that? How do big guys at studios do that?

Cheap option:
Configure your home router (it does have real, but probably dynamic, IP address) to forward connections on some port of your liking to your server on the local network. Read up on Network Address Translation - that's the trick routers use to hide a network behind a single routable IP.
Setup a DDNS account somewhere, so people can find your game server by name instead of changing IP address.
Expensive options:
Buy static IP package from your ISP (not always available).
Deploy your game at a Hosting Service.

Generally there are two ways to connect two clients:
Give each client other client's IP address and let them connect to each other.
Give each client a mid-server's IP address and tunnel the traffic through it.
First way assumes each client has a real IP address and they both can be a server to one another. Second way is for when one or both clients don't have real IP address.

Related

Will DHCP server give me always same IP?

I have question on DHCP server in home router. I have founded, that I have same IP address in my notebook for some time. I don't know, how long it last, but it is probably few weeks at least. Will DHCP server ever change my local IP if i will still connecting to that Wi-Fi?
I am asking, because I am working on home automation system and I don't know if i had to keep care about checking if my devices has same IP...Because there will be server, which will remember IP of its clients (lets say ESP8266 modules). Must I periodically check IP address (in my modules) and send new IP to server (in case of change)? Or DHCP server will not change IP address of my modules, connected to that DHCP server? And what about situation when ESP8266 module will disconnect (lets say it will be off for few days) - is it common to get different or same IP from DHCP after connection again?
Thanks!
Simple solution would be reserving IP address for your ESP8266 modules in your DHCP server that they always receive the same IPs.
With regards to your questions:
My routers DHCP server saves clients and keep information about them unless it is deleted explicitly or number of saved clients gets larger than number of addresses available. It serves always the same IP to saved clients. Obviously it depends on the router and might be different in your case.
I'd not check for IPs manually, I'd rather reserve the IPs for the modules as said above.
If your DHCP server stores client information it will give the same IPs to your modules upon reconnect. Otherwise not it won't be necessary the case.
If you use or consider using MQTT server (my preferred way :) ) for your home automation (it has integration in many systems like e.g. Home Assistant) you won't need to care about IP addresses of your modules at all you'd only need to fix IP of the MQTT server.
Another option can be addressing your modules (or/and server) using host name instead of IPs. If you develop n Arduino this GitHub thread might be helpful.

Identifying correct IP address of my machine

Let's say we have a wifi at home. When I google "whatsmyip", it gives me public IP address, which is essentially IP address of my router on the internet.
Now lets say I have two machines (A and B) both hosting a web server. I want to reach to a web-server on my machine 'A' from outside my local network (from some other corner of the world), how I can ping to that specific machine to my network. I understand for outgoing requests from my machine we have NAT, but what about incoming request to a specific machine? How router resolves it?
How I can check that IP(for incoming requests) in my windows/linux machine?
e.g let's say I have a tomcat server running on port 8080 on machine A. Now if I do localhost:8080/home, it displays "Hello World". Now one of my friend in let's say in Europe wants to access "/home" end point. What ip would he use?{IP}:8080/home. Means how he'll identify my machine, as to the internet only router's IP address is visible
To be able to reach your comptuer on the LAN behind your router you will need to do a port forward.
All connections to your public x.x.x.x:p ip/port address are forward to y.y.y.y:p
You can't forward different connections with the same port to a different machine in your lan, you will have to implement a more sophisticated approach to be able to do that, like a load balancer and apply a rule's base on the domain etc.
To be able to ping, you have to forward ICMP request to your lan machine.

How to connect two devices through Wifi without using mDNS?

I have an embedded webserver running on a device. Now I want a smartphone app to connect to the webserver. They are on the same wifi network but they don't know each others IP addresses.
I understand that this problem is often solved by implementing the mDNS protocol on the server. But are there any alternatives? Can the server maybe ask for specific IP address or similar?
If it has to be entirely automated, such that the embedded webserver is discoverable, perhaps scan the entire netblock looking for the correct response "http://[IP_address]/yes-im-the-one" from your embedded webserver?
Although beware, some network monitors may then consider the IP of your smartphone/device that does that scan "dangerous" and cut it off from the network - this is probably only a "big enterprise" problem.
...after you "find" your server, perhaps the application should cache/remember this, so it doesn't have to scan next time.
Other things you could do: give your embedded webserver a static IP on the LAN, either by setting this on the device itself, or via a DHCP reservation from whatever is the local DHCP server on the LAN.
What allot of emended devices do is come delivered with a static LAN IP already set on it, then it's up to the sysadmin to change their computer's IP temporarily to be in the same range, then they can visit the webserver or telnet into the default IP, and change it to what they want (to match their network's IP range)

How to Find My Proper Ip Address to Connect to Another Computer Remotely

My friend wanted to connect to my computer using Remote Desktop Connection. But the problem is I am confused what my Ip address is.
My computer is connected to the internet via router via broadband internet network. My ip address is dynamic.
Here, my main purpose is not only the remote connection but also learning how dynamic ip connect to another pc.
I searched for ip address on Google. They show me an ip address. But I think it is not mine, it's related with the router or broadband network. I also find a WAN ip (it is different from that i found on google) on router settings. It did't work.
I used Team Viewer. It worked perfectly. But I want to do that manually because I am going to make a multiplayer game on GM8.
It will helpful if someone explain about ip and port forwarding.
Teamviewer is a great tool, but uses different techniques than what you plan to do. Teamviewer always uses an outgoing connection and use a mediator on the Internet to connect you and the other PC.
You should ask your Internet provider if he technically enables you to be reachable from the outside Internet. Often this is not possible at all, even if you configure your router the correct way.
When you ask this you can ask him if you have a static IP.
It seems you are not aware of basics of IP networking, so I'd strongly advise against trying this on your router as wrong settings would render it useless. But here's for your information how port forwarding and IP Address and dynamic DNS can be used to solve your problem.
Basically your ISP is likely to give you a router having an IP address. If this IP address is a global IP address, it is possible to connect to this IP from outside. How do you find out whether your IP address is global? Look for your WAN IP address setting. If it is in 10.x.x.x or 192.168.x.x range, it's unlikely to be global and in that case it might not be possible to connect to your computer from outside - without help of a third server (some kind of a registration server, where you connect and register your application). The Registration server would determine your globally visible IP address and then convey it to another Application who is interested in connecting to it. This is somewhat complicated to make it work (but if you intend to make a game - this is something you'd have to do regardless). This is mostly how software like TeamViewer would work.
If you have a global IP address - it means it can technically be reached from anywhere in the world. In that case you could use port forwarding to make things work for you. Port forwarding works basically as follows - You expose a certain port (on TCP) to external world - say 8000 and then you make a setting like following on your router.
<TCP>-<RouterIP>-8000 --> <TCP>-<Your LAN IP><Your application Port>
(You can find you lan ip using ipconfig on windows or ifconfig on Linux).
Now all connections coming to port 8000 would be directed to your application. You might want to do it on UDP as well and the protocol above would change. That is how you 'open' a few ports to be accessible from outside, configure them on your router and then run corresponding applications on your network.
There's another thing called dynamic DNS, where the IP address you use if it is dynamic (and global) can be registered with a Dynamic DNS server so that you don't have to know and remember the current WAN IP Address. But that can be for later.
Hope that helps.

How do I monitor network connections to see what address a certain program is contacting

I made a program many years ago, that connects to a SQL Server database (port 1433), and I no longer have the code for this application, but I need to know whether it is trying to connected to the domain name exampleDomain.com or if it is connecting directly to the IP address, xxx.xxx.xxx.xxx.
I need to find this out because I want to switch hosting providers, but cannot let this application stop working, so I'm not sure if changing the IP Address of the SQL server will affect the program.
Is there a way I can tell what this program is connecting to? The raw IP Address or the domain Name?
thanks.
Use wireshark. http://www.wireshark.org/
It's free, easy to use, and very powerful.
You can monitor all traffic coming out of your PC and you can filter the traffic by type. So first I would look for any DNS communication that has MyDoman.com and then look at TCP connections.

Resources