This question already has answers here:
Understanding Stun working
(1 answer)
What is STUN and does it need a port-forwarded server?
(1 answer)
Closed 7 months ago.
My understanding is that the STUN server aids in establishing a communication channel between different devices by obtaining their public IP address.
But how does obtaining the public IP address help when the devices are behind a NAT.
I've tried communicating through sockets to the devices public IP address (public IP obtained from https://whatismyipaddress.com/), yet this communication has not gone through?
So how does the services of a STUN server differ from me communication via my known public IP address?
Related
I am looking for a gateway service to transform an IPv6 address to an IPv4. I have a VPS connected to an IPv6 Network but my ISP is on IPv4. So I can't (or don't know how) connect via SSH to my VPS server.
I will appreciate any suggestions?
So you have a client machine on an ipv4-only network and you want to ssh into a machine on an ipv6-only network.
There are a few options.
6to4, works automatically through relays found by internet routing. 6to4 gateway machine must have a public IPv4 address. ipv6 address block is derived from ipv4 address. Relays are sometimes overloaded leading to poor performance.
teredo, works through relays found by internet routing but requires a configured server for connection setup. Several operators run free public teredo servers. Works from behind most NATs. Can be a bit fragile and relays are often overloaded.
configured point to point tunnels either free or paid for. Well-known free operators include Hurricane Electric and gogo6. Free tunnels may have restrictions on allowed protocols and/or poor performance.
I have 'Socket test v-3.0' software installed on two different PCs.
Using it can create a TCP server on 1st PC and a TCP client on 2nd PC.
When I connect both the PCs on LAN I can establish a connection & can communicate between the Server & Client.
But, When I connect both the PCs to individual Internet connections (Using dongles having different ISPs), I couldn't establish the connection between the Server & Client.
How can I do that?
Please help me out..
The private address 192.168.x.x is address that can be used for direct connection only in your private network. If you want to connect to your machine from public internet you have two options:
Get a public IP address
Configure a port forwarding
Public IP address could be get from your internet provider but it is usually requires some extra payment dependent on your service provider policy.
Port forwarding can be configured at the device at the border between your private network and internet. The device does the NAT (network address translation) between your private network and intenet. Use google if you are not sure about NAT.
Such a device can be your own device like an ADSL modem or a set top box. But such a device could be in the internet provider network. If you own the device then you can configure the port forwarding yourself. Modems usually have a web interface where you can easily configure port forwarding. See the documentation to your modem or whatever you have.
If the NAT device is in internet provider network then you have to ask it to configure port forwarding for you. Before you ask please read something about port forwarding so you are sure what you want to configure.
I feel this question is best started with a simplified version of the scenario.
Server A is connected to the public internet.
Server B is in a private Network and uses network address translation to connect to the internet.
I own both servers and can edit the software on them.
The ip addresses of the servers and the nat router are known to me.
Using Winsock, I need to create a connection between them. I know enough about winsock for this to be trivial if the connection is started from server B, but I need server A to start the connection.
I want to avoid using additional libraries if possible as it would appear to me that I only need to figure out what ip and port server A needs to use when starting the connection.
What additional information do I require, How do I acquire it, and How do I act upon the information.
note: I have investigated other similar questions, but none of them addressed this situation. I am not sure if this should have been asked on server fault or another site, but if so please say which one before flagging as "off topic" instead of closing the question wordlessly.
You need to setup port forwarding on the NAT device to the machine on the private network. Exact steps are device/manufacturer-specific, but here's the general idea:
Pick a port number, configure the NAT device so that connections to its public IP and that port are forwarded to the IP of your private server and the port where your application is listening.
Hello I am writing a server application with multiple clients.
For this i first authenticate the clients and the SOCKADDR_IN of the connected ones gets saved in an array.
Then i use the following to answer a specific client:
if(myArray[i].sin_addr.s_addr == current.sin_addr.s_s_addr)
This works because I am getting a LAN IP at the moment. Later when the server will not be in the same network and two clients from the same network connect I will get the same IP twice.
At least when i check the IP of mine and my brothers computer over one of the many sites that show the IP i see the same.
So how can i differentiate two computers in the same network from a remote server?
To do what you are asking, each client would have to explicitly send to your server the local IP it is using to send packets to your server, then your server can store that extra IP along with the IP it receives on inbound packets from that client. If the two IPs are different than you will know that the client is behind a router/NAT, and you will have to use both stored IPs as a pair to uniquely identify individual clients from the same network. Your communication protocol will need a small handshake to establish that information. For example:
C -> S: HELLO I want to talk to you
S: detects client's public IP:Port to send packets to
S -> C: WELCOME who are you
C: detects local IP that OS is using to route packets to/from the server
C -> S: IAMSAM here is my local IP
S: associates both public and private IPs with the client, allows further communication
If a client has the same public and private IPs then it is directly connected to the Internet.
If the public and private IPs are different than the client is behind a NAT:
If multiple clients are behind the same NAT then they will have the same public IP but different private IPs.
Clients on different NATs will have different public IPs but can have the same private IP.
I have a question about network connections among computers.
I've made some applications where messages pass through the Internet (via sockets) to make a connection between two devices. However, a strong condition is that two devices must be connected to the same network.
Can anyone give me a trick how to create a communication using sockets between two computers even if they are connected to different netwkorks?
Thank you in advance.
Here is a great tutorial on how to use sockets and general networking
(in java) http://www.thenewboston.org/watch.php?cat=25&number=38
In order to communicate between two diffrent networks over the internet, you will need to do something called port forwarding. What that does is that when your public IP of your network receives a packet with a spesific port number. The router knows where to send that packet to which local IP.
If you dont port forward and receive some data. The router doesent know where to send the packet. Therefore it discards it, which means others wont be able to connect to you.
You will only need to port forward the network with your server (using the example i linked). How you do that is by logging in to your router, and say that a port which the server uses gets forwarded to the IP of the PC hosting the server.
On the other network (client) you will need to change the IP address of which the client shall connect to. That IP address needs to be your public IP of your server's network. You can find that by connecting to the server's network and go to: http://www.whatsmyip.org/ . Keep in mind that public IP addresses may change over time.
Hope this helped!
-Kad